From f07763982ff09e49876b810c3d1952d9f0cfedd0 Mon Sep 17 00:00:00 2001 From: Florian Fischer Date: Thu, 26 Dec 2024 09:21:51 +0100 Subject: fix available unit actions --- go/game/card.go | 2 +- 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)) + } + } } } } -- cgit v1.2.3