diff options
| author | Florian Fischer <florian.fischer@muhq.space> | 2023-02-21 10:42:31 +0100 |
|---|---|---|
| committer | Florian Fischer <florian.fischer@muhq.space> | 2025-01-27 16:43:51 +0100 |
| commit | 31105395f2af79a53777d923db412e0785ed649f (patch) | |
| tree | 0a1650908d2bea7a3f4602e9d3f4533840b545dd | |
| parent | d76655a521807f0aa6fae52de0a231a8531c660b (diff) | |
| download | muhqs-game-31105395f2af79a53777d923db412e0785ed649f.tar.gz muhqs-game-31105395f2af79a53777d923db412e0785ed649f.zip | |
fixup! validate equip and switch actions
| -rw-r--r-- | go/game/state.go | 13 |
1 files changed, 7 insertions, 6 deletions
diff --git a/go/game/state.go b/go/game/state.go index 347b5406..0ef8c4d4 100644 --- a/go/game/state.go +++ b/go/game/state.go @@ -205,27 +205,28 @@ func (s *State) IsValidEquip(a *EquipAction) error { uTile := TileOrContainingPermTile(a.Source().(*Unit)) eTile := TileOrContainingPermTile(a.equipment) - if !IsPositionInRange(uTile, eTile, 1) { + if !IsPositionInRange(uTile.Position, eTile.Position, 1) { return fmt.Errorf("Can only equip adjacent equipments") } return nil } -func (s *State) IsValidArtifactSwitch(a *EquipAction) error { +func (s *State) IsValidArtifactSwitch(a *ArtifactSwitchAction) error { if s.ActivePhase != Phases.ActionPhase { return fmt.Errorf("Play actions can only be declared during one's actions phase") } u := a.Source().(*Unit) uTile := TileOrContainingPermTile(u) - a := a.Artifact - aTile := TileOrContainingPermTile(a) - if !IsPositionInRange(uTile, aTile, 1) { + artifact := a.Artifact + aTile := TileOrContainingPermTile(artifact) + if !IsPositionInRange(uTile.Position, aTile.Position, 1) { return fmt.Errorf("Can only switch position with adjacent equipments") } - if a.Controller() != u.Controller() && a.Solid > 0 { + solid, err := artifact.XEffect("solid") + if err != nil && artifact.Controller() != u.Controller() && solid > 0 { return fmt.Errorf("Can only switch with solid artifacts you control") } |
