diff options
| author | Florian Fischer <florian.fischer@muhq.space> | 2024-12-26 09:21:51 +0100 |
|---|---|---|
| committer | Florian Fischer <florian.fischer@muhq.space> | 2025-08-20 15:57:11 +0200 |
| commit | e2ab17c14f1a9a448e241eb65ad0590317fe2623 (patch) | |
| tree | 0365d47119fa114da787a102c8047cc748d3375c /go | |
| parent | f3dce6f8edb37284d46de2c396396d35cd61c137 (diff) | |
| download | muhqs-game-e2ab17c14f1a9a448e241eb65ad0590317fe2623.tar.gz muhqs-game-e2ab17c14f1a9a448e241eb65ad0590317fe2623.zip | |
fix available unit actions
Diffstat (limited to 'go')
| -rw-r--r-- | go/game/card.go | 2 | ||||
| -rw-r--r-- | go/game/unit.go | 36 |
2 files changed, 22 insertions, 16 deletions
diff --git a/go/game/card.go b/go/game/card.go index 4f01eb4c..be198d5a 100644 --- a/go/game/card.go +++ b/go/game/card.go @@ -238,7 +238,7 @@ func (card *Card) parseDefinition(definition []byte) { if pcFound { card.PlayCosts = ParseCardResourceCosts(pc, card.getEffects()) } else if card.Type == CardTypes.Unit { - card.PlayCosts = ParseCardResourceCosts(card.Values["upkeep"], card.getEffects()) + card.PlayCosts = ParseCardResourceCosts(card.Values["upkeep"], card.getEffects()) } card.Impl = getCardImplementation(card) diff --git a/go/game/unit.go b/go/game/unit.go index 9f823a0d..b71596d4 100644 --- a/go/game/unit.go +++ b/go/game/unit.go @@ -170,35 +170,41 @@ func (u *Unit) AvailSlowActions() (actions []Action) { for _, p := range u.FullActions { actions = append(actions, p) } - - for _, t := range TilesInRange(m, u, 1) { - // 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)) - } - } } if u.AvailAttackActions > 0 || u.AvailMoveActions > 0 { - for _, tile := range TilesInRange(m, u, 1) { - if tile.Permanent == nil { + for _, t := range TilesInRange(m, u, 1) { + if t.Permanent == nil { continue } - if equipment, ok := tile.Permanent.(*Equipment); ok { + // Equipment Actions + if equipment, ok := t.Permanent.(*Equipment); ok { actions = append(actions, NewEquipAction(u, equipment)) } - for _, perm := range tile.Permanent.Pile() { + for _, perm := range t.Permanent.Pile() { if equipment, ok := perm.(*Equipment); ok { actions = append(actions, NewEquipAction(u, equipment)) } } - if tile.Permanent.Card().Type.IsArtifact() { - actions = append(actions, newArtifactMoveAction(u, tile.Permanent)) + // Artifact Actions + if t.Permanent.Card().Type.IsArtifact() { + // ArtifactMoveActions are FullActions + if u.AvailAttackActions > 0 && u.AvailMoveActions > 0 { + actions = append(actions, newArtifactMoveAction(u, t.Permanent)) + } + + // ArtifactSwitchActions replace the MoveAction + if u.AvailMoveActions > 0 { + // Only generate an ArtifactSwitchAction if the 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)) + } + } } } } |
