From b0a8cf800123af3fe6e200eee364457168afee04 Mon Sep 17 00:00:00 2001 From: Florian Fischer Date: Sat, 4 Feb 2023 13:09:57 +0100 Subject: 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. --- go/game/stack.go | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'go/game/stack.go') 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() } } -- cgit v1.2.3