From 7b54ed8e53f6c4f090fd6481c855f3dacbfd46c3 Mon Sep 17 00:00:00 2001 From: Pavel Flegr Date: Thu, 7 May 2026 19:46:01 +0200 Subject: [PATCH] a --- internal/engine/game.go | 6 ++++++ internal/engine/script.go | 13 +++++++++++++ internal/llm/client.go | 2 ++ 3 files changed, 21 insertions(+) diff --git a/internal/engine/game.go b/internal/engine/game.go index 886aaa2..dd2c52d 100644 --- a/internal/engine/game.go +++ b/internal/engine/game.go @@ -585,6 +585,10 @@ func (g *Game) buildState(p *Player, chosenSuit Suit) GameScriptState { copy(h, pl.Hand) hands[i] = h } + discardCopy := make([]Card, len(g.DiscardPile)) + copy(discardCopy, g.DiscardPile) + deckCopy := make([]Card, len(g.Deck)) + copy(deckCopy, g.Deck) return GameScriptState{ ActiveSuit: g.ActiveSuit, @@ -593,6 +597,8 @@ func (g *Game) buildState(p *Player, chosenSuit Suit) GameScriptState { ChosenSuit: chosenSuit, Hand: handCopy, PlayerHands: hands, + DiscardPile: discardCopy, + Deck: deckCopy, CurrentPlayerIndex: g.CurrentPlayer, PlayerCount: len(g.Players), HandCounts: counts, diff --git a/internal/engine/script.go b/internal/engine/script.go index 1ad8651..5079223 100644 --- a/internal/engine/script.go +++ b/internal/engine/script.go @@ -97,6 +97,8 @@ type GameScriptState struct { ChosenSuit Suit Hand []Card // acting player's full hand (including cards being played) PlayerHands [][]Card + DiscardPile []Card + Deck []Card CurrentPlayerIndex int PlayerCount int HandCounts []int // cards held by each player, in seat order @@ -237,6 +239,15 @@ func (sr *ScriptRuntime) stateVal(s GameScriptState) goja.Value { } playerHands[i] = cards } + discardPile := make([]interface{}, len(s.DiscardPile)) + for i, c := range s.DiscardPile { + discardPile[i] = map[string]string{"suit": string(c.Suit), "value": string(c.Value)} + } + deck := make([]interface{}, len(s.Deck)) + for i, c := range s.Deck { + deck[i] = map[string]string{"suit": string(c.Suit), "value": string(c.Value)} + } + counts := make([]interface{}, len(s.HandCounts)) for i, n := range s.HandCounts { counts[i] = n @@ -260,6 +271,8 @@ func (sr *ScriptRuntime) stateVal(s GameScriptState) goja.Value { "chosenSuit": string(s.ChosenSuit), "hand": hand, "playerHands": playerHands, + "discardPile": discardPile, + "deck": deck, "currentPlayerIndex": s.CurrentPlayerIndex, "playerCount": s.PlayerCount, "handCounts": counts, diff --git a/internal/llm/client.go b/internal/llm/client.go index 0e7a1b5..0e873ac 100644 --- a/internal/llm/client.go +++ b/internal/llm/client.go @@ -61,6 +61,8 @@ The script MUST export these functions (no classes, no imports): chosenSuit string — suit the player chose when playing an Upper (wildcard) hand Card[] — the acting player's FULL hand, including cards being played playerHands Card[][] — full hands of all players in seat order + discardPile Card[] — full discard pile snapshot (includes previously played cards) + deck Card[] — current draw deck snapshot currentPlayerIndex number — acting player seat index playerCount number — total number of players handCounts number[] — cards held by each player (seat order)