Added possibility to set a minimum for VariableManaCosts (does only work for humans).

This commit is contained in:
LevelX2 2013-01-31 23:39:14 +01:00
parent 90e4c74a4d
commit 9f5857b0ed
2 changed files with 20 additions and 8 deletions

View file

@ -198,20 +198,20 @@ public abstract class AbilityImpl<T extends AbilityImpl<T>> 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();
}
}

View file

@ -43,6 +43,7 @@ public class VariableManaCost extends ManaCostImpl<VariableManaCost> implements
protected int multiplier;
protected FilterMana filter;
protected int minX = 0;
public VariableManaCost() {
this(1);
@ -57,7 +58,10 @@ public class VariableManaCost extends ManaCostImpl<VariableManaCost> 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<VariableManaCost> implements
public int getMultiplier() {
return multiplier;
}
public int getMinX() {
return minX;
}
public void setMinX(int minX) {
this.minX = minX;
}
}