diff options
Diffstat (limited to 'go/game/state.go')
| -rw-r--r-- | go/game/state.go | 16 |
1 files changed, 14 insertions, 2 deletions
diff --git a/go/game/state.go b/go/game/state.go index f6bcbc8e..b72da192 100644 --- a/go/game/state.go +++ b/go/game/state.go @@ -458,6 +458,14 @@ func (s *LocalState) pushAction(a Action) { s.stack.push(a) } +type ErrDeclareSlowAction struct { + reason string +} + +func (err ErrDeclareSlowAction) Error() string { + return err.reason +} + func (s *LocalState) declareAction(a Action) { var err error @@ -471,8 +479,12 @@ func (s *LocalState) declareAction(a Action) { } case *FreeAction: default: - if a.Speed() == ActionSpeeds.Slow && !s.stack.IsEmpty() { - err = errors.New("slow action can not be declared while other actions are on the stack") + if a.Speed() == ActionSpeeds.Slow { + if !s.stack.IsEmpty() { + err = ErrDeclareSlowAction{"stack not empty"} + } else if s.activePlayerId != a.Controller().Id || s.activePhase != Phases.ActionPhase { + err = ErrDeclareSlowAction{"not action phase"} + } } } } |
