diff options
| author | historia <[not public]> | 2026-09-18 20:03:13 -0400 |
|---|---|---|
| committer | historia <[not public]> | 2026-09-18 20:03:13 -0400 |
| commit | 79764732406d6484f67d3dec045483dcb5d08c28 (patch) | |
| tree | 7a64e8581a540b97ed554f5723e2d587424ab1c6 /internal/casino/types.go | |
| parent | f1e461ab6aec6b9bf056bbe2daa88a251e0f21da (diff) | |
| download | thehouseoficarus-79764732406d6484f67d3dec045483dcb5d08c28.tar.gz | |
feat: better card ascii art
Diffstat (limited to 'internal/casino/types.go')
| -rw-r--r-- | internal/casino/types.go | 58 |
1 files changed, 30 insertions, 28 deletions
diff --git a/internal/casino/types.go b/internal/casino/types.go index 3d31820..980769c 100644 --- a/internal/casino/types.go +++ b/internal/casino/types.go @@ -234,36 +234,24 @@ type Wallet interface { type EventType string +// Only the event types the games actually construct are defined. Payout and +// win styling travels on Event.Color, so there is no separate payout event +// type to keep in sync. const ( - EventJoined EventType = "joined" - EventBetting EventType = "betting" - EventBetPlaced EventType = "bet_placed" - EventRoundStarted EventType = "round_started" - EventResult EventType = "result" - EventPayout EventType = "payout" - EventTimedOut EventType = "timed_out" - EventLeft EventType = "left" - EventClosed EventType = "closed" -) - -type MenuKind string - -const ( - MenuSlotCommands MenuKind = "slot_commands" - MenuBlackjackBet MenuKind = "blackjack_bet" - MenuBlackjackTurn MenuKind = "blackjack_turn" - MenuBaccaratBet MenuKind = "baccarat_bet" + EventJoined EventType = "joined" + EventResult EventType = "result" + EventLeft EventType = "left" ) // MenuView carries a structured menu alongside its plain-text Message so the // presentation layer can enrich it (balances, command colors) without parsing -// message prefixes. +// message prefixes. It is deliberately game-agnostic: every game supplies a +// heading and its command list, and the renderer has no per-game switch that +// could silently drop a new game's commands. type MenuView struct { - Kind MenuKind - Body string // command list (MenuSlotCommands) - Title string // prompt heading (MenuBlackjackTurn) - Actions []string // available commands (MenuBlackjackTurn) - Commands []MenuCommand // unified command list for all casino menus + Heading string // prompt heading shown above the command list + ShowBalance bool // prepend the player's chips/credits balance + Commands []MenuCommand } // MenuCommand is one selectable command shown in a casino menu: the typed @@ -283,17 +271,27 @@ type Event struct { PrivateTo string Color string Public bool - Slot *SlotSnapshot - Blackjack *BlackjackSnapshot - Baccarat *BaccaratSnapshot - Menu *MenuView + // Snapshot is the optional per-game view attached to the event. A game + // implements the Snapshot interface for its view type; the presentation + // layer type-switches on it. Because the field is typed, a new game's + // snapshot can never be assigned without implementing the interface, and + // the event filter can test it with a single nil check instead of + // enumerating every game's field. + Snapshot Snapshot + Menu *MenuView } +// Snapshot is the marker interface for a game's structured event view. The +// method is unexported so only types in this package can implement it. +type Snapshot interface{ snapshot() } + type SlotSnapshot struct { Grid [slotGridRows][slotGridReels]string StoppedReels int } +func (*SlotSnapshot) snapshot() {} + // CardView renders one card for any card-based table game. type CardView struct { Rank string @@ -315,6 +313,8 @@ type BlackjackSnapshot struct { Players []BlackjackPlayerView } +func (*BlackjackSnapshot) snapshot() {} + // BaccaratBetView lists one participant's wager on a baccarat outcome. type BaccaratBetView struct { Name string @@ -330,6 +330,8 @@ type BaccaratSnapshot struct { Bets []BaccaratBetView } +func (*BaccaratSnapshot) snapshot() {} + type Participant struct { Name string Connected bool |
