diff --git a/forge-game/src/main/java/forge/ai/AiCostDecision.java b/forge-game/src/main/java/forge/ai/AiCostDecision.java index 171ebf24328..6bb581e4ac7 100644 --- a/forge-game/src/main/java/forge/ai/AiCostDecision.java +++ b/forge-game/src/main/java/forge/ai/AiCostDecision.java @@ -540,7 +540,7 @@ public class AiCostDecision extends CostDecisionMakerBase implements ICostVisito } for (Card card : typeList) { if (card.getCounters(cost.counter) >= c) { - return PaymentDecision.card(card); + return PaymentDecision.card(card, c); } } return null; @@ -551,9 +551,7 @@ public class AiCostDecision extends CostDecisionMakerBase implements ICostVisito return null; } - PaymentDecision result = PaymentDecision.card(source); - result.c = c; // cost.cntRemoved = c; - return result; + return PaymentDecision.card(source, c); } @Override diff --git a/forge-game/src/main/java/forge/game/cost/CostRemoveCounter.java b/forge-game/src/main/java/forge/game/cost/CostRemoveCounter.java index c4c0726e1c6..8f6c84accf4 100644 --- a/forge-game/src/main/java/forge/game/cost/CostRemoveCounter.java +++ b/forge-game/src/main/java/forge/game/cost/CostRemoveCounter.java @@ -20,7 +20,6 @@ package forge.game.cost; import java.util.List; import com.google.common.collect.Lists; -import forge.game.ability.AbilityUtils; import forge.game.card.Card; import forge.game.card.CardLists; import forge.game.card.CounterType; @@ -43,14 +42,6 @@ public class CostRemoveCounter extends CostPartWithList { public final CounterType counter; public final ZoneType zone; private int cntRemoved; - - - /** - * @param cntRemoved the cntRemoved to set - */ - public void setCntRemoved(int cntRemoved) { - this.cntRemoved = cntRemoved; - } /** * Instantiates a new cost remove counter. @@ -168,23 +159,9 @@ public class CostRemoveCounter extends CostPartWithList { @Override public boolean payAsDecided(Player ai, PaymentDecision decision, SpellAbility ability) { Card source = ability.getSourceCard(); - final String amount = this.getAmount(); - Integer c = this.convertAmount(); - if (c == null) { - if (amount.equals("All")) { - cntRemoved = source.getCounters(this.counter); - } else { - cntRemoved = AbilityUtils.calculateAmount(source, amount, ability); - } - } else - cntRemoved = c.intValue(); - - if (this.payCostFromSource()) { - executePayment(ability, source); - } else { - for (final Card card : decision.cards) { - executePayment(ability, card); - } + cntRemoved = decision.c; + for (final Card card : decision.cards) { + executePayment(ability, card); } source.setSVar("CostCountersRemoved", Integer.toString(cntRemoved)); return true; diff --git a/forge-game/src/main/java/forge/game/cost/PaymentDecision.java b/forge-game/src/main/java/forge/game/cost/PaymentDecision.java index 9da39d5c5c9..cae4c5af2c5 100644 --- a/forge-game/src/main/java/forge/game/cost/PaymentDecision.java +++ b/forge-game/src/main/java/forge/game/cost/PaymentDecision.java @@ -48,6 +48,13 @@ public class PaymentDecision { return new PaymentDecision(chosen); } + public static PaymentDecision card(Card chosen, int n) { + PaymentDecision res = new PaymentDecision(chosen); + res.c = n; + return res; + } + + public static PaymentDecision number(int c) { return new PaymentDecision(c); } @@ -56,6 +63,12 @@ public class PaymentDecision { return new PaymentDecision(chosen, null, null); } + public static PaymentDecision card(Collection chosen, int n) { + PaymentDecision res = new PaymentDecision(chosen, null, null); + res.c = n; + return res; + } + public static PaymentDecision mana(List manas) { return new PaymentDecision(null, manas, null); } diff --git a/forge-gui/src/main/java/forge/gui/player/HumanCostDecision.java b/forge-gui/src/main/java/forge/gui/player/HumanCostDecision.java index 1049cb8fac5..b1c0e3855cd 100644 --- a/forge-gui/src/main/java/forge/gui/player/HumanCostDecision.java +++ b/forge-gui/src/main/java/forge/gui/player/HumanCostDecision.java @@ -908,13 +908,11 @@ public class HumanCostDecision extends CostDecisionMakerBase { else if ( c == null && "XChoice".equals(sVarAmount)) { cntRemoved = chooseXValue(maxCounters); } - cost.setCntRemoved(cntRemoved); if (maxCounters < cntRemoved) return null; - PaymentDecision res = PaymentDecision.card(source); - res.c = cntRemoved >= 0 ? cntRemoved : maxCounters; - return res; + return PaymentDecision.card(source, cntRemoved >= 0 ? cntRemoved : maxCounters); + } else if (type.equals("OriginalHost")) { int maxCounters = ability.getOriginalHost().getCounters(cost.counter); if (amount.equals("All")) { @@ -923,10 +921,7 @@ public class HumanCostDecision extends CostDecisionMakerBase { if (maxCounters < cntRemoved) return null; - PaymentDecision res = PaymentDecision.card(ability.getOriginalHost()); - res.c = cntRemoved >= 0 ? cntRemoved : maxCounters; - cost.setCntRemoved(cntRemoved); - return res; + return PaymentDecision.card(ability.getOriginalHost(), cntRemoved >= 0 ? cntRemoved : maxCounters); } List validCards = CardLists.getValidCards(player.getCardsIn(cost.zone), type.split(";"), player, source); @@ -949,8 +944,7 @@ public class HumanCostDecision extends CostDecisionMakerBase { int oldVal = crd.getCounters().get(cost.counter).intValue(); crd.getCounters().put(cost.counter, Integer.valueOf(oldVal - removed + 1)); } - cost.setCntRemoved(1); - return PaymentDecision.card(inp.getSelected()); + return PaymentDecision.card(inp.getSelected(), 1); } // Rift Elemental only - always removes 1 counter, so there will be no code for N counters. @@ -960,7 +954,7 @@ public class HumanCostDecision extends CostDecisionMakerBase { suspended.add(crd); final Card card = GuiChoose.oneOrNone("Remove counter(s) from a card in " + cost.zone, suspended); - return null == card ? null : PaymentDecision.card(card); + return null == card ? null : PaymentDecision.card(card, c); } @Override