a
This commit is contained in:
parent
d61129dfe5
commit
7b54ed8e53
3 changed files with 21 additions and 0 deletions
|
|
@ -585,6 +585,10 @@ func (g *Game) buildState(p *Player, chosenSuit Suit) GameScriptState {
|
||||||
copy(h, pl.Hand)
|
copy(h, pl.Hand)
|
||||||
hands[i] = h
|
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{
|
return GameScriptState{
|
||||||
ActiveSuit: g.ActiveSuit,
|
ActiveSuit: g.ActiveSuit,
|
||||||
|
|
@ -593,6 +597,8 @@ func (g *Game) buildState(p *Player, chosenSuit Suit) GameScriptState {
|
||||||
ChosenSuit: chosenSuit,
|
ChosenSuit: chosenSuit,
|
||||||
Hand: handCopy,
|
Hand: handCopy,
|
||||||
PlayerHands: hands,
|
PlayerHands: hands,
|
||||||
|
DiscardPile: discardCopy,
|
||||||
|
Deck: deckCopy,
|
||||||
CurrentPlayerIndex: g.CurrentPlayer,
|
CurrentPlayerIndex: g.CurrentPlayer,
|
||||||
PlayerCount: len(g.Players),
|
PlayerCount: len(g.Players),
|
||||||
HandCounts: counts,
|
HandCounts: counts,
|
||||||
|
|
|
||||||
|
|
@ -97,6 +97,8 @@ type GameScriptState struct {
|
||||||
ChosenSuit Suit
|
ChosenSuit Suit
|
||||||
Hand []Card // acting player's full hand (including cards being played)
|
Hand []Card // acting player's full hand (including cards being played)
|
||||||
PlayerHands [][]Card
|
PlayerHands [][]Card
|
||||||
|
DiscardPile []Card
|
||||||
|
Deck []Card
|
||||||
CurrentPlayerIndex int
|
CurrentPlayerIndex int
|
||||||
PlayerCount int
|
PlayerCount int
|
||||||
HandCounts []int // cards held by each player, in seat order
|
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
|
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))
|
counts := make([]interface{}, len(s.HandCounts))
|
||||||
for i, n := range s.HandCounts {
|
for i, n := range s.HandCounts {
|
||||||
counts[i] = n
|
counts[i] = n
|
||||||
|
|
@ -260,6 +271,8 @@ func (sr *ScriptRuntime) stateVal(s GameScriptState) goja.Value {
|
||||||
"chosenSuit": string(s.ChosenSuit),
|
"chosenSuit": string(s.ChosenSuit),
|
||||||
"hand": hand,
|
"hand": hand,
|
||||||
"playerHands": playerHands,
|
"playerHands": playerHands,
|
||||||
|
"discardPile": discardPile,
|
||||||
|
"deck": deck,
|
||||||
"currentPlayerIndex": s.CurrentPlayerIndex,
|
"currentPlayerIndex": s.CurrentPlayerIndex,
|
||||||
"playerCount": s.PlayerCount,
|
"playerCount": s.PlayerCount,
|
||||||
"handCounts": counts,
|
"handCounts": counts,
|
||||||
|
|
|
||||||
|
|
@ -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)
|
chosenSuit string — suit the player chose when playing an Upper (wildcard)
|
||||||
hand Card[] — the acting player's FULL hand, including cards being played
|
hand Card[] — the acting player's FULL hand, including cards being played
|
||||||
playerHands Card[][] — full hands of all players in seat order
|
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
|
currentPlayerIndex number — acting player seat index
|
||||||
playerCount number — total number of players
|
playerCount number — total number of players
|
||||||
handCounts number[] — cards held by each player (seat order)
|
handCounts number[] — cards held by each player (seat order)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue