From 4a64688d77096e198a1cca03948acdcf46bb0dfd Mon Sep 17 00:00:00 2001 From: Florian Fischer Date: Mon, 21 Jul 2025 08:36:36 -0400 Subject: add comments and action assertion --- go/game/pileOfCards_test.go | 1 - go/game/player.go | 3 +++ go/game/state.go | 4 ++++ 3 files changed, 7 insertions(+), 1 deletion(-) diff --git a/go/game/pileOfCards_test.go b/go/game/pileOfCards_test.go index 55f68c7d..75467b57 100644 --- a/go/game/pileOfCards_test.go +++ b/go/game/pileOfCards_test.go @@ -104,7 +104,6 @@ func TestPocToList(t *testing.T) { } } - func TestPocFilterCards(t *testing.T) { base := NewDeckFromCardPaths(Sets.Base.CardPaths()) units := base.FilterCards(func(c *Card) bool { return c.Type == CardTypes.Unit }) diff --git a/go/game/player.go b/go/game/player.go index ef88cd81..f7f5be7c 100644 --- a/go/game/player.go +++ b/go/game/player.go @@ -151,6 +151,9 @@ func (p *Player) actionPhase() { if _, ok := a.(*PassPriority); ok { return } + if a == nil { + log.Fatal("Received nil action from ", p.Name) + } p.gameState.declareAction(a) p.gameState.stack.resolve() } diff --git a/go/game/state.go b/go/game/state.go index 1c773618..d5a9bfc6 100644 --- a/go/game/state.go +++ b/go/game/state.go @@ -51,6 +51,7 @@ func (s *LocalState) Players() []*Player { return s.players } +// PlayerById returns the player using its 1-based identifier. func (s *LocalState) PlayerById(id int) *Player { return s.players[id-1] } @@ -457,6 +458,7 @@ func (s *LocalState) declareAction(a Action) { if err == nil { t := a.Targets() if t != nil { + // FIXME: seperate between targets choices implemented as target s.events = append(s.events, newTargetEvent(a, t)) } } @@ -524,6 +526,8 @@ func (s *LocalState) allPassing(skipFirst bool) bool { switch a := _a.(type) { case *PassPriority: log.Printf("%s passed %d/%d\n", p.Name, i+1, nPlayers) + case nil: + log.Fatal("received nil action from ", p.Name, " at ", s.activePhase) default: s.declareAction(a) return false -- cgit v1.2.3