From 9f5857b0ed36c569b4c8c9838a7122f82a49dbc6 Mon Sep 17 00:00:00 2001 From: LevelX2 Date: Thu, 31 Jan 2013 23:39:14 +0100 Subject: [PATCH] Added possibility to set a minimum for VariableManaCosts (does only work for humans). --- Mage/src/mage/abilities/AbilityImpl.java | 14 +++++++------- .../abilities/costs/mana/VariableManaCost.java | 14 +++++++++++++- 2 files changed, 20 insertions(+), 8 deletions(-) diff --git a/Mage/src/mage/abilities/AbilityImpl.java b/Mage/src/mage/abilities/AbilityImpl.java index d9c649101c2..2be319adc4f 100644 --- a/Mage/src/mage/abilities/AbilityImpl.java +++ b/Mage/src/mage/abilities/AbilityImpl.java @@ -198,20 +198,20 @@ public abstract class AbilityImpl> implements Ability { // its mana cost; see rule 107.3), the player announces the value of that variable. if (game.getPlayer(this.controllerId).isHuman()) { // AI can't handle this yet. Uses old way of playXMana - VariableManaCost manaX = null; + VariableManaCost variableManaCost = null; for (ManaCost cost: manaCostsToPay) { if (cost instanceof VariableManaCost && !cost.isPaid()) { - manaX = (VariableManaCost) cost; + variableManaCost = (VariableManaCost) cost; break; // only one VariableManCost per spell (or is it possible to have more?) } } - if (manaX != null) { - int amount = game.getPlayer(this.controllerId).getAmount(0, Integer.MAX_VALUE, "Announce the value for " + manaX.getText(), game); - game.informPlayers(new StringBuilder(game.getPlayer(this.controllerId).getName()).append(" announced a value of ").append(amount).append(" for ").append(manaX.getText()).toString()); - amount *= manaX.getMultiplier(); + if (variableManaCost != null) { + int amount = game.getPlayer(this.controllerId).getAmount(variableManaCost.getMinX(), Integer.MAX_VALUE, "Announce the value for " + variableManaCost.getText(), game); + game.informPlayers(new StringBuilder(game.getPlayer(this.controllerId).getName()).append(" announced a value of ").append(amount).append(" for ").append(variableManaCost.getText()).toString()); + amount *= variableManaCost.getMultiplier(); manaCostsToPay.add(new ManaCostsImpl(new StringBuilder("{").append(amount).append("}").toString())); manaCostsToPay.setX(amount); - manaX.setPaid(); + variableManaCost.setPaid(); } } diff --git a/Mage/src/mage/abilities/costs/mana/VariableManaCost.java b/Mage/src/mage/abilities/costs/mana/VariableManaCost.java index 8a27fee572e..99fc604d4a3 100644 --- a/Mage/src/mage/abilities/costs/mana/VariableManaCost.java +++ b/Mage/src/mage/abilities/costs/mana/VariableManaCost.java @@ -43,6 +43,7 @@ public class VariableManaCost extends ManaCostImpl implements protected int multiplier; protected FilterMana filter; + protected int minX = 0; public VariableManaCost() { this(1); @@ -57,7 +58,10 @@ public class VariableManaCost extends ManaCostImpl implements public VariableManaCost(VariableManaCost manaCost) { super(manaCost); this.multiplier = manaCost.multiplier; - if (manaCost.filter != null) this.filter = manaCost.filter.copy(); + if (manaCost.filter != null) { + this.filter = manaCost.filter.copy(); + } + this.minX = manaCost.minX; } @Override @@ -119,4 +123,12 @@ public class VariableManaCost extends ManaCostImpl implements public int getMultiplier() { return multiplier; } + + public int getMinX() { + return minX; + } + + public void setMinX(int minX) { + this.minX = minX; + } }