aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFlorian Fischer <florian.fischer@muhq.space>2025-08-19 16:58:24 +0200
committerFlorian Fischer <florian.fischer@muhq.space>2025-08-20 15:57:40 +0200
commit5992858282dd716bdffaee784914d2d5abd6dca6 (patch)
treedf7d32a8826a3539facc676271fd5439e78e35d9
parent9c9036a492c9dc5233688202f3df140afe93de9b (diff)
downloadmuhqs-game-5992858282dd716bdffaee784914d2d5abd6dca6.tar.gz
muhqs-game-5992858282dd716bdffaee784914d2d5abd6dca6.zip
do not check the target constraints twice
-rw-r--r--go/game/state.go38
1 files changed, 0 insertions, 38 deletions
diff --git a/go/game/state.go b/go/game/state.go
index d91bbe35..e7d77f4c 100644
--- a/go/game/state.go
+++ b/go/game/state.go
@@ -234,40 +234,6 @@ func (s *LocalState) stateBasedActions() []*Player {
return w
}
-func (s *LocalState) IsValidPlay(a *PlayAction) error {
- 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 {
- return nil
- }
-
- spawn := a.Target().sel[0].(*Tile)
- if !slices.Contains(s.AvailableSpawnTiles(a.Source().(*Player), a.Card), spawn) {
- return fmt.Errorf("spawn %v is not a valid spawn tile for %s",
- spawn.Position.String(), a.Card.Name)
- }
- }
-
- return nil
-}
-
-func (s *LocalState) IsValidMove(a *MoveAction) error {
- u := a.Source().(*Unit)
- tile := relaxedTileTarget(a, a.Target().sel[0])
-
- if !slices.Contains(u.MoveRangeTiles(), tile) {
- return fmt.Errorf("unit %s@%v can not move to %s",
- u.card.Name, u.tile.Position, tile.Position.String())
- }
-
- if !u.IsAvailableTile(tile) {
- return fmt.Errorf("unit %s@%v can not move to not available tile %v",
- u.card.Name, u.tile.Position, tile)
- }
-
- return nil
-}
-
func (s *LocalState) isValidBuy(a *BuyAction) error {
card := a.card()
if s._map.HasStores() {
@@ -354,10 +320,6 @@ func (s *LocalState) ValidateAction(a Action) (err error) {
}
switch a := a.(type) {
- case *PlayAction:
- err = s.IsValidPlay(a)
- case *MoveAction:
- err = s.IsValidMove(a)
case *EquipAction:
err = s.IsValidEquip(a)
case *ArtifactSwitchAction: