Added UUID to costs (required for optional costs for kicker)

This commit is contained in:
magenoxx 2011-09-14 00:35:02 +04:00
parent f72a04f175
commit a07c210ac0
6 changed files with 526 additions and 495 deletions

View file

@ -23,6 +23,11 @@ public class CompositeCost implements Cost {
this.description = cost.description;
}
@Override
public UUID getId() {
throw new RuntimeException("Not supported method");
}
@Override
public String getText() {
return description;

View file

@ -37,6 +37,7 @@ import mage.target.Targets;
public interface Cost extends Serializable {
public UUID getId();
public String getText();
public boolean canPay(UUID sourceId, UUID controllerId, Game game);
public boolean pay(Ability ability, Game game, UUID sourceId, UUID controllerId, boolean noMana);

View file

@ -31,8 +31,11 @@ package mage.abilities.costs;
import mage.target.Target;
import mage.target.Targets;
import java.util.UUID;
public abstract class CostImpl<T extends CostImpl<T>> implements Cost {
protected UUID id;
protected String text;
protected boolean paid;
protected Targets targets;
@ -41,11 +44,13 @@ public abstract class CostImpl<T extends CostImpl<T>> implements Cost {
public abstract T copy();
public CostImpl() {
id = UUID.randomUUID();
paid = false;
targets = new Targets();
}
public CostImpl(final CostImpl cost) {
this.id = cost.id;
this.text = cost.text;
this.paid = cost.paid;
this.targets = cost.targets.copy();
@ -82,4 +87,9 @@ public abstract class CostImpl<T extends CostImpl<T>> implements Cost {
paid = true;
}
@Override
public UUID getId() {
return this.id;
}
}

View file

@ -51,6 +51,11 @@ public class CostsImpl<T extends Cost> extends ArrayList<T> implements Costs<T>
}
}
@Override
public UUID getId() {
throw new RuntimeException("Not supported method");
}
@Override
public String getText() {
if (this.size() == 0)

View file

@ -29,6 +29,7 @@
package mage.abilities.costs.mana;
import java.util.UUID;
import mage.Constants.ColoredManaSymbol;
import mage.Mana;
import mage.abilities.Ability;

View file

@ -45,16 +45,21 @@ import java.util.*;
*/
public class ManaCostsImpl<T extends ManaCost> extends ArrayList<T> implements ManaCosts<T> {
protected UUID id;
private static Map<String, ManaCosts> costs = new HashMap<String, ManaCosts>();
public ManaCostsImpl() {
this.id = UUID.randomUUID();
}
public ManaCostsImpl(String mana) {
this.id = UUID.randomUUID();
load(mana);
}
public ManaCostsImpl(final ManaCostsImpl<T> costs) {
this.id = costs.id;
for (T cost : costs) {
this.add((T) cost.copy());
}
@ -147,7 +152,6 @@ public class ManaCostsImpl<T extends ManaCost> extends ArrayList<T> implements M
}
@Override
public List<VariableCost> getVariableCosts() {
List<VariableCost> variableCosts = new ArrayList<VariableCost>();
@ -267,6 +271,11 @@ public class ManaCostsImpl<T extends ManaCost> extends ArrayList<T> implements M
return symbols;
}
@Override
public UUID getId() {
return this.id;
}
@Override
public String getText() {
if (this.size() == 0)