diff options
| author | Florian Fischer <florian.fischer@muhq.space> | 2025-08-19 15:42:02 +0200 |
|---|---|---|
| committer | Florian Fischer <florian.fischer@muhq.space> | 2025-08-20 14:46:14 +0200 |
| commit | 57c5ae839d197d03525681baf244c3042379fda1 (patch) | |
| tree | 2a3562f3a173a64c35dcdc08d39ffc10dc0c0601 | |
| parent | 57316649861e43698226cd51ee0b208c591a53d9 (diff) | |
| download | muhqs-game-57c5ae839d197d03525681baf244c3042379fda1.tar.gz muhqs-game-57c5ae839d197d03525681baf244c3042379fda1.zip | |
remove timing checks from action validation
| -rw-r--r-- | go/game/state.go | 45 |
1 files changed, 2 insertions, 43 deletions
diff --git a/go/game/state.go b/go/game/state.go index c0b3ed37..d91bbe35 100644 --- a/go/game/state.go +++ b/go/game/state.go @@ -235,10 +235,6 @@ func (s *LocalState) stateBasedActions() []*Player { } func (s *LocalState) IsValidPlay(a *PlayAction) error { - if s.activePhase != Phases.ActionPhase { - return errors.New("play actions can only be declared during one's actions phase") - } - if a.Card.IsPermanent() { // Equipments may be played not on a spawn tile but equiped to the next played unit if a.Card.Type == CardTypes.Equipment && len(a.Target().sel) == 0 { @@ -256,10 +252,6 @@ func (s *LocalState) IsValidPlay(a *PlayAction) error { } func (s *LocalState) IsValidMove(a *MoveAction) error { - if s.activePhase != Phases.ActionPhase { - return errors.New("move actions can only be declared during one's actions phase") - } - u := a.Source().(*Unit) tile := relaxedTileTarget(a, a.Target().sel[0]) @@ -276,26 +268,6 @@ func (s *LocalState) IsValidMove(a *MoveAction) error { return nil } -func (s *LocalState) IsValidAttack(a *AttackAction) error { - if s.activePhase != Phases.ActionPhase { - return errors.New("Attack actions can only be declared during one's actions phase") - } - - unit := a.Source().(*Unit) - if !unit.Attack.Valid() { - return fmt.Errorf("%s can not attack", unit.card.Name) - } - - target := a.Target().sel[0].(Permanent) - if !IsPositionInRange(unit.tile.Position, target.Tile().Position, unit.Attack.MaxRange()) { - return fmt.Errorf("attack target on %s is not in attack range %d of %s on %s", - target.Tile().Position.String(), unit.Attack.MaxRange(), unit.card.Name, - unit.tile.Position.String()) - } - - return nil -} - func (s *LocalState) isValidBuy(a *BuyAction) error { card := a.card() if s._map.HasStores() { @@ -332,10 +304,6 @@ func (s *LocalState) isValidBuy(a *BuyAction) error { } func (s *LocalState) IsValidEquip(a *EquipAction) error { - if s.activePhase != Phases.ActionPhase { - return errors.New("play actions can only be declared during one's actions phase") - } - uTile := TileOrContainingPermTile(a.Source().(*Unit)) eTile := TileOrContainingPermTile(a.equipment) if !IsPositionInRange(uTile.Position, eTile.Position, 1) { @@ -346,10 +314,6 @@ func (s *LocalState) IsValidEquip(a *EquipAction) error { } func (s *LocalState) IsValidArtifactSwitch(a *ArtifactSwitchAction) error { - if s.activePhase != Phases.ActionPhase { - return errors.New("play actions can only be declared during one's actions phase") - } - u := a.Source().(*Unit) uTile := TileOrContainingPermTile(u) artifact := a.Artifact @@ -367,10 +331,6 @@ func (s *LocalState) IsValidArtifactSwitch(a *ArtifactSwitchAction) error { } func (s *LocalState) IsValidArtifactMove(a *ArtifactMoveAction) error { - if s.activePhase != Phases.ActionPhase { - return errors.New("play actions can only be declared during one's actions phase") - } - u := a.Source().(*Unit) uTile := TileOrContainingPermTile(u) artifact := a.Artifact @@ -398,8 +358,6 @@ func (s *LocalState) ValidateAction(a Action) (err error) { err = s.IsValidPlay(a) case *MoveAction: err = s.IsValidMove(a) - case *AttackAction: - err = s.IsValidAttack(a) case *EquipAction: err = s.IsValidEquip(a) case *ArtifactSwitchAction: @@ -458,7 +416,7 @@ func (s *LocalState) checkActionTiming(a Action) error { func (s *LocalState) declareAction(a Action) { var err error - err = a.CheckTargets(s) + err = s.ValidateAction(a) if err == nil { err = s.checkActionTiming(a) @@ -469,6 +427,7 @@ func (s *LocalState) declareAction(a Action) { s.fireEvent(newDeclaredActionEvent(a)) } + log.Info("declare action", "action", a, "error", err) s.broadcastNotification(newDeclaredActionNotification(a, err)) if err == nil { t := a.Targets() |
