From b37be577cf4cabd521b553fd2d2d30d843c96d6a Mon Sep 17 00:00:00 2001 From: swordshine Date: Sat, 10 May 2014 06:23:30 +0000 Subject: [PATCH] - Fixed Mana Drain and friends --- .../main/java/forge/game/ability/AbilityUtils.java | 11 ++++++++++- .../forge/game/ability/effects/CounterEffect.java | 4 ++++ .../game/ability/effects/DelayedTriggerEffect.java | 8 ++++++++ .../main/java/forge/game/card/CardFactoryUtil.java | 10 ++++++++++ forge-gui/res/cardsfolder/d/dovescape.txt | 7 ++++--- forge-gui/res/cardsfolder/d/draining_whelk.txt | 7 ++++--- forge-gui/res/cardsfolder/i/induce_paranoia.txt | 7 ++++--- forge-gui/res/cardsfolder/m/mana_drain.txt | 7 ++++--- forge-gui/res/cardsfolder/m/mystic_genesis.txt | 7 ++++--- forge-gui/res/cardsfolder/p/plasm_capture.txt | 7 ++++--- 10 files changed, 56 insertions(+), 19 deletions(-) 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 60c6cadf221..d67ee3e0a64 100644 --- a/forge-game/src/main/java/forge/game/ability/AbilityUtils.java +++ b/forge-game/src/main/java/forge/game/ability/AbilityUtils.java @@ -1399,7 +1399,16 @@ public class AbilityUtils { return sum; } - + if (sq[0].startsWith("TriggerRememberAmount")) { + final SpellAbility root = sa.getRootAbility(); + int count = 0; + for (final Object o : root.getTriggerRemembered()) { + if (o instanceof Integer) { + count += (Integer) o; + } + } + return count; + } // Count$Compare .. if (sq[0].startsWith("Compare")) { final String[] compString = sq[0].split(" "); diff --git a/forge-game/src/main/java/forge/game/ability/effects/CounterEffect.java b/forge-game/src/main/java/forge/game/ability/effects/CounterEffect.java index 8e1ef3af241..a9c86ef9517 100644 --- a/forge-game/src/main/java/forge/game/ability/effects/CounterEffect.java +++ b/forge-game/src/main/java/forge/game/ability/effects/CounterEffect.java @@ -104,6 +104,10 @@ public class CounterEffect extends SpellAbilityEffect { continue; } + if (sa.hasParam("RememberCounteredCMC")) { + sa.getHostCard().addRemembered((Integer) tgtSACard.getCMC()); + } + this.removeFromStack(tgtSA, sa, si); // Destroy Permanent may be able to be turned into a SubAbility diff --git a/forge-game/src/main/java/forge/game/ability/effects/DelayedTriggerEffect.java b/forge-game/src/main/java/forge/game/ability/effects/DelayedTriggerEffect.java index 99f4f3f981b..d1598310ef0 100644 --- a/forge-game/src/main/java/forge/game/ability/effects/DelayedTriggerEffect.java +++ b/forge-game/src/main/java/forge/game/ability/effects/DelayedTriggerEffect.java @@ -58,6 +58,14 @@ public class DelayedTriggerEffect extends SpellAbilityEffect { } } + if (sa.hasParam("RememberNumber")) { + for (final Object o : sa.getHostCard().getRemembered()) { + if (o instanceof Integer) { + delTrig.addRemembered((Integer) o); + } + } + } + if (mapParams.containsKey("Execute")) { SpellAbility overridingSA = AbilityFactory.getAbility(sa.getSVar(mapParams.get("Execute")), sa.getHostCard()); delTrig.setOverridingAbility(overridingSA); diff --git a/forge-game/src/main/java/forge/game/card/CardFactoryUtil.java b/forge-game/src/main/java/forge/game/card/CardFactoryUtil.java index ff41b72e6ca..50b8aa0b102 100644 --- a/forge-game/src/main/java/forge/game/card/CardFactoryUtil.java +++ b/forge-game/src/main/java/forge/game/card/CardFactoryUtil.java @@ -872,6 +872,16 @@ public class CardFactoryUtil { return doXMath(c.getRemembered().size(), m, c); } + if (l[0].startsWith("RememberedNumber")) { + int num = 0; + for (final Object o : c.getRemembered()) { + if (o instanceof Integer) { + num += (Integer) o; + } + } + return doXMath(num, m, c); + } + // Count$CountersAdded if (l[0].startsWith("CountersAdded")) { final String[] components = l[0].split(" ", 3); diff --git a/forge-gui/res/cardsfolder/d/dovescape.txt b/forge-gui/res/cardsfolder/d/dovescape.txt index d80e4424a99..721e9f325cc 100644 --- a/forge-gui/res/cardsfolder/d/dovescape.txt +++ b/forge-gui/res/cardsfolder/d/dovescape.txt @@ -2,8 +2,9 @@ Name:Dovescape ManaCost:3 WU WU WU Types:Enchantment T:Mode$ SpellCast | ValidCard$ Card.nonCreature | TriggerZones$ Battlefield | Execute$ TrigCounter | TriggerDescription$ Whenever a player casts a noncreature spell, counter that spell. That player puts X 1/1 white and blue Bird creature tokens with flying onto the battlefield, where X is the spell's converted mana cost. -SVar:TrigCounter:AB$ Counter | Cost$ 0 | Defined$ TriggeredSpellAbility | SubAbility$ DBToken -SVar:DBToken:DB$ Token | TokenAmount$ X | TokenName$ Bird | TokenTypes$ Creature,Bird | TokenOwner$ TriggeredActivator | TokenColors$ White,Blue | TokenPower$ 1 | TokenToughness$ 1 | TokenKeywords$ Flying | References$ X -SVar:X:TriggeredCard$CardManaCost +SVar:TrigCounter:AB$ Counter | Cost$ 0 | Defined$ TriggeredSpellAbility | RememberCounteredCMC$ True | SubAbility$ DBToken +SVar:DBToken:DB$ Token | TokenAmount$ X | TokenName$ Bird | TokenTypes$ Creature,Bird | TokenOwner$ TriggeredActivator | TokenColors$ White,Blue | TokenPower$ 1 | TokenToughness$ 1 | TokenKeywords$ Flying | References$ X | SubAbility$ DBCleanup +SVar:DBCleanup:DB$ Cleanup | ClearRemembered$ True +SVar:X:Count$RememberedNumber SVar:Picture:http://www.wizards.com/global/images/magic/general/dovescape.jpg Oracle:({W/U} can be paid with either {W} or {U}.)\nWhenever a player casts a noncreature spell, counter that spell. That player puts X 1/1 white and blue Bird creature tokens with flying onto the battlefield, where X is the spell's converted mana cost. \ No newline at end of file diff --git a/forge-gui/res/cardsfolder/d/draining_whelk.txt b/forge-gui/res/cardsfolder/d/draining_whelk.txt index 94150f0f8f5..c49f097b546 100644 --- a/forge-gui/res/cardsfolder/d/draining_whelk.txt +++ b/forge-gui/res/cardsfolder/d/draining_whelk.txt @@ -5,8 +5,9 @@ PT:1/1 K:Flash K:Flying T:Mode$ ChangesZone | ValidCard$ Card.Self | Origin$ Any | Destination$ Battlefield | Execute$ TrigCounter | TriggerDescription$ When CARDNAME enters the battlefield, counter target spell. Put X +1/+1 counters on CARDNAME, where X is that spell's converted mana cost. -SVar:TrigCounter:DB$ Counter | Cost$ 0 | TargetType$ Spell | ValidTgts$ Card | TgtPrompt$ Select target spell | SubAbility$ DBPutcounter -SVar:DBPutcounter:DB$ PutCounter | CounterType$ P1P1 | Defined$ Self | CounterNum$ X | References$ X -SVar:X:Targeted$CardManaCost +SVar:TrigCounter:DB$ Counter | Cost$ 0 | TargetType$ Spell | ValidTgts$ Card | TgtPrompt$ Select target spell | RememberCounteredCMC$ True | SubAbility$ DBPutcounter +SVar:DBPutcounter:DB$ PutCounter | CounterType$ P1P1 | Defined$ Self | CounterNum$ X | References$ X | SubAbility$ DBCleanup +SVar:DBCleanup:DB$ Cleanup | ClearRemembered$ True +SVar:X:Count$RememberedNumber SVar:Picture:http://www.wizards.com/global/images/magic/general/draining_whelk.jpg Oracle:Flash (You may cast this spell any time you could cast an instant.)\nFlying\nWhen Draining Whelk enters the battlefield, counter target spell. Put X +1/+1 counters on Draining Whelk, where X is that spell's converted mana cost. \ No newline at end of file diff --git a/forge-gui/res/cardsfolder/i/induce_paranoia.txt b/forge-gui/res/cardsfolder/i/induce_paranoia.txt index 8368f3a4887..3661ec210bb 100644 --- a/forge-gui/res/cardsfolder/i/induce_paranoia.txt +++ b/forge-gui/res/cardsfolder/i/induce_paranoia.txt @@ -1,9 +1,10 @@ Name:Induce Paranoia ManaCost:2 U U Types:Instant -A:SP$ Counter | Cost$ 2 U U | TargetType$ Spell | ValidTgts$ Card | SubAbility$ DBMill | SpellDescription$ Counter target spell. If {B} was spent to cast CARDNAME, that spell's controller puts the top X cards of his or her library into his or her graveyard, where X is the spell's converted mana cost. -SVar:DBMill:DB$ Mill | NumCards$ X | Defined$ TargetedController | ConditionManaSpent$ B | References$ X -SVar:X:Targeted$CardManaCost +A:SP$ Counter | Cost$ 2 U U | TargetType$ Spell | ValidTgts$ Card | RememberCounteredCMC$ True | SubAbility$ DBMill | SpellDescription$ Counter target spell. If {B} was spent to cast CARDNAME, that spell's controller puts the top X cards of his or her library into his or her graveyard, where X is the spell's converted mana cost. +SVar:DBMill:DB$ Mill | NumCards$ X | Defined$ TargetedController | ConditionManaSpent$ B | References$ X | SubAbility$ DBCleanup +SVar:DBCleanup:DB$ Cleanup | ClearRemembered$ True +SVar:X:Count$RememberedNumber SVar:ManaNeededToAvoidNegativeEffect:black SVar:RemRandomDeck:True DeckNeeds:Color$Black diff --git a/forge-gui/res/cardsfolder/m/mana_drain.txt b/forge-gui/res/cardsfolder/m/mana_drain.txt index eaa463f6868..09a6b8ce695 100644 --- a/forge-gui/res/cardsfolder/m/mana_drain.txt +++ b/forge-gui/res/cardsfolder/m/mana_drain.txt @@ -1,9 +1,10 @@ Name:Mana Drain ManaCost:U U Types:Instant -A:SP$Counter | Cost$ U U | TargetType$ Spell | RememberCountered$ True | ForgetOtherTargets$ True | ValidTgts$ Card | SubAbility$ DBDelTrig | SpellDescription$ Counter target spell. At the beginning of your next main phase, add {X} to your mana pool, where X is that spell's converted mana cost. -SVar:DBDelTrig:DB$ DelayedTrigger | Mode$ Phase | Phase$ Main1,Main2 | ValidPlayer$ You | Execute$ AddMana | TriggerDescription$ CARDNAME - At the beginning of your next main phase, add X to your mana pool, where X is the countered spell's converted mana cost. +A:SP$ Counter | Cost$ U U | TargetType$ Spell | RememberCounteredCMC$ True | ValidTgts$ Card | SubAbility$ DBDelTrig | SpellDescription$ Counter target spell. At the beginning of your next main phase, add {X} to your mana pool, where X is that spell's converted mana cost. +SVar:DBDelTrig:DB$ DelayedTrigger | Mode$ Phase | Phase$ Main1,Main2 | ValidPlayer$ You | Execute$ AddMana | TriggerDescription$ At the beginning of your next main phase, add X to your mana pool, where X is the countered spell's converted mana cost. | RememberNumber$ True | SubAbility$ DBCleanup +SVar:DBCleanup:DB$ Cleanup | ClearRemembered$ True SVar:AddMana:DB$ Mana | Cost$ 0 | Produced$ 1 | Amount$ X | References$ X -SVar:X:Remembered$CardManaCost +SVar:X:Count$TriggerRememberAmount SVar:Picture:http://www.wizards.com/global/images/magic/general/mana_drain.jpg Oracle:Counter target spell. At the beginning of your next main phase, add {X} to your mana pool, where X is that spell's converted mana cost. \ No newline at end of file diff --git a/forge-gui/res/cardsfolder/m/mystic_genesis.txt b/forge-gui/res/cardsfolder/m/mystic_genesis.txt index c66aa57eb5c..9d3b88bd29e 100644 --- a/forge-gui/res/cardsfolder/m/mystic_genesis.txt +++ b/forge-gui/res/cardsfolder/m/mystic_genesis.txt @@ -1,8 +1,9 @@ Name:Mystic Genesis ManaCost:2 G U U Types:Instant -A:SP$ Counter | Cost$ 2 G U U | TargetType$ Spell | RememberCountered$ True | ForgetOtherTargets$ True | ValidTgts$ Card | SubAbility$ DBToken | SpellDescription$ Counter target spell. Put an X/X green Ooze creature token onto the battlefield, where X is that spell's converted mana cost. -SVar:DBToken:DB$ Token | TokenAmount$ 1 | TokenName$ Ooze | TokenTypes$ Creature,Ooze | TokenOwner$ You | TokenColors$ Green | TokenPower$ X | TokenToughness$ X | References$ X -SVar:X:Remembered$CardManaCost +A:SP$ Counter | Cost$ 2 G U U | TargetType$ Spell | RememberCounteredCMC$ True | ValidTgts$ Card | SubAbility$ DBToken | SpellDescription$ Counter target spell. Put an X/X green Ooze creature token onto the battlefield, where X is that spell's converted mana cost. +SVar:DBToken:DB$ Token | TokenAmount$ 1 | TokenName$ Ooze | TokenTypes$ Creature,Ooze | TokenOwner$ You | TokenColors$ Green | TokenPower$ X | TokenToughness$ X | References$ X | SubAbility$ DBCleanup +SVar:DBCleanup:DB$ Cleanup | ClearRemembered$ True +SVar:X:Count$RememberedNumber SVar:Picture:http://www.wizards.com/global/images/magic/general/mystic_genesis.jpg Oracle:Counter target spell. Put an X/X green Ooze creature token onto the battlefield, where X is that spell's converted mana cost. \ No newline at end of file diff --git a/forge-gui/res/cardsfolder/p/plasm_capture.txt b/forge-gui/res/cardsfolder/p/plasm_capture.txt index b32d67b3e8d..7d7f022652d 100644 --- a/forge-gui/res/cardsfolder/p/plasm_capture.txt +++ b/forge-gui/res/cardsfolder/p/plasm_capture.txt @@ -1,9 +1,10 @@ Name:Plasm Capture ManaCost:G G U U Types:Instant -A:SP$ Counter | Cost$ G G U U | TargetType$ Spell | RememberCountered$ True | ForgetOtherTargets$ True | ValidTgts$ Card | SubAbility$ DBDelTrig | SpellDescription$ Counter target spell. At the beginning of your next precombat main phase, add X mana in any combination of colors to your mana pool, where X is that spell's converted mana cost. -SVar:DBDelTrig:DB$ DelayedTrigger | Mode$ Phase | Phase$ Main1 | ValidPlayer$ You | Execute$ AddMana | TriggerDescription$ CARDNAME - At the beginning of your next precombat main phase, aadd X mana in any combination of colors to your mana pool, where X is that spell's converted mana cost. +A:SP$ Counter | Cost$ G G U U | TargetType$ Spell | RememberCounteredCMC$ True | ValidTgts$ Card | SubAbility$ DBDelTrig | SpellDescription$ Counter target spell. At the beginning of your next precombat main phase, add X mana in any combination of colors to your mana pool, where X is that spell's converted mana cost. +SVar:DBDelTrig:DB$ DelayedTrigger | Mode$ Phase | Phase$ Main1 | ValidPlayer$ You | Execute$ AddMana | TriggerDescription$ CARDNAME - At the beginning of your next precombat main phase, aadd X mana in any combination of colors to your mana pool, where X is that spell's converted mana cost. | RememberNumber$ True | SubAbility$ DBCleanup +SVar:DBCleanup:DB$ Cleanup | ClearRemembered$ True SVar:AddMana:DB$ Mana | Cost$ 0 | Produced$ Combo Any | Amount$ X | References$ X | AILogic$ MostProminentInComputerHand -SVar:X:Remembered$CardManaCost +SVar:X:Count$TriggerRememberAmount SVar:Picture:http://www.wizards.com/global/images/magic/general/plasm_capture.jpg Oracle:Counter target spell. At the beginning of your next precombat main phase, add X mana in any combination of colors to your mana pool, where X is that spell's converted mana cost. \ No newline at end of file