From 5992858282dd716bdffaee784914d2d5abd6dca6 Mon Sep 17 00:00:00 2001 From: Florian Fischer Date: Tue, 19 Aug 2025 16:58:24 +0200 Subject: do not check the target constraints twice --- go/game/state.go | 38 -------------------------------------- 1 file changed, 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: -- cgit v1.2.3