aboutsummaryrefslogtreecommitdiff
path: root/go/game/stack.go
diff options
context:
space:
mode:
authorFlorian Fischer <florian.fischer@muhq.space>2025-07-24 05:42:50 -0400
committerFlorian Fischer <florian.fischer@muhq.space>2025-08-20 15:57:29 +0200
commit7b148fe16cd87a6043c3350b92a479d78f6415c5 (patch)
treed4372c7af30415586c8bedbe319b40ad0b685f46 /go/game/stack.go
parent135a654e497cd53ca66da31b839c83251a072e3c (diff)
downloadmuhqs-game-7b148fe16cd87a6043c3350b92a479d78f6415c5.tar.gz
muhqs-game-7b148fe16cd87a6043c3350b92a479d78f6415c5.zip
check the wincondition after the state based actions
Diffstat (limited to 'go/game/stack.go')
-rw-r--r--go/game/stack.go17
1 files changed, 14 insertions, 3 deletions
diff --git a/go/game/stack.go b/go/game/stack.go
index a4ba6a49..62783bf2 100644
--- a/go/game/stack.go
+++ b/go/game/stack.go
@@ -45,11 +45,22 @@ func (s *Stack) pop() {
}
}
-func (s *Stack) resolve() {
+func (s *Stack) resolve() []*Player {
for !s.IsEmpty() {
- for !s.gameState.allPassing(false) {
+ for {
+ passing, w := s.gameState.allPassing(false)
+ if len(w) > 0 {
+ return w
+ }
+ if passing {
+ break
+ }
}
s.pop()
- s.gameState.stateBasedActions()
+ w := s.gameState.stateBasedActions()
+ if len(w) > 0 {
+ return w
+ }
}
+ return nil
}