diff options
| author | Florian Fischer <florian.fischer@muhq.space> | 2024-03-26 20:36:22 +0100 |
|---|---|---|
| committer | Florian Fischer <florian.fischer@muhq.space> | 2025-01-27 16:43:56 +0100 |
| commit | e82bce56827e5a43c02895feef86394f39f319d7 (patch) | |
| tree | d5f8340d65976fd45618e6664721bebd0c5b19b8 | |
| parent | af88dce12b3bf140bba6bfb4bc08fb440cd42627 (diff) | |
| download | muhqs-game-e82bce56827e5a43c02895feef86394f39f319d7.tar.gz muhqs-game-e82bce56827e5a43c02895feef86394f39f319d7.zip | |
only generate ArtifactMoveActions if the switched positions are suitable
| -rw-r--r-- | go/game/tile.go | 20 | ||||
| -rw-r--r-- | go/game/unit.go | 5 |
2 files changed, 16 insertions, 9 deletions
diff --git a/go/game/tile.go b/go/game/tile.go index 47f9a5d6..89d3ec3f 100644 --- a/go/game/tile.go +++ b/go/game/tile.go @@ -137,16 +137,20 @@ func (t *Tile) IsFree() bool { return t.Permanent == nil } +func (t *Tile) IsSuitableForCard(card *Card) bool { + if t.Water && !card.hasPlacementConstrain("swimming") { + return false + } + if !t.Water && card.hasPlacementConstrain("swimming") { + return false + } + + return true +} + func (t *Tile) IsAvailableForCard(card *Card) bool { if t.IsFree() { - if t.Water && !card.hasPlacementConstrain("swimming") { - return false - } - if !t.Water && card.hasPlacementConstrain("swimming") { - return false - } - - return true + return t.IsSuitableForCard(card) } x, err := t.Permanent.Card().getXEffect("crew") diff --git a/go/game/unit.go b/go/game/unit.go index c875fa50..9f823a0d 100644 --- a/go/game/unit.go +++ b/go/game/unit.go @@ -172,7 +172,10 @@ func (u *Unit) AvailSlowActions() (actions []Action) { } for _, t := range TilesInRange(m, u, 1) { - if t.Permanent != nil && t.Permanent.Card().Type.IsArtifact() { + // Only generate a ArtifactSwitchAction if the tiles are current + // tiles are suitable for both permanents + if t.Permanent != nil && t.Permanent.Card().Type.IsArtifact() && + t.IsSuitableForCard(u.Card()) && u.Tile().IsSuitableForCard(t.Permanent.Card()) { actions = append(actions, newArtifactSwitchAction(u, t.Permanent)) } } |
