From 2511bda8bcd6e538f08325fd0118fe5c35a65d4d Mon Sep 17 00:00:00 2001 From: Maxmtg Date: Mon, 8 Apr 2013 07:38:49 +0000 Subject: [PATCH] Removed 'YChoice' from game. - Tetravus may use the same variable X (it's cleared after resolve) no other cards used it Fixed NPE in announce code for costs that do announce but have no manacost (ab of simic manipulator) --- res/cardsfolder/s/simic_manipulator.txt | 2 +- res/cardsfolder/t/tetravus.txt | 4 +-- src/main/java/forge/Card.java | 2 +- .../java/forge/card/ability/AbilityUtils.java | 2 +- .../card/ability/effects/CleanUpEffect.java | 3 --- src/main/java/forge/card/cost/CostExile.java | 4 +-- .../forge/card/cost/CostRemoveCounter.java | 22 ++++++++------- src/main/java/forge/card/cost/CostUtil.java | 27 ------------------- .../spellability/HumanPlaySpellAbility.java | 5 +++- src/main/java/forge/game/zone/MagicStack.java | 1 - 10 files changed, 21 insertions(+), 51 deletions(-) diff --git a/res/cardsfolder/s/simic_manipulator.txt b/res/cardsfolder/s/simic_manipulator.txt index 4d0ff409550..48d5dbe62df 100644 --- a/res/cardsfolder/s/simic_manipulator.txt +++ b/res/cardsfolder/s/simic_manipulator.txt @@ -3,7 +3,7 @@ ManaCost:1 U U Types:Creature Merfolk PT:0/1 K:Evolve -A:AB$ GainControl | Announce$ X | Cost$ XCantBe0 T SubCounter | ValidTgts$ Creature.powerLEX | TgtPrompt$ Select target with power less than or equal to the number of +1/+1 counters removed this way | SpellDescription$ Gain control of target creature with power less than or equal to the number of +1/+1 counters removed this way. +A:AB$ GainControl | Announce$ X | Cost$ XCantBe0 T SubCounter | ValidTgts$ Creature.powerLEX | TgtPrompt$ Select target with power less than or equal to the number of +1/+1 counters removed this way | SpellDescription$ Gain control of target creature with power less than or equal to the number of +1/+1 counters removed this way. SVar:X:Count$xPaid SVar:RemAIDeck:True SVar:Picture:http://www.wizards.com/global/images/magic/general/simic_manipulator.jpg diff --git a/res/cardsfolder/t/tetravus.txt b/res/cardsfolder/t/tetravus.txt index 09ad54a406b..2a05b038902 100644 --- a/res/cardsfolder/t/tetravus.txt +++ b/res/cardsfolder/t/tetravus.txt @@ -9,9 +9,7 @@ SVar:TrigToken:AB$Token | Cost$ SubCounter | References$ X | TokenAmount SVar:DBClearXChoice:DB$ Cleanup | ClearChosenX$ True SVar:X:XChoice T:Mode$ Phase | Phase$ Upkeep | ValidPlayer$ You | TriggerZones$ Battlefield | Execute$ TrigPutCounters | TriggerDescription$ At the beginning of your upkeep, you may exile any number of tokens put onto the battlefield with CARDNAME. If you do, put that many +1/+1 counters on CARDNAME. -SVar:TrigPutCounters:AB$PutCounter | Cost$ Exile | References$ Y | Defined$ Self | CounterType$ P1P1 | CounterNum$ ChosenY | CostDesc$ Exile any number of tokens put onto the battlefield with CARDNAME. | SubAbility$ DBClearYChoice -SVar:DBClearYChoice:DB$ Cleanup | ClearChosenY$ True -SVar:Y:YChoice +SVar:TrigPutCounters:AB$PutCounter | Cost$ Exile | References$ X | Defined$ Self | CounterType$ P1P1 | CounterNum$ ChosenX | CostDesc$ Exile any number of tokens put onto the battlefield with CARDNAME. | SubAbility$ DBClearXChoice SVar:Picture:http://www.wizards.com/global/images/magic/general/tetravus.jpg Oracle:Flying\nTetravus enters the battlefield with three +1/+1 counters on it.\nAt the beginning of your upkeep, you may remove any number of +1/+1 counters from Tetravus. If you do, put that many 1/1 colorless Tetravite artifact creature tokens onto the battlefield. They each have flying and "This creature can't be enchanted."\nAt the beginning of your upkeep, you may exile any number of tokens put onto the battlefield with Tetravus. If you do, put that many +1/+1 counters on Tetravus. SetInfo:ATQ Rare diff --git a/src/main/java/forge/Card.java b/src/main/java/forge/Card.java index 175d41f3338..140576872c0 100644 --- a/src/main/java/forge/Card.java +++ b/src/main/java/forge/Card.java @@ -226,7 +226,7 @@ public class Card extends GameEntity implements Comparable { private final List untapCommandList = new ArrayList(); private final List changeControllerCommandList = new ArrayList(); - private final static ImmutableList storableSVars = ImmutableList.of("ChosenX", "ChosenY" ); + private final static ImmutableList storableSVars = ImmutableList.of("ChosenX" ); private final List hauntedBy = new ArrayList(); private Card haunting = null; diff --git a/src/main/java/forge/card/ability/AbilityUtils.java b/src/main/java/forge/card/ability/AbilityUtils.java index 99942b4498d..5a40fb3cda6 100644 --- a/src/main/java/forge/card/ability/AbilityUtils.java +++ b/src/main/java/forge/card/ability/AbilityUtils.java @@ -318,7 +318,7 @@ public class AbilityUtils { if (StringUtils.isBlank(svarval)) { // Some variables may be not chosen yet at this moment // So return 0 and don't issue an error. - if (amount.equals("ChosenX") || amount.equals("ChosenY")) { + if (amount.equals("ChosenX")) { // isn't made yet return 0; } diff --git a/src/main/java/forge/card/ability/effects/CleanUpEffect.java b/src/main/java/forge/card/ability/effects/CleanUpEffect.java index 52248b3f296..1c5fbe9a7da 100644 --- a/src/main/java/forge/card/ability/effects/CleanUpEffect.java +++ b/src/main/java/forge/card/ability/effects/CleanUpEffect.java @@ -31,9 +31,6 @@ public class CleanUpEffect extends SpellAbilityEffect { if (sa.hasParam("ClearChosenX")) { source.setSVar("ChosenX", ""); } - if (sa.hasParam("ClearChosenY")) { - source.setSVar("ChosenY", ""); - } if (sa.hasParam("ClearTriggered")) { Singletons.getModel().getGame().getTriggerHandler().clearDelayedTrigger(source); } diff --git a/src/main/java/forge/card/cost/CostExile.java b/src/main/java/forge/card/cost/CostExile.java index 6ede1a632cd..8ceb591ce54 100644 --- a/src/main/java/forge/card/cost/CostExile.java +++ b/src/main/java/forge/card/cost/CostExile.java @@ -542,8 +542,6 @@ public class CostExile extends CostPartWithList { // Generalize this if (sVar.equals("XChoice")) { c = CostUtil.chooseXValue(source, ability, list.size()); - } else if (sVar.equals("YChoice")) { - c = CostUtil.chooseYValue(source, ability, list.size()); } else { c = AbilityUtils.calculateAmount(source, amount, ability); } @@ -652,7 +650,7 @@ public class CostExile extends CostPartWithList { if (c == null) { final String sVar = ability.getSVar(this.getAmount()); // Generalize this - if (sVar.equals("XChoice") || sVar.equals("YChoice")) { + if (sVar.equals("XChoice")) { return null; } c = AbilityUtils.calculateAmount(source, this.getAmount(), ability); diff --git a/src/main/java/forge/card/cost/CostRemoveCounter.java b/src/main/java/forge/card/cost/CostRemoveCounter.java index a6d8589da7a..9cd17c09a55 100644 --- a/src/main/java/forge/card/cost/CostRemoveCounter.java +++ b/src/main/java/forge/card/cost/CostRemoveCounter.java @@ -122,21 +122,23 @@ public class CostRemoveCounter extends CostPartWithList { final String amount = this.getAmount(); final Card source = ability.getSourceCard(); Integer c = this.convertAmount(); - int maxCounters = 0; + String sVarAmount = ability.getSVar(amount); cntRemoved = 1; - if (amount.equals("All")) - cntRemoved = -1; - else if (c != null) { + if (c != null) cntRemoved = c.intValue(); - } else { - cntRemoved = "XChoice".equals(ability.getSVar(amount)) - ? CostUtil.chooseXValue(source, ability, maxCounters) - : AbilityUtils.calculateAmount(source, amount, ability); + else if (!"XChoice".equals(sVarAmount)) { + cntRemoved = AbilityUtils.calculateAmount(source, amount, ability); } - + if (this.payCostFromSource()) { - maxCounters = source.getCounters(this.counter); + int maxCounters = source.getCounters(this.counter); + if (amount.equals("All")) + cntRemoved = maxCounters; + else if ( c == null && "XChoice".equals(sVarAmount)) { + cntRemoved = CostUtil.chooseXValue(source, ability, maxCounters); + } + if (maxCounters < cntRemoved) return false; cntRemoved = cntRemoved >= 0 ? cntRemoved : maxCounters; diff --git a/src/main/java/forge/card/cost/CostUtil.java b/src/main/java/forge/card/cost/CostUtil.java index 82d7d4da6bf..e0e6c29aece 100644 --- a/src/main/java/forge/card/cost/CostUtil.java +++ b/src/main/java/forge/card/cost/CostUtil.java @@ -97,33 +97,6 @@ public class CostUtil { return chosenX; } - /** - * Choose x value (for ChosenY). - * - * @param card - * the card - * @param sa - * the SpellAbility - * @param maxValue - * the max value - * @return the int - */ - public static int chooseYValue(final Card card, final SpellAbility sa, final int maxValue) { - /*final String chosen = sa.getSVar("ChosenY"); - if (chosen.length() > 0) { - return AbilityFactory.calculateAmount(card, "ChosenY", null); - }*/ - - final Integer[] choiceArray = new Integer[maxValue + 1]; - for (int i = 0; i < choiceArray.length; i++) { - choiceArray[i] = Integer.valueOf(i); - } - final Integer chosenY = GuiChoose.one(card.toString() + " - Choose a Value for Y", choiceArray); - sa.setSVar("ChosenY", Integer.toString(chosenY)); - card.setSVar("ChosenY", Integer.toString(chosenY)); - - return chosenY; - } public static Cost combineCosts(Cost cost1, Cost cost2) { if (cost1 == null) return cost2; diff --git a/src/main/java/forge/card/spellability/HumanPlaySpellAbility.java b/src/main/java/forge/card/spellability/HumanPlaySpellAbility.java index 52d775b435f..7b5afb659e0 100644 --- a/src/main/java/forge/card/spellability/HumanPlaySpellAbility.java +++ b/src/main/java/forge/card/spellability/HumanPlaySpellAbility.java @@ -24,6 +24,7 @@ import org.apache.commons.lang3.StringUtils; import forge.Card; import forge.CardCharacteristicName; import forge.card.ability.AbilityUtils; +import forge.card.cost.CostPartMana; import forge.card.cost.CostPayment; import forge.game.GameState; import forge.game.zone.Zone; @@ -157,7 +158,9 @@ public class HumanPlaySpellAbility { for(String aVar : announce.split(",")) { String varName = aVar.trim(); - boolean allowZero = !("X".equalsIgnoreCase(varName)) || ability.getPayCosts().getCostMana().canXbe0(); + boolean isX = "X".equalsIgnoreCase(varName); + CostPartMana manaCost = ability.getPayCosts().getCostMana(); + boolean allowZero = !isX || manaCost == null || manaCost.canXbe0(); Integer value = ability.getActivatingPlayer().getController().announceRequirements(ability, varName, allowZero); if ( null == value ) diff --git a/src/main/java/forge/game/zone/MagicStack.java b/src/main/java/forge/game/zone/MagicStack.java index c0c14a37939..7fd381cefe7 100644 --- a/src/main/java/forge/game/zone/MagicStack.java +++ b/src/main/java/forge/game/zone/MagicStack.java @@ -26,7 +26,6 @@ import com.esotericsoftware.minlog.Log; import forge.Card; import forge.CardLists; -import forge.CardPredicates; import forge.FThreads; import forge.CardPredicates.Presets; import forge.Singletons;