A real-time multiplayer card game built in Go with WebSocket connections. Players compete to be the first to empty their hand by playing melds (sequences or books) and manipulating cards on the table through the unique "mexe-mexe" mechanic.
Check it out: https://www.mexe-mexe.online/ It is FREE!
- Win condition: Be the first player to have 0 cards in your hand
- Alternative win condition: If the deck runs out, the player with fewer points/cards wins (not yet implemented)
- Turn-based: Players take turns in sequence
- Meld playing: On your turn, you can play a meld (sequence 🃊 🃋 🃍 or book 🂱 🃑 🃁) from your hand to the table
- Drawing: If you cannot play a meld, you must draw a card from the deck
- Turn ending: If no meld is available and no mexe-mexe moves are possible, your turn ends
The unique feature of this game! Once any meld is played on the table (by any player), "mexe-mexe" becomes available.
Mexe-mexe allows you to:
- Manipulate cards already on the table as if they were your own
- Rearrange existing melds to create new valid combinations
- Play cards from your hand by incorporating them with table cards
- Requirement: All resulting melds on the table must remain valid (proper sequences or books)
| Key | Action |
|---|---|
<- or -> |
Navigate cards |
s |
Select/deselect cards |
p |
Play selected meld |
d |
Draw a card |
e |
End turn |
q |
Quit game |
Responsibilities:
- WebSocket connection management
- User authentication
- Game room creation and matchmaking
- Player pairing (2 players per room)
Responsibilities:
- Core game logic and rule validation
- Game state management (player hands, table cards, deck)
- Turn flow control
- Meld validation (sequences and books)
- Communication through input/output providers
Responsibilities:
- WebSocket connection to server
- Terminal-based user interface
- User input handling
- Game state display
Input-Output: The game engine works with abstractions (InputProvider, OutputProvider) rather than concrete WebSocket implementations. Ideal for
alternative implementations (e.g. TerminalInputProvider).
- Concurrent Design: Each game runs in its own goroutine.
- Real-time Communication: WebSocket connections provide instant updates.
- State Management: Centralized game state with atomic operations.
Provider Pattern:
WebsocketInputProvider: Handles player input via WebSocketWebsocketOutputProvider: Sends game updates to clients
- Go 1.24.2
- Terminal environment (Linux/macOS recommended - Windows not tested)
go build cmd/server/main.go
./maingo build cmd/client/main.go
./mainClient → WebSocket → Server.HandleConnections()
├── Read JoinServerMessage
├── Authenticate user
├── Send WelcomeMessage
├── Read StartGameMessage
├── Create/join GameRoom
└── When room full (2 players) → Start game
Server creates:
├── engine.Game (with shuffled player order)
├── WebsocketInputProvider for each client
├── WebsocketOutputProvider for each client
└── Calls room.StartGame() → game.Start() in goroutine
Game Engine Loop:
├── For each player's turn:
│ ├── Call inputProvider.GetPlay() → blocks on WebSocket
│ ├── Validate play with IsValid()
│ ├── Execute play with MakePlay()
│ └── Update game state
└── Continue until win/quit condition
├── cmd/
│ ├── server/ # Server entry point
│ └── client/ # Client entry point
├── internal/
│ ├── engine/ # Game logic and rules
│ ├── server/ # WebSocket server implementation
│ └── client/ # Client implementation
└── └── service/ # Logger
Frontend (https://www.mexe-mexe.online/) and this README were vibe coded.
Guilherme Schu: [email protected]