aboutsummaryrefslogtreecommitdiff
path: root/go
diff options
context:
space:
mode:
authorFlorian Fischer <florian.fischer@muhq.space>2025-08-19 15:42:02 +0200
committerFlorian Fischer <florian.fischer@muhq.space>2025-08-20 15:57:40 +0200
commit9c9036a492c9dc5233688202f3df140afe93de9b (patch)
tree9036816b4e1e171b2aa6735a044f0207323627b6 /go
parent3d36f5c92ec204f72d55df5b41e9bacdf5e87ba8 (diff)
downloadmuhqs-game-9c9036a492c9dc5233688202f3df140afe93de9b.tar.gz
muhqs-game-9c9036a492c9dc5233688202f3df140afe93de9b.zip
remove timing checks from action validation
Diffstat (limited to 'go')
-rw-r--r--go/game/state.go45
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()