This document outlines the system and library requirements, build instructions, and core functionality for both the CLI and server components of the Cribbage application.
The CLI provides a terminal-based user interface for interacting with the Cribbage game server. It allows users to log in, join or create games, view their hand, play cards, and track the game state.
- Go (version specified in
cli/go.mod) - github.com/charmbracelet/bubbletea: A Go framework for building terminal apps.
- github.com/charmbracelet/lipgloss: Style definitions for the TUI.
- Other dependencies are listed in cli/go.mod and cli/go.sum.
-
Ensure you have Go installed and configured correctly.
-
Navigate to the
clidirectory:cd cli -
Build the CLI application:
go build -o crib_cli main.go
Alternatively, use the BuildGame mage target:
mage BuildGame
This command builds the CLI for multiple platforms and places the binaries in the builds directory. This requires magefile.go and build.go to be configured correctly.
-
The executable
crib_cliwill be created in the cli directory, or in the builds directory if using the mage target.
- Login: Authenticates a user with the server.
- Lobby: Displays a list of open matches and allows users to join existing matches or create new ones.
- Game View: Presents the game board, player hands, and other relevant game information.
- Input Handling: Parses user input to perform actions such as playing cards or cutting the deck.
- State Management: Manages the CLI's state and updates the view based on server responses.
The server component provides the backend logic and API endpoints for the Cribbage game. It handles user authentication, match management, game state, and communication between clients.
- Go (version specified in go.mod)
- PostgreSQL: Database for storing game data.
- github.com/labstack/echo/v4: High performance, extensible, minimalist Go web framework.
- github.com/swaggo/echo-swagger: Swagger middleware for Echo framework.
- Other dependencies are listed in go.mod and go.sum.
-
Ensure you have Go installed and configured correctly.
-
Navigate to the server directory:
cd server -
Build the server application:
go build -o crib_server main.go
Alternatively, use the BuildServer mage target:
mage BuildServer
This command builds the server and places the binary in the builds directory. This requires magefile.go and build.go to be configured correctly.
-
The executable
crib_serverwill be created in the server directory, or in the builds directory if using the mage target.
-
Ensure PostgreSQL is installed and running. Configure the database connection string as needed.
-
Run the server executable:
./crib_server
- API Endpoints: Provides RESTful API endpoints for user authentication, match management, and game actions. See router.go and main.go for endpoint definitions.
- Match Management: Creates, joins, and manages Cribbage matches.
- Game Logic: Implements the rules of Cribbage, including card dealing, playing, and scoring.
- Database Interaction: Stores and retrieves game data from the PostgreSQL database.
- Real-time Updates: (Potentially) Implements real-time communication with clients using WebSockets or similar technologies.
- Swagger Documentation: Generates Swagger documentation for the API endpoints.