a
This commit is contained in:
parent
d61129dfe5
commit
7b54ed8e53
3 changed files with 21 additions and 0 deletions
|
|
@ -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,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue