Skip to main content

Module domain

Module domain 

Source
Expand description

Domain logic types and helpers.

Structs§

AvailableGame
A game that is visible in the public lobby and can be joined. These only get created with respect to a given user, i.e. they are “available” to that user. Either the user is the host, or participating in the game, or they can join as a guest.
Card
A playing card consisting of a Face and a Suit.
Dealer
Represents the dealer player in a two-player game.
Discarding
Represents the game state during the discarding phase, where players select cards to contribute to the crib.
Finished
Represents the terminal state of a completed game.
Game
Represents a game with a host, optional guest (i.e. no one has joined and game is deemed to be in the lobby), name, and current state.
GameId
Unique identifier for a game instance.
GameServices
No external services required.
Pegging
Represents pegging information for a specific player during scoring.
Pending
Represents players who are to acknowledge the current game phase before the game can proceed to the next phase.
Play
Represents a single play in the pegging phase of the game.
PlayState
Represents the current state of play during the pegging phase.
Player
Represents a player in the game.
Playing
Represents the state of a game during the playing phase.
Points
Represents a point value in the game.
Pone
Represents the pone (non-dealer) player in a two-player game.
Position
Represents a player’s position in the game.
Rank
A card rank used for ordering/comparison.
Roles
Represents the roles assigned to players in a round.
ScoreItem
Represents a single scoring event in the game.
ScoreSheet
A collection of scoring items accumulated for a hand, crib, or play phase.
Scoreboard
Represents the scoreboard.
Starting
Represents the state of the game during the starting phase, before the deal is assigned and initial hands are dealt.
UserId
Identifier for a user/account.
Value
Point value of a card.

Enums§

Availability
How a game appears in the public lobby / matchmaking pool.
CardsError
Errors that occur when manipulating cards in piles, hands, crib, etc.
DomainError
Domain-specific errors that represent invalid game actions.
Face
The face of a playing card (Ace through King).
GameCommand
Commands that drive the game state machine.
GameEvent
Domain events which represent the single source of truth for game history and are persisted in the event store. The current game state is derived by folding them in order.
GoStatus
Represents the status of a “go” during pegging.
Phase
Current phase of the Cribbage game.
ScoreKind
Represents the kind of scoring event that occurred during play.
ScorePhase
Represents the distinct phases of the game.
Suit
The four suits in a standard French playing card deck.

Constants§

PLAYER0
The first player (index 0).
PLAYER1
The second player (index 1).
PLAYERS
An array of all players in the game.

Traits§

HasCrib
Trait for game states that contain a crib.
HasCutsForDeal
Trait for game states that track the “cut for deal” phase.
HasDeck
The main draw pile / stock.
HasHands
Trait for game states that have player hands.
HasPegging
Trait for types that contain pegging information.
HasPending
Trait for game states that track player acknowledgments.
HasPlayState
Trait for types that expose a PlayState.
HasRoles
Trait for types that contain player roles.
HasScoreboard
Trait for types that expose a Scoreboard.
HasStarterCut
Trait for game states that have a starter card.

Type Aliases§

Crib
The crib is the special pile of cards discarded cards that belongs to the dealer and is scored at the end of the pegging phase.
CutsForDeal
The two cards cut by the players to determine who deals first.
Deck
The deck contains all cards at the start of the game and is drawn from during dealing and for the starter cut.
Hand
A hand is the set of cards a player holds privately during play. 6 cards dealt then 4 after discarding to the crib.
Hands
Fixed-size array holding all players’ hands.
Positions
Represents the positions of both players in the game.
ScoringCrib
A strongly typed alias for scoring operations related to the crib.
ScoringDealer
A strongly typed alias for scoring operations associated with the dealer.
ScoringPone
A strongly typed alias for scoring operations associated with the pone.
StarterCut
The card turned up after the deal as the “starter”.