- Added the new static ability CantAttackUnless.

This commit is contained in:
Sloth
2012-09-26 18:28:57 +00:00
parent eb8ca4bd29
commit d94843e38c
15 changed files with 230 additions and 121 deletions

View File

@@ -24,6 +24,7 @@ import forge.Card;
import forge.CardList;
import forge.Counters;
import forge.card.abilityfactory.AbilityFactory;
import forge.card.mana.ManaCost;
import forge.card.spellability.SpellAbility;
import forge.control.input.Input;
import forge.game.player.ComputerUtil;
@@ -456,4 +457,36 @@ public class CostUtil {
// Just a shortcut..
AllZone.getInputControl().setInput(in, true);
}
public static Cost combineCosts(Cost cost1, Cost cost2) {
if (cost1 == null) {
if (cost2 == null) {
return null;
} else {
return cost2;
}
}
if (cost2 == null) {
return cost1;
}
for (final CostPart part : cost1.getCostParts()) {
if (!(part instanceof CostMana)) {
cost2.getCostParts().add(part);
} else {
CostMana newCostMana = cost2.getCostMana();
if (newCostMana != null) {
ManaCost oldManaCost = new ManaCost(part.toString());
newCostMana.setXMana(oldManaCost.getXcounter() + newCostMana.getXMana());
oldManaCost.combineManaCost(newCostMana.toString());
newCostMana.setMana(oldManaCost.toString(false));
} else {
cost2.getCostParts().add(part);
}
}
}
return cost2;
}
}