diff options
| author | Florian Fischer <florian.fischer@muhq.space> | 2025-07-21 08:36:36 -0400 |
|---|---|---|
| committer | Florian Fischer <florian.fischer@muhq.space> | 2025-08-20 15:57:27 +0200 |
| commit | 4a64688d77096e198a1cca03948acdcf46bb0dfd (patch) | |
| tree | 6545776ec0c53a6d831e53da549f777326788afe /go | |
| parent | 4cfe2d81345bc3807bed3facd9a222dd6e789435 (diff) | |
| download | muhqs-game-4a64688d77096e198a1cca03948acdcf46bb0dfd.tar.gz muhqs-game-4a64688d77096e198a1cca03948acdcf46bb0dfd.zip | |
add comments and action assertion
Diffstat (limited to 'go')
| -rw-r--r-- | go/game/pileOfCards_test.go | 1 | ||||
| -rw-r--r-- | go/game/player.go | 3 | ||||
| -rw-r--r-- | go/game/state.go | 4 |
3 files changed, 7 insertions, 1 deletions
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 |
