dont marshal uninitialized players

This commit is contained in:
Bel LaPointe
2021-03-12 07:04:38 -06:00
parent 3efa60f2d0
commit aaf4ff3161
4 changed files with 44 additions and 2 deletions

View File

@@ -8,9 +8,11 @@ import (
"strings"
)
type Players [16]Player
type Game struct {
Pot Currency
Players [16]Player
Players Players
}
type Player struct {
@@ -32,6 +34,12 @@ func (game Game) GetPlayers() []Player {
return players
}
func (players Players) MarshalJSON() ([]byte, error) {
game := Game{Players: players}
subplayers := game.GetPlayers()
return json.Marshal(subplayers)
}
func (p Player) Empty() bool {
return p == (Player{})
}