From d3d41d7c1fb729e67d8e65cf6308aa301f44a6bb Mon Sep 17 00:00:00 2001 From: swordshine Date: Fri, 6 Sep 2019 12:34:53 +0800 Subject: [PATCH 1/5] Add Adamant cards --- .../src/main/java/forge/game/CardTraitBase.java | 13 +++++++++++++ .../res/cardsfolder/upcoming/embereth_paladin.txt | 7 +++++++ 2 files changed, 20 insertions(+) create mode 100644 forge-gui/res/cardsfolder/upcoming/embereth_paladin.txt diff --git a/forge-game/src/main/java/forge/game/CardTraitBase.java b/forge-game/src/main/java/forge/game/CardTraitBase.java index 7897017b187..a56db98f6f9 100644 --- a/forge-game/src/main/java/forge/game/CardTraitBase.java +++ b/forge-game/src/main/java/forge/game/CardTraitBase.java @@ -1,5 +1,6 @@ package forge.game; +import forge.card.MagicColor; import forge.card.mana.ManaAtom; import forge.game.ability.AbilityUtils; import forge.game.card.Card; @@ -16,6 +17,8 @@ import forge.util.Expressions; import java.util.*; +import org.apache.commons.lang3.StringUtils; + import com.google.common.collect.ImmutableList; import com.google.common.collect.Maps; @@ -250,6 +253,16 @@ public abstract class CardTraitBase extends GameObject implements IHasCardView { if (params.containsKey("Blessing")) { if ("True".equalsIgnoreCase(params.get("Blessing")) != hostController.hasBlessing()) return false; } + + if (params.containsKey("Adamant")) { + if (hostCard.getCastSA() == null) { + return false; + } + final String payingMana = StringUtils.join(hostCard.getCastSA().getPayingMana()); + if (StringUtils.countMatches(payingMana, MagicColor.toShortString(params.get("Adamant"))) < 3) { + return false; + } + } if (params.containsKey("Presence")) { if (hostCard.getCastFrom() == null || hostCard.getCastSA() == null) diff --git a/forge-gui/res/cardsfolder/upcoming/embereth_paladin.txt b/forge-gui/res/cardsfolder/upcoming/embereth_paladin.txt new file mode 100644 index 00000000000..456f35744c0 --- /dev/null +++ b/forge-gui/res/cardsfolder/upcoming/embereth_paladin.txt @@ -0,0 +1,7 @@ +Name:Embereth Paladin +ManaCost:3 R +Types:Creature Human Knight +PT:4/1 +K:Haste +K:etbCounter:P1P1:1:Adamant$ Red:Adamant — If at least three red mana was spent to cast this spell, CARDNAME enters the battlefield with a +1/+1 counter on it. +Oracle:Haste\nAdamant — If at least three red mana was spent to cast this spell, Embereth Paladin enters the battlefield with a +1/+1 counter on it. From 0f9ed8638b53baf5dfd0b953640be115bb133461 Mon Sep 17 00:00:00 2001 From: swordshine Date: Fri, 6 Sep 2019 13:24:14 +0800 Subject: [PATCH 2/5] Add Silverflame Ritual --- .../game/spellability/SpellAbilityCondition.java | 13 +++++++++++++ .../game/spellability/SpellAbilityVariables.java | 16 ++++++++++++++++ .../cardsfolder/upcoming/silverflame_ritual.txt | 6 ++++++ 3 files changed, 35 insertions(+) create mode 100644 forge-gui/res/cardsfolder/upcoming/silverflame_ritual.txt diff --git a/forge-game/src/main/java/forge/game/spellability/SpellAbilityCondition.java b/forge-game/src/main/java/forge/game/spellability/SpellAbilityCondition.java index c53c34bd3ce..aa0b7797540 100644 --- a/forge-game/src/main/java/forge/game/spellability/SpellAbilityCondition.java +++ b/forge-game/src/main/java/forge/game/spellability/SpellAbilityCondition.java @@ -155,6 +155,10 @@ public class SpellAbilityCondition extends SpellAbilityVariables { this.setPresenceCondition(params.get("Presence")); } + if (params.containsKey("ConditionAdamant")) { + this.setAdamantCondition(params.get("ConditionAdamant")); + } + // Condition version of IsPresent stuff if (params.containsKey("ConditionPresent")) { this.setIsPresent(params.get("ConditionPresent")); @@ -264,6 +268,15 @@ public class SpellAbilityCondition extends SpellAbilityVariables { } } + if (!this.getAdamantCondition().isEmpty()) { + if (host.getCastSA() == null) return false; + final String color = this.getAdamantCondition(); + final String payingMana = StringUtils.join(host.getCastSA().getPayingMana()); + if (StringUtils.countMatches(payingMana, MagicColor.toShortString(color)) < 3) { + return false; + } + } + if (this.isAllTargetsLegal()) { for (Card c : sa.getTargets().getTargetCards()) { if (!CardFactoryUtil.isTargetStillValid(sa, c)) { diff --git a/forge-game/src/main/java/forge/game/spellability/SpellAbilityVariables.java b/forge-game/src/main/java/forge/game/spellability/SpellAbilityVariables.java index 7f8c32e6f74..2378c584822 100644 --- a/forge-game/src/main/java/forge/game/spellability/SpellAbilityVariables.java +++ b/forge-game/src/main/java/forge/game/spellability/SpellAbilityVariables.java @@ -89,6 +89,7 @@ public class SpellAbilityVariables implements Cloneable { this.targetValidTargeting = sav.getTargetValidTargeting(); this.targetsSingleTarget = sav.targetsSingleTarget(); this.presenceCondition = sav.getPresenceCondition(); + this.adamantCondition = sav.getAdamantCondition(); } // default values for Sorcery speed abilities @@ -200,6 +201,8 @@ public class SpellAbilityVariables implements Cloneable { /** The Presence keyword value containing the relevant condition */ private String presenceCondition = ""; + /** The Adamant keyword value containing the relevant condition */ + private String adamantCondition = ""; /** *

* Setter for the field manaSpent. @@ -943,4 +946,17 @@ public class SpellAbilityVariables implements Cloneable { public void setPresenceCondition(String s) { this.presenceCondition = s; } + /** + * @return the condition from the Adamant keyword, empty if keyword is absent + */ + public String getAdamantCondition() { + return this.adamantCondition; + } + + /** + * @param s the condition from the Adamant keyword + */ + public void setAdamantCondition(String s) { + this.adamantCondition = s; + } } // end class SpellAbilityVariables diff --git a/forge-gui/res/cardsfolder/upcoming/silverflame_ritual.txt b/forge-gui/res/cardsfolder/upcoming/silverflame_ritual.txt new file mode 100644 index 00000000000..e9504a07e7e --- /dev/null +++ b/forge-gui/res/cardsfolder/upcoming/silverflame_ritual.txt @@ -0,0 +1,6 @@ +Name:Silverflame Ritual +ManaCost:3 W +Types:Sorcery +A:SP$ PutCounterAll | Cost$ 3 W | ValidCards$ Creature.YouCtrl | CounterType$ P1P1 | CounterNum$ 1 | SubAbility$ DBPumpAll | SpellDescription$ Put a +1/+1 counter on each creature you control. Adamant — If at least three white mana was spent to cast this spell, creatures you control gain vigilance until end of turn. +SVar:DBPumpAll:DB$ PumpAll | ValidCards$ Creature.YouCtrl | KW$ Vigilance | ConditionAdamant$ White +Oracle:Put a +1/+1 counter on each creature you control.\nAdamant — If at least three white mana was spent to cast this spell, creatures you control gain vigilance until end of turn. From 56d0982fb150e5975c58247feb71a4833d3754bb Mon Sep 17 00:00:00 2001 From: swordshine Date: Fri, 6 Sep 2019 13:36:18 +0800 Subject: [PATCH 3/5] Add Slaying Fire --- .../src/main/java/forge/game/ability/AbilityUtils.java | 7 +++++++ forge-gui/res/cardsfolder/upcoming/slaying_fire.txt | 6 ++++++ 2 files changed, 13 insertions(+) create mode 100644 forge-gui/res/cardsfolder/upcoming/slaying_fire.txt 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 399515f6755..bf32df071ef 100644 --- a/forge-game/src/main/java/forge/game/ability/AbilityUtils.java +++ b/forge-game/src/main/java/forge/game/ability/AbilityUtils.java @@ -1623,6 +1623,13 @@ public class AbilityUtils { return count; } + // Count$Adamant... + if (sq[0].startsWith("Adamant")) { + final String payingMana = StringUtils.join(sa.getRootAbility().getPayingMana()); + final boolean adamant = StringUtils.countMatches(payingMana, MagicColor.toShortString(sq[1])) >= 3; + return CardFactoryUtil.doXMath(Integer.parseInt(sq[adamant ? 2 : 3]), expr, c); + } + if (l[0].startsWith("LastStateBattlefield")) { final String[] k = l[0].split(" "); CardCollectionView list = null; diff --git a/forge-gui/res/cardsfolder/upcoming/slaying_fire.txt b/forge-gui/res/cardsfolder/upcoming/slaying_fire.txt new file mode 100644 index 00000000000..8476797dfaa --- /dev/null +++ b/forge-gui/res/cardsfolder/upcoming/slaying_fire.txt @@ -0,0 +1,6 @@ +Name:Slaying Fire +ManaCost:2 R +Types:Instant +A:SP$ DealDamage | Cost$ 2 R | ValidTgts$ Creature,Player,Planeswalker | TgtPrompt$ Select any target | NumDmg$ X | References$ X | SpellDescription$ CARDNAME deals 3 damage to any target. Adamant — If at least three red mana was spent to cast this spell, it deals 4 damage instead. +SVar:X:Count$Adamant.Red.4.3 +Oracle:Slaying Fire deals 3 damage to any target.\nAdamant — If at least three red mana was spent to cast this spell, it deals 4 damage instead. From b4a7a9a3ca4e1069fc14ea9ef62a6b7aa3780acd Mon Sep 17 00:00:00 2001 From: swordshine Date: Fri, 6 Sep 2019 20:04:07 +0800 Subject: [PATCH 4/5] Changed the template of Embereth Paladin --- forge-gui/res/cardsfolder/upcoming/embereth_paladin.txt | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/forge-gui/res/cardsfolder/upcoming/embereth_paladin.txt b/forge-gui/res/cardsfolder/upcoming/embereth_paladin.txt index 456f35744c0..b76ada65fcd 100644 --- a/forge-gui/res/cardsfolder/upcoming/embereth_paladin.txt +++ b/forge-gui/res/cardsfolder/upcoming/embereth_paladin.txt @@ -3,5 +3,7 @@ ManaCost:3 R Types:Creature Human Knight PT:4/1 K:Haste -K:etbCounter:P1P1:1:Adamant$ Red:Adamant — If at least three red mana was spent to cast this spell, CARDNAME enters the battlefield with a +1/+1 counter on it. +R:Event$ Moved | ValidCard$ Card.Self | Destination$ Battlefield | Adamant$ Red | ReplaceWith$ ETBAddCounter | Description$ Adamant — If at least three red mana was spent to cast this spell, CARDNAME enters the battlefield with a +1/+1 counter on it. +SVar:ETBAddCounter:DB$ PutCounter | ETB$ True | Defined$ Self | CounterType$ P1P1 | CounterNum$ 1 | SubAbility$ MoveToPlay +SVar:MoveToPlay:DB$ ChangeZone | Hidden$ True | Origin$ All | Destination$ Battlefield | Defined$ ReplacedCard Oracle:Haste\nAdamant — If at least three red mana was spent to cast this spell, Embereth Paladin enters the battlefield with a +1/+1 counter on it. From e8e115ae1acecacd9e79d23b183dd9f472728e18 Mon Sep 17 00:00:00 2001 From: swordshine Date: Fri, 6 Sep 2019 20:51:55 +0800 Subject: [PATCH 5/5] Use a simple template for Silverflame Ritual --- .../game/spellability/SpellAbilityCondition.java | 13 ------------- .../game/spellability/SpellAbilityVariables.java | 16 ---------------- .../cardsfolder/upcoming/silverflame_ritual.txt | 3 ++- 3 files changed, 2 insertions(+), 30 deletions(-) diff --git a/forge-game/src/main/java/forge/game/spellability/SpellAbilityCondition.java b/forge-game/src/main/java/forge/game/spellability/SpellAbilityCondition.java index aa0b7797540..c53c34bd3ce 100644 --- a/forge-game/src/main/java/forge/game/spellability/SpellAbilityCondition.java +++ b/forge-game/src/main/java/forge/game/spellability/SpellAbilityCondition.java @@ -155,10 +155,6 @@ public class SpellAbilityCondition extends SpellAbilityVariables { this.setPresenceCondition(params.get("Presence")); } - if (params.containsKey("ConditionAdamant")) { - this.setAdamantCondition(params.get("ConditionAdamant")); - } - // Condition version of IsPresent stuff if (params.containsKey("ConditionPresent")) { this.setIsPresent(params.get("ConditionPresent")); @@ -268,15 +264,6 @@ public class SpellAbilityCondition extends SpellAbilityVariables { } } - if (!this.getAdamantCondition().isEmpty()) { - if (host.getCastSA() == null) return false; - final String color = this.getAdamantCondition(); - final String payingMana = StringUtils.join(host.getCastSA().getPayingMana()); - if (StringUtils.countMatches(payingMana, MagicColor.toShortString(color)) < 3) { - return false; - } - } - if (this.isAllTargetsLegal()) { for (Card c : sa.getTargets().getTargetCards()) { if (!CardFactoryUtil.isTargetStillValid(sa, c)) { diff --git a/forge-game/src/main/java/forge/game/spellability/SpellAbilityVariables.java b/forge-game/src/main/java/forge/game/spellability/SpellAbilityVariables.java index 2378c584822..7f8c32e6f74 100644 --- a/forge-game/src/main/java/forge/game/spellability/SpellAbilityVariables.java +++ b/forge-game/src/main/java/forge/game/spellability/SpellAbilityVariables.java @@ -89,7 +89,6 @@ public class SpellAbilityVariables implements Cloneable { this.targetValidTargeting = sav.getTargetValidTargeting(); this.targetsSingleTarget = sav.targetsSingleTarget(); this.presenceCondition = sav.getPresenceCondition(); - this.adamantCondition = sav.getAdamantCondition(); } // default values for Sorcery speed abilities @@ -201,8 +200,6 @@ public class SpellAbilityVariables implements Cloneable { /** The Presence keyword value containing the relevant condition */ private String presenceCondition = ""; - /** The Adamant keyword value containing the relevant condition */ - private String adamantCondition = ""; /** *

* Setter for the field manaSpent. @@ -946,17 +943,4 @@ public class SpellAbilityVariables implements Cloneable { public void setPresenceCondition(String s) { this.presenceCondition = s; } - /** - * @return the condition from the Adamant keyword, empty if keyword is absent - */ - public String getAdamantCondition() { - return this.adamantCondition; - } - - /** - * @param s the condition from the Adamant keyword - */ - public void setAdamantCondition(String s) { - this.adamantCondition = s; - } } // end class SpellAbilityVariables diff --git a/forge-gui/res/cardsfolder/upcoming/silverflame_ritual.txt b/forge-gui/res/cardsfolder/upcoming/silverflame_ritual.txt index e9504a07e7e..7692b568a9b 100644 --- a/forge-gui/res/cardsfolder/upcoming/silverflame_ritual.txt +++ b/forge-gui/res/cardsfolder/upcoming/silverflame_ritual.txt @@ -2,5 +2,6 @@ Name:Silverflame Ritual ManaCost:3 W Types:Sorcery A:SP$ PutCounterAll | Cost$ 3 W | ValidCards$ Creature.YouCtrl | CounterType$ P1P1 | CounterNum$ 1 | SubAbility$ DBPumpAll | SpellDescription$ Put a +1/+1 counter on each creature you control. Adamant — If at least three white mana was spent to cast this spell, creatures you control gain vigilance until end of turn. -SVar:DBPumpAll:DB$ PumpAll | ValidCards$ Creature.YouCtrl | KW$ Vigilance | ConditionAdamant$ White +SVar:DBPumpAll:DB$ PumpAll | ValidCards$ Creature.YouCtrl | KW$ Vigilance | ConditionCheckSVar$ X | References$ X +SVar:X:Count$Adamant.White.1.0 Oracle:Put a +1/+1 counter on each creature you control.\nAdamant — If at least three white mana was spent to cast this spell, creatures you control gain vigilance until end of turn.