diff --git a/res/cardsfolder/nether_void.txt b/res/cardsfolder/nether_void.txt index 803fac9a675..335c4663860 100644 --- a/res/cardsfolder/nether_void.txt +++ b/res/cardsfolder/nether_void.txt @@ -3,7 +3,7 @@ ManaCost:3 B Types:World Enchantment Text:no text T:Mode$ SpellCast | ValidCard$ Card | ValidActivatingPlayer$ Each | TriggerZones$ Battlefield | Execute$ TrigCounter | TriggerDescription$ Whenever a player casts a spell, counter it unless its controller pays 3. -SVar:TrigCounter:AB$Counter | Cost$ 0 | UnlessCost$ 3 | Defined$ TriggeredSpellAbility | UnlessPayer$ TriggeredCardController +SVar:TrigCounter:DB$Counter | Cost$ 0 | UnlessCost$ 3 | Defined$ TriggeredSpellAbility | UnlessPayer$ TriggeredCardController SVar:RemRandomDeck:True SVar:Rarity:Rare SVar:Picture:http://www.wizards.com/global/images/magic/general/nether_void.jpg diff --git a/src/forge/card/abilityFactory/AbilityFactory_CounterMagic.java b/src/forge/card/abilityFactory/AbilityFactory_CounterMagic.java index 760a6130954..1d3dffbd3b5 100644 --- a/src/forge/card/abilityFactory/AbilityFactory_CounterMagic.java +++ b/src/forge/card/abilityFactory/AbilityFactory_CounterMagic.java @@ -25,7 +25,6 @@ import forge.card.spellability.Target_Selection; // -Hand // -BottomOfLibrary // -ShuffleIntoLibrary -//UnlessCost - counter target spell unless it's controller pays this cost //PowerSink - true if the drawback type part of Power Sink should be used //ExtraActions - this has been removed. All SubAbilitys should now use the standard SubAbility system @@ -161,16 +160,20 @@ public class AbilityFactory_CounterMagic { } } - SpellAbility topSA = AllZone.Stack.peek(); - if (!CardFactoryUtil.isCounterable(topSA.getSourceCard()) || topSA.getActivatingPlayer().isComputer()) - return false; - Target tgt = sa.getTarget(); - tgt.resetTargets(); - if (Target_Selection.matchSpellAbility(sa, topSA, tgt)) - tgt.addTarget(topSA); - else - return false; + if (tgt != null) { + + SpellAbility topSA = AllZone.Stack.peek(); + if (!CardFactoryUtil.isCounterable(topSA.getSourceCard()) || topSA.getActivatingPlayer().isComputer()) + return false; + + tgt.resetTargets(); + if (Target_Selection.matchSpellAbility(sa, topSA, tgt)) + tgt.addTarget(topSA); + else + return false; + } + if (unlessCost != null){ // Is this Usable Mana Sources? Or Total Available Mana? @@ -215,43 +218,44 @@ public class AbilityFactory_CounterMagic { if(AllZone.Stack.size() < 1) { return false; } - - SpellAbility topSA = AllZone.Stack.peek(); - if (!CardFactoryUtil.isCounterable(topSA.getSourceCard()) || topSA.getActivatingPlayer().isComputer()) - return false; - + Target tgt = sa.getTarget(); - tgt.resetTargets(); - if (Target_Selection.matchSpellAbility(sa, topSA, tgt)) - tgt.addTarget(topSA); - - else - return false; - - Card source = sa.getSourceCard(); - if (unlessCost != null){ - // Is this Usable Mana Sources? Or Total Available Mana? - int usableManaSources = CardFactoryUtil.getUsableManaSources(AllZone.HumanPlayer); - int toPay = 0; - boolean setPayX = false; - if (unlessCost.equals("X") && source.getSVar(unlessCost).equals("Count$xPaid")){ - setPayX = true; - toPay = ComputerUtil.determineLeftoverMana(sa); - } - else - toPay = AbilityFactory.calculateAmount(source, unlessCost, sa); - - if (toPay == 0) + if (tgt != null) { + SpellAbility topSA = AllZone.Stack.peek(); + if (!CardFactoryUtil.isCounterable(topSA.getSourceCard()) || topSA.getActivatingPlayer().isComputer()) return false; - - if (toPay <= usableManaSources){ - // If this is a reusable Resource, feel free to play it most of the time - if (!sa.getPayCosts().isReusuableResource() || MyRandom.random.nextFloat() < .4) + + tgt.resetTargets(); + if (Target_Selection.matchSpellAbility(sa, topSA, tgt)) + tgt.addTarget(topSA); + else + return false; + + Card source = sa.getSourceCard(); + if (unlessCost != null){ + // Is this Usable Mana Sources? Or Total Available Mana? + int usableManaSources = CardFactoryUtil.getUsableManaSources(AllZone.HumanPlayer); + int toPay = 0; + boolean setPayX = false; + if (unlessCost.equals("X") && source.getSVar(unlessCost).equals("Count$xPaid")){ + setPayX = true; + toPay = ComputerUtil.determineLeftoverMana(sa); + } + else + toPay = AbilityFactory.calculateAmount(source, unlessCost, sa); + + if (toPay == 0) return false; + + if (toPay <= usableManaSources){ + // If this is a reusable Resource, feel free to play it most of the time + if (!sa.getPayCosts().isReusuableResource() || MyRandom.random.nextFloat() < .4) + return false; + } + + if (setPayX) + source.setSVar("PayX", Integer.toString(toPay)); } - - if (setPayX) - source.setSVar("PayX", Integer.toString(toPay)); } // TODO: Improve AI diff --git a/src/forge/card/cardFactory/CardFactoryUtil.java b/src/forge/card/cardFactory/CardFactoryUtil.java index bedaf189584..8d9d6ffc9a5 100644 --- a/src/forge/card/cardFactory/CardFactoryUtil.java +++ b/src/forge/card/cardFactory/CardFactoryUtil.java @@ -2518,7 +2518,7 @@ public class CardFactoryUtil { // Count$TopOfLibraryCMC if(sq[0].contains("TopOfLibraryCMC")) { - CardList topcard = AllZoneUtil.getPlayerCardsInLibrary(AllZone.HumanPlayer, 1); + CardList topcard = AllZoneUtil.getPlayerCardsInLibrary(cardController, 1); return doXMath(topcard.getTotalConvertedManaCost(), m, c); }