aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFlorian Fischer <florian.fischer@muhq.space>2024-12-26 09:21:51 +0100
committerFlorian Fischer <florian.fischer@muhq.space>2025-01-27 16:43:56 +0100
commitf07763982ff09e49876b810c3d1952d9f0cfedd0 (patch)
tree254651351a80f5b819f8476a59f2f37febb90053
parent46819d5eb7ce7dd174db9eba254eed583adbf01a (diff)
downloadmuhqs-game-f07763982ff09e49876b810c3d1952d9f0cfedd0.tar.gz
muhqs-game-f07763982ff09e49876b810c3d1952d9f0cfedd0.zip
fix available unit actions
-rw-r--r--go/game/card.go2
-rw-r--r--go/game/unit.go36
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))
+ }
+ }
}
}
}