aboutsummaryrefslogtreecommitdiff
path: root/go/game/stack.go
diff options
context:
space:
mode:
authorFlorian Fischer <florian.fischer@muhq.space>2023-02-04 13:09:57 +0100
committerFlorian Fischer <florian.fischer@muhq.space>2025-08-20 15:46:39 +0200
commitdb60306a942874062bf7a706aca6d31e15f6fef9 (patch)
treea1a1df2baa4a75c1ab7114216f2090cb08debc0e /go/game/stack.go
parenta907c8794f572a5b330bea1f9143887c8f2a4c4a (diff)
downloadmuhqs-game-db60306a942874062bf7a706aca6d31e15f6fef9.tar.gz
muhqs-game-db60306a942874062bf7a706aca6d31e15f6fef9.zip
introduce state-based action
State-based action are executed anytime a action resolved to handle events caused by the game state. Currently state-based actions only destroy unit with more damage than health.
Diffstat (limited to 'go/game/stack.go')
-rw-r--r--go/game/stack.go7
1 files changed, 4 insertions, 3 deletions
diff --git a/go/game/stack.go b/go/game/stack.go
index 9132ae13..cf0622ce 100644
--- a/go/game/stack.go
+++ b/go/game/stack.go
@@ -17,11 +17,11 @@ func (s *Stack) IsEmpty() bool {
return len(s.Actions) == 0
}
-func (s *Stack) Push(a Action) {
+func (s *Stack) push(a Action) {
s.Actions = append(s.Actions, a)
}
-func (s *Stack) Pop() {
+func (s *Stack) pop() {
l := len(s.Actions)
if l == 0 {
log.Fatalf("Can not pop from empty stack")
@@ -41,6 +41,7 @@ func (s *Stack) Pop() {
func (s *Stack) Resolve() {
for !s.IsEmpty() {
s.gameState.AllPassing(false)
- s.Pop()
+ s.pop()
+ s.gameState.stateBasedActions()
}
}