From 3fb07c5ead3e7673bddf4ee4756c3d81f4e9da99 Mon Sep 17 00:00:00 2001 From: Hans Mackowiak Date: Sat, 11 Jan 2025 15:18:17 +0100 Subject: [PATCH] Move Altar of the Pantheon to its own static (#6760) --- .../src/main/java/forge/game/GameAction.java | 3 ++ .../java/forge/game/ability/AbilityUtils.java | 2 +- .../main/java/forge/game/player/Player.java | 13 +++++++++ .../staticability/StaticAbilityDevotion.java | 29 +++++++++++++++++++ .../cardsfolder/a/altar_of_the_pantheon.txt | 2 +- 5 files changed, 47 insertions(+), 2 deletions(-) create mode 100644 forge-game/src/main/java/forge/game/staticability/StaticAbilityDevotion.java diff --git a/forge-game/src/main/java/forge/game/GameAction.java b/forge-game/src/main/java/forge/game/GameAction.java index 3f60a427a6a..831e67c85b8 100644 --- a/forge-game/src/main/java/forge/game/GameAction.java +++ b/forge-game/src/main/java/forge/game/GameAction.java @@ -1159,6 +1159,9 @@ public boolean visit(final Card c) { } } staticAbilities.addAll(toAdd); + for (Player p : game.getPlayers()) { + p.afterStaticAbilityLayer(layer); + } } for (final CardCollectionView affected : affectedPerAbility.values()) { diff --git a/forge-game/src/main/java/forge/game/ability/AbilityUtils.java b/forge-game/src/main/java/forge/game/ability/AbilityUtils.java index aa934c4f481..96501829c8a 100644 --- a/forge-game/src/main/java/forge/game/ability/AbilityUtils.java +++ b/forge-game/src/main/java/forge/game/ability/AbilityUtils.java @@ -1938,8 +1938,8 @@ public static int xCount(Card c, final String s, final CardTraitBase ctb) { colorOccurrences++; } } - colorOccurrences += c0.getAmountOfKeyword("Your devotion to each color and each combination of colors is increased by one."); } + colorOccurrences += player.getDevotionMod(); return doXMath(colorOccurrences, expr, c, ctb); } } // end ctb != null diff --git a/forge-game/src/main/java/forge/game/player/Player.java b/forge-game/src/main/java/forge/game/player/Player.java index fa2b07c533f..07da018e783 100644 --- a/forge-game/src/main/java/forge/game/player/Player.java +++ b/forge-game/src/main/java/forge/game/player/Player.java @@ -114,6 +114,7 @@ public class Player extends GameEntity implements Comparable { private int venturedThisTurn; private int descended; private int numRingTemptedYou; + private int devotionMod; private boolean revolt = false; private Card ringBearer, theRing; @@ -4017,4 +4018,16 @@ public List getUnlockedDoors() { .flatMap(Collection::stream) .collect(Collectors.toList()); } + + public int getDevotionMod() { + return devotionMod; + } + + public void afterStaticAbilityLayer(StaticAbilityLayer layer) { + if (layer != StaticAbilityLayer.TEXT) { + return; + } + + devotionMod = StaticAbilityDevotion.getDevotionMod(this); + } } diff --git a/forge-game/src/main/java/forge/game/staticability/StaticAbilityDevotion.java b/forge-game/src/main/java/forge/game/staticability/StaticAbilityDevotion.java new file mode 100644 index 00000000000..60369c4c55d --- /dev/null +++ b/forge-game/src/main/java/forge/game/staticability/StaticAbilityDevotion.java @@ -0,0 +1,29 @@ +package forge.game.staticability; + +import forge.game.Game; +import forge.game.card.Card; +import forge.game.player.Player; +import forge.game.zone.ZoneType; + +public class StaticAbilityDevotion { + + static String MODE = "Devotion"; + + public static int getDevotionMod(final Player player) { + int i = 0; + final Game game = player.getGame(); + for (final Card ca : game.getCardsIn(ZoneType.STATIC_ABILITIES_SOURCE_ZONES)) { + for (final StaticAbility stAb : ca.getStaticAbilities()) { + if (!stAb.checkConditions(MODE)) { + continue; + } + if (!stAb.matchesValidParam("ValidPlayer", player)) { + continue; + } + int t = Integer.parseInt(stAb.getParamOrDefault("Value", "1")); + i = i + t; + } + } + return i; + } +} diff --git a/forge-gui/res/cardsfolder/a/altar_of_the_pantheon.txt b/forge-gui/res/cardsfolder/a/altar_of_the_pantheon.txt index 58d28da7f04..5e90f70adce 100644 --- a/forge-gui/res/cardsfolder/a/altar_of_the_pantheon.txt +++ b/forge-gui/res/cardsfolder/a/altar_of_the_pantheon.txt @@ -1,7 +1,7 @@ Name:Altar of the Pantheon ManaCost:3 Types:Artifact -K:Your devotion to each color and each combination of colors is increased by one. +S:Mode$ Devotion | ValidPlayer$ You | Description$ Your devotion to each color and each combination of colors is increased by one. A:AB$ Mana | Cost$ T | Produced$ Any | SubAbility$ DBGainLife | SpellDescription$ Add one mana of any color. If you control a God, a Demigod, or a legendary enchantment, you gain 1 life. SVar:DBGainLife:DB$ GainLife | LifeAmount$ 1 | ConditionPresent$ God.YouCtrl,Demigod.YouCtrl,Enchantment.YouCtrl+Legendary DeckHas:Ability$LifeGain