From 2f01274717d62e59e4bf3b4426a2ec6a76ffac11 Mon Sep 17 00:00:00 2001 From: Florian Fischer Date: Thu, 16 Feb 2023 13:49:35 +0100 Subject: client: use only the currently available actions in the action choice --- go/game/unit.go | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) (limited to 'go/game/unit.go') diff --git a/go/game/unit.go b/go/game/unit.go index 4851a037..51383b77 100644 --- a/go/game/unit.go +++ b/go/game/unit.go @@ -184,7 +184,7 @@ func (u *Unit) HasFullAction() bool { func (u *Unit) FullAction() { } -func (u *Unit) AvailActions() (actions []Action) { +func (u *Unit) AvailSlowActions() (actions []Action) { if u.AvailMoveActions > 0 && u.Movement != INVALID_MOVEMENT() { actions = append(actions, NewMoveAction(u)) } @@ -202,11 +202,29 @@ func (u *Unit) AvailActions() (actions []Action) { } } + return actions +} + +func (u *Unit) AvailFreeActions() (actions []Action) { for _, p := range u.FreeActions { actions = append(actions, p) } + return +} + +func (u *Unit) CurrentlyAvailActions() (actions []Action) { + s := u.Controller().gameState + if s.ActivePlayer == u.Controller() && s.ActivePhase == Phases.ActionPhase { + actions = append(actions, u.AvailSlowActions()...) + } + actions = append(actions, u.AvailFreeActions()...) + return +} - return actions +func (u *Unit) AvailActions() (actions []Action) { + actions = append(actions, u.AvailSlowActions()...) + actions = append(actions, u.AvailFreeActions()...) + return } func (u *Unit) onPile(containing Permanent) { -- cgit v1.2.3