diff options
| author | Florian Fischer <florian.fischer@muhq.space> | 2023-02-04 13:09:57 +0100 |
|---|---|---|
| committer | Florian Fischer <florian.fischer@muhq.space> | 2025-01-27 16:43:47 +0100 |
| commit | b0a8cf800123af3fe6e200eee364457168afee04 (patch) | |
| tree | d72f347458c48e26750432e222b3a0d2c11e7351 /go/game/stack.go | |
| parent | 77b53f7feb759c3969ec3937edddad8cf4e4a00f (diff) | |
| download | muhqs-game-b0a8cf800123af3fe6e200eee364457168afee04.tar.gz muhqs-game-b0a8cf800123af3fe6e200eee364457168afee04.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.go | 7 |
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() } } |
