Implement priority token.

This commit is contained in:
Greyson Parrelli
2026-07-23 00:45:25 -04:00
parent 1c457c602a
commit b8775432b4
6 changed files with 280 additions and 39 deletions
+24 -21
View File
@@ -17,17 +17,19 @@ type PlayerView struct {
// View is the full game state as seen by one player.
type View struct {
GameID string `json:"gameId"`
Code string `json:"code"`
Phase Phase `json:"phase"`
Round int `json:"round"`
MaxRounds int `json:"maxRounds"`
MaxPets int `json:"maxPets"`
YouSeat int `json:"youSeat"`
Turn int `json:"turn"`
ShopRow []Card `json:"shopRow"`
DeckCounts []int `json:"deckCounts"` // remaining shop cards per tier
Players []PlayerView `json:"players"`
GameID string `json:"gameId"`
Code string `json:"code"`
Phase Phase `json:"phase"`
Round int `json:"round"`
MaxRounds int `json:"maxRounds"`
MaxPets int `json:"maxPets"`
YouSeat int `json:"youSeat"`
Turn int `json:"turn"`
// PrioritySeat is the seat currently holding the priority token.
PrioritySeat int `json:"prioritySeat"`
ShopRow []Card `json:"shopRow"`
DeckCounts []int `json:"deckCounts"` // remaining shop cards per tier
Players []PlayerView `json:"players"`
// Pending is included for everyone so opponents see a trade is in
// progress, but the revealed options are only shown to the trader.
Pending *PendingTrade `json:"pending,omitempty"`
@@ -38,16 +40,17 @@ type View struct {
// ViewFor builds the state visible to the given player.
func (g *Game) ViewFor(playerID string) View {
v := View{
GameID: g.ID,
Code: g.Code,
Phase: g.Phase,
Round: g.Round,
MaxRounds: MaxRounds,
MaxPets: MaxPets,
YouSeat: -1,
Turn: g.Turn,
ShopRow: g.ShopRow,
WinnerSeat: g.WinnerSeat,
GameID: g.ID,
Code: g.Code,
Phase: g.Phase,
Round: g.Round,
MaxRounds: MaxRounds,
MaxPets: MaxPets,
YouSeat: -1,
Turn: g.Turn,
PrioritySeat: g.PrioritySeat,
ShopRow: g.ShopRow,
WinnerSeat: g.WinnerSeat,
}
for _, deck := range g.ShopDecks {
v.DeckCounts = append(v.DeckCounts, len(deck))