Code cleanup

This commit is contained in:
drdev
2013-12-02 07:31:12 +00:00
parent 93b6ac15dd
commit fe04d56568

View File

@@ -240,7 +240,7 @@ public class Card extends GameEntity implements Comparable<Card> {
private final List<Command> untapCommandList = new ArrayList<Command>(); private final List<Command> untapCommandList = new ArrayList<Command>();
private final List<Command> changeControllerCommandList = new ArrayList<Command>(); private final List<Command> changeControllerCommandList = new ArrayList<Command>();
private final static ImmutableList<String> storableSVars = ImmutableList.of("ChosenX" ); private final static ImmutableList<String> storableSVars = ImmutableList.of("ChosenX");
private final List<Card> hauntedBy = new ArrayList<Card>(); private final List<Card> hauntedBy = new ArrayList<Card>();
private Card haunting = null; private Card haunting = null;
@@ -1144,7 +1144,7 @@ public class Card extends GameEntity implements Comparable<Card> {
public final void addCounter(final CounterType counterType, final int n, final boolean applyMultiplier) { public final void addCounter(final CounterType counterType, final int n, final boolean applyMultiplier) {
final int addAmount = getTotalCountersToAdd(counterType, n, applyMultiplier); final int addAmount = getTotalCountersToAdd(counterType, n, applyMultiplier);
if ( addAmount == 0 ) if (addAmount == 0)
return; return;
Integer oldValue = this.counters.get(counterType); Integer oldValue = this.counters.get(counterType);
@@ -1564,7 +1564,7 @@ public class Card extends GameEntity implements Comparable<Card> {
List<CardColor> colorList = this.getCharacteristics().getCardColor(); List<CardColor> colorList = this.getCharacteristics().getCardColor();
byte colors = 0; byte colors = 0;
for(int i = colorList.size() - 1;i >= 0;i--) { for (int i = colorList.size() - 1;i >= 0;i--) {
final CardColor cc = colorList.get(i); final CardColor cc = colorList.get(i);
colors |= cc.getColorMask(); colors |= cc.getColorMask();
if (!cc.isAdditional()) { if (!cc.isAdditional()) {
@@ -1847,11 +1847,11 @@ public class Card extends GameEntity implements Comparable<Card> {
sb.append("\r\nLife Modifier: ").append(getRules().getLife()); sb.append("\r\nLife Modifier: ").append(getRules().getLife());
sb.append("\r\n\r\n"); sb.append("\r\n\r\n");
} }
if(this.isCommander) if (this.isCommander)
{ {
sb.append(getOwner() + "'s Commander\r\n\r\n"); sb.append(getOwner() + "'s Commander\r\n\r\n");
} }
if(this.getName().equals("Commander effect")) if (this.getName().equals("Commander effect"))
{ {
sb.append("Zone: " + getOwner().getCommander().getZone().toString() + "\r\n"); sb.append("Zone: " + getOwner().getCommander().getZone().toString() + "\r\n");
sb.append(CardFactoryUtil.getCommanderInfo(getOwner())); sb.append(CardFactoryUtil.getCommanderInfo(getOwner()));
@@ -2106,7 +2106,7 @@ public class Card extends GameEntity implements Comparable<Card> {
continue; continue;
} else if (keyword.startsWith("CantBeBlockedBy")) { } else if (keyword.startsWith("CantBeBlockedBy")) {
sbLong.append(this.getName()).append(" can't be blocked "); sbLong.append(this.getName()).append(" can't be blocked ");
if( keyword.startsWith("CantBeBlockedByAmount")) if (keyword.startsWith("CantBeBlockedByAmount"))
sbLong.append(getTextForKwCantBeBlockedByAmount(keyword)); sbLong.append(getTextForKwCantBeBlockedByAmount(keyword));
else else
sbLong.append(getTextForKwCantBeBlockedByType(keyword)); sbLong.append(getTextForKwCantBeBlockedByType(keyword));
@@ -2149,12 +2149,12 @@ public class Card extends GameEntity implements Comparable<Card> {
List<String> subs = Lists.newArrayList(TextUtil.split(keyword.split(" ", 2)[1], ',')); List<String> subs = Lists.newArrayList(TextUtil.split(keyword.split(" ", 2)[1], ','));
List<List<String>> subsAnd = Lists.newArrayList(); List<List<String>> subsAnd = Lists.newArrayList();
List<String> orClauses = new ArrayList<String>(); List<String> orClauses = new ArrayList<String>();
for( int iOr = 0; iOr < subs.size(); iOr++ ) { for (int iOr = 0; iOr < subs.size(); iOr++) {
String expession = subs.get(iOr); String expession = subs.get(iOr);
List<String> parts = Lists.newArrayList(expession.split("[.+]")); List<String> parts = Lists.newArrayList(expession.split("[.+]"));
for(int p = 0; p < parts.size(); p++) { for (int p = 0; p < parts.size(); p++) {
String part = parts.get(p); String part = parts.get(p);
if( part.equalsIgnoreCase("creature")) { if (part.equalsIgnoreCase("creature")) {
parts.remove(p--); parts.remove(p--);
continue; continue;
} }
@@ -2171,53 +2171,53 @@ public class Card extends GameEntity implements Comparable<Card> {
@Override @Override
public String apply(Pair<Boolean, String> inp) { public String apply(Pair<Boolean, String> inp) {
boolean useNon = inp.getKey().booleanValue() == allNegative; boolean useNon = inp.getKey().booleanValue() == allNegative;
return (useNon ? "*NO* " : "" ) + inp.getRight(); return (useNon ? "*NO* " : "") + inp.getRight();
} }
}; };
for( int iOr = 0; iOr < subsAnd.size(); iOr++ ) { for (int iOr = 0; iOr < subsAnd.size(); iOr++) {
List<String> andOperands = subsAnd.get(iOr); List<String> andOperands = subsAnd.get(iOr);
List<Pair<Boolean, String>> prependedAdjectives = Lists.newArrayList(); List<Pair<Boolean, String>> prependedAdjectives = Lists.newArrayList();
List<Pair<Boolean, String>> postponedAdjectives = Lists.newArrayList(); List<Pair<Boolean, String>> postponedAdjectives = Lists.newArrayList();
String creatures = null; String creatures = null;
for(String part : andOperands) { for (String part : andOperands) {
boolean positive = true; boolean positive = true;
if (part.startsWith("non")) { if (part.startsWith("non")) {
part = part.substring(3); part = part.substring(3);
positive = false; positive = false;
} }
if(part.startsWith("with")) { if (part.startsWith("with")) {
positive = !part.startsWith("without"); positive = !part.startsWith("without");
postponedAdjectives.add(Pair.of(positive, part.substring(positive ? 4 : 7))); postponedAdjectives.add(Pair.of(positive, part.substring(positive ? 4 : 7)));
} else if ( part.startsWith("power") ) { } else if (part.startsWith("power")) {
int kwLength = 5; int kwLength = 5;
String opName = Expressions.operatorName(part.substring(kwLength, kwLength + 2)); String opName = Expressions.operatorName(part.substring(kwLength, kwLength + 2));
String operand = part.substring(kwLength + 2); String operand = part.substring(kwLength + 2);
postponedAdjectives.add(Pair.of(true, "power" + opName + operand)); postponedAdjectives.add(Pair.of(true, "power" + opName + operand));
} else if ( forge.card.CardType.isACreatureType(part)) { } else if (forge.card.CardType.isACreatureType(part)) {
creatures = StringUtils.capitalize(Lang.getPlural(part)) + ( creatures == null ? "" : " or " + creatures ); creatures = StringUtils.capitalize(Lang.getPlural(part)) + (creatures == null ? "" : " or " + creatures);
} else { } else {
prependedAdjectives.add(Pair.of(positive, part.toLowerCase())); prependedAdjectives.add(Pair.of(positive, part.toLowerCase()));
} }
} }
StringBuilder sbShort = new StringBuilder(); StringBuilder sbShort = new StringBuilder();
if ( allNegative ) { if (allNegative) {
boolean isFirst = true; boolean isFirst = true;
for(Pair<Boolean, String> pre : prependedAdjectives) { for (Pair<Boolean, String> pre : prependedAdjectives) {
if ( isFirst ) isFirst = false; if (isFirst) isFirst = false;
else sbShort.append(" and/or "); else sbShort.append(" and/or ");
boolean useNon = pre.getKey().booleanValue() == allNegative; boolean useNon = pre.getKey().booleanValue() == allNegative;
if( useNon ) sbShort.append("non-"); if (useNon) sbShort.append("non-");
sbShort.append(pre.getValue()).append(" ").append(creatures == null ? "creatures" : creatures); sbShort.append(pre.getValue()).append(" ").append(creatures == null ? "creatures" : creatures);
} }
if (prependedAdjectives.isEmpty()) if (prependedAdjectives.isEmpty())
sbShort.append(creatures == null ? "creatures" : creatures); sbShort.append(creatures == null ? "creatures" : creatures);
if(!postponedAdjectives.isEmpty()) { if (!postponedAdjectives.isEmpty()) {
if( !prependedAdjectives.isEmpty() ) { if (!prependedAdjectives.isEmpty()) {
sbShort.append(" and/or creatures"); sbShort.append(" and/or creatures");
} }
@@ -2226,14 +2226,14 @@ public class Card extends GameEntity implements Comparable<Card> {
} }
} else { } else {
for(Pair<Boolean, String> pre : prependedAdjectives) { for (Pair<Boolean, String> pre : prependedAdjectives) {
boolean useNon = pre.getKey().booleanValue() == allNegative; boolean useNon = pre.getKey().booleanValue() == allNegative;
if( useNon ) sbShort.append("non-"); if (useNon) sbShort.append("non-");
sbShort.append(pre.getValue()).append(" "); sbShort.append(pre.getValue()).append(" ");
} }
sbShort.append(creatures == null ? "creatures" : creatures); sbShort.append(creatures == null ? "creatures" : creatures);
if(!postponedAdjectives.isEmpty()) { if (!postponedAdjectives.isEmpty()) {
sbShort.append(" with "); sbShort.append(" with ");
sbShort.append(Lang.joinHomogenous(postponedAdjectives, withToString, allNegative ? "or" : "and")); sbShort.append(Lang.joinHomogenous(postponedAdjectives, withToString, allNegative ? "or" : "and"));
} }
@@ -2981,7 +2981,6 @@ public class Card extends GameEntity implements Comparable<Card> {
this.changeControllerCommandList.add(c); this.changeControllerCommandList.add(c);
} }
public final void runChangeControllerCommands() { public final void runChangeControllerCommands() {
for (final Command c : this.changeControllerCommandList) { for (final Command c : this.changeControllerCommandList) {
c.run(); c.run();
@@ -3040,7 +3039,6 @@ public class Card extends GameEntity implements Comparable<Card> {
this.becameTargetThisTurn = becameTargetThisTurn; this.becameTargetThisTurn = becameTargetThisTurn;
} }
/** /**
* @return the startedTheTurnUntapped * @return the startedTheTurnUntapped
*/ */
@@ -3055,7 +3053,6 @@ public class Card extends GameEntity implements Comparable<Card> {
this.startedTheTurnUntapped = untapped; this.startedTheTurnUntapped = untapped;
} }
/** /**
* <p> * <p>
* Getter for the field <code>owner</code>. * Getter for the field <code>owner</code>.
@@ -3096,7 +3093,6 @@ public class Card extends GameEntity implements Comparable<Card> {
public final void clearTempControllers() { public final void clearTempControllers() {
this.tempControllers.clear(); this.tempControllers.clear();
} }
public final void clearControllers() { public final void clearControllers() {
@@ -3369,8 +3365,7 @@ public class Card extends GameEntity implements Comparable<Card> {
* @param c * @param c
* a {@link forge.game.card.Card} object. * a {@link forge.game.card.Card} object.
*/ */
public final void unEquipCard(final Card c) // equipment.unEquipCard(equippedCard); public final void unEquipCard(final Card c) { // equipment.unEquipCard(equippedCard);
{
this.equipping.remove(c); this.equipping.remove(c);
c.equippedBy.remove(this); c.equippedBy.remove(this);
@@ -3636,7 +3631,6 @@ public class Card extends GameEntity implements Comparable<Card> {
} }
return newType; return newType;
} }
/** /**
@@ -4047,7 +4041,7 @@ public class Card extends GameEntity implements Comparable<Card> {
public final void addMultiKickerMagnitude(final int n) { this.multiKickerMagnitude += n; } public final void addMultiKickerMagnitude(final int n) { this.multiKickerMagnitude += n; }
public final void setKickerMagnitude(final int n) { this.multiKickerMagnitude = n; } public final void setKickerMagnitude(final int n) { this.multiKickerMagnitude = n; }
public final int getKickerMagnitude() { public final int getKickerMagnitude() {
if ( this.multiKickerMagnitude > 0 ) if (this.multiKickerMagnitude > 0)
return multiKickerMagnitude; return multiKickerMagnitude;
boolean hasK1 = costsPaid.contains(OptionalCost.Kicker1); boolean hasK1 = costsPaid.contains(OptionalCost.Kicker1);
return hasK1 == costsPaid.contains(OptionalCost.Kicker2) ? (hasK1 ? 2 : 0) : 1; return hasK1 == costsPaid.contains(OptionalCost.Kicker2) ? (hasK1 ? 2 : 0) : 1;
@@ -4688,14 +4682,11 @@ public class Card extends GameEntity implements Comparable<Card> {
public final boolean isFortification() { return this.typeContains("Fortification"); } public final boolean isFortification() { return this.typeContains("Fortification"); }
public final boolean isScheme() { return this.typeContains("Scheme"); } public final boolean isScheme() { return this.typeContains("Scheme"); }
public final boolean isPlaneswalker() { return this.typeContains("Planeswalker"); } public final boolean isPlaneswalker() { return this.typeContains("Planeswalker"); }
public final boolean isEnchantment() { return this.typeContains("Enchantment"); } public final boolean isEnchantment() { return this.typeContains("Enchantment"); }
public final boolean isAura() { return this.typeContains("Aura"); } public final boolean isAura() { return this.typeContains("Aura"); }
private boolean typeContains(final String s) { private boolean typeContains(final String s) {
final Iterator<String> it = this.getType().iterator(); final Iterator<String> it = this.getType().iterator();
while (it.hasNext()) { while (it.hasNext()) {
@@ -5190,8 +5181,8 @@ public class Card extends GameEntity implements Comparable<Card> {
final String[] incR = restriction.split("\\.", 2); final String[] incR = restriction.split("\\.", 2);
boolean testFailed = false; boolean testFailed = false;
if(incR[0].startsWith("!")) { if (incR[0].startsWith("!")) {
testFailed = true; // a bit counter logical )) testFailed = true; // a bit counter logical))
incR[0] = incR[0].substring(1); // consume negation sign incR[0] = incR[0].substring(1); // consume negation sign
} }
@@ -5282,32 +5273,32 @@ public class Card extends GameEntity implements Comparable<Card> {
} }
// ... Card colors // ... Card colors
else if (property.contains("White") || property.contains("Blue") || property.contains("Black") else if (property.contains("White") || property.contains("Blue") || property.contains("Black")
|| property.contains("Red") || property.contains("Green") ) { || property.contains("Red") || property.contains("Green")) {
boolean mustHave = !property.startsWith("non"); boolean mustHave = !property.startsWith("non");
int desiredColor = MagicColor.fromName(mustHave ? property : property.substring(3)); int desiredColor = MagicColor.fromName(mustHave ? property : property.substring(3));
boolean hasColor = CardUtil.getColors(this).hasAnyColor(desiredColor); boolean hasColor = CardUtil.getColors(this).hasAnyColor(desiredColor);
if( mustHave != hasColor ) if (mustHave != hasColor)
return false; return false;
} else if (property.contains("Colorless")) { // ... Card is colorless } else if (property.contains("Colorless")) { // ... Card is colorless
if( property.startsWith("non") == CardUtil.getColors(this).isColorless() ) return false; if (property.startsWith("non") == CardUtil.getColors(this).isColorless()) return false;
} else if (property.contains("MultiColor")) { // ... Card is multicolored } else if (property.contains("MultiColor")) { // ... Card is multicolored
if( property.startsWith("non") == CardUtil.getColors(this).isMulticolor() ) return false; if (property.startsWith("non") == CardUtil.getColors(this).isMulticolor()) return false;
} else if (property.contains("MonoColor")) { // ... Card is monocolored } else if (property.contains("MonoColor")) { // ... Card is monocolored
if( property.startsWith("non") == CardUtil.getColors(this).isMonoColor() ) return false; if (property.startsWith("non") == CardUtil.getColors(this).isMonoColor()) return false;
} else if (property.equals("ChosenColor")) { } else if (property.equals("ChosenColor")) {
if (source.getChosenColor().isEmpty() || !CardUtil.getColors(this).hasAnyColor(MagicColor.fromName(source.getChosenColor().get(0)))) if (source.getChosenColor().isEmpty() || !CardUtil.getColors(this).hasAnyColor(MagicColor.fromName(source.getChosenColor().get(0))))
return false; return false;
} else if (property.equals("AllChosenColors")) { } else if (property.equals("AllChosenColors")) {
if ( source.getChosenColor().isEmpty() || !CardUtil.getColors(this).hasAllColors(ColorSet.fromNames(source.getChosenColor()).getColor()) ) if (source.getChosenColor().isEmpty() || !CardUtil.getColors(this).hasAllColors(ColorSet.fromNames(source.getChosenColor()).getColor()))
return false; return false;
} else if (property.equals("AnyChosenColor")) { } else if (property.equals("AnyChosenColor")) {
if ( source.getChosenColor().isEmpty() || !CardUtil.getColors(this).hasAnyColor(ColorSet.fromNames(source.getChosenColor()).getColor()) ) if (source.getChosenColor().isEmpty() || !CardUtil.getColors(this).hasAnyColor(ColorSet.fromNames(source.getChosenColor()).getColor()))
return false; return false;
} else if (property.equals("DoubleFaced")) { } else if (property.equals("DoubleFaced")) {
@@ -5790,14 +5781,14 @@ public class Card extends GameEntity implements Comparable<Card> {
} }
} else if (restriction.equals("MostProminentColor")) { } else if (restriction.equals("MostProminentColor")) {
byte mask = CardFactoryUtil.getMostProminentColors(game.getCardsIn(ZoneType.Battlefield)); byte mask = CardFactoryUtil.getMostProminentColors(game.getCardsIn(ZoneType.Battlefield));
if( !CardUtil.getColors(this).hasAnyColor(mask)) if (!CardUtil.getColors(this).hasAnyColor(mask))
return false; return false;
} else if (restriction.equals("LastCastThisTurn")) { } else if (restriction.equals("LastCastThisTurn")) {
final List<Card> c = game.getStack().getCardsCastThisTurn(); final List<Card> c = game.getStack().getCardsCastThisTurn();
if (c.isEmpty() || !this.sharesColorWith(c.get(c.size() - 1))) { if (c.isEmpty() || !this.sharesColorWith(c.get(c.size() - 1))) {
return false; return false;
} }
} else if (restriction.equals("ActivationColor" )) { } else if (restriction.equals("ActivationColor")) {
byte manaSpent = source.getColorsPaid(); byte manaSpent = source.getColorsPaid();
if (!CardUtil.getColors(this).hasAnyColor(manaSpent)) { if (!CardUtil.getColors(this).hasAnyColor(manaSpent)) {
return false; return false;
@@ -6368,7 +6359,7 @@ public class Card extends GameEntity implements Comparable<Card> {
} }
} else if (property.startsWith("hasXCost")) { } else if (property.startsWith("hasXCost")) {
SpellAbility sa1 = this.getFirstSpellAbility(); SpellAbility sa1 = this.getFirstSpellAbility();
if( sa1 != null && !sa1.isXCost()) { if (sa1 != null && !sa1.isXCost()) {
return false; return false;
} }
} else if (property.startsWith("suspended")) { } else if (property.startsWith("suspended")) {
@@ -6431,7 +6422,7 @@ public class Card extends GameEntity implements Comparable<Card> {
/* /*
* Pattern p = Pattern.compile("[a-z]*[A-Z][A-Z][X0-9]+.*$"); * Pattern p = Pattern.compile("[a-z]*[A-Z][A-Z][X0-9]+.*$");
* String[] parse = ??? * String[] parse = ???
* System.out.println("Parsing completed of: "+Property); for(int i * System.out.println("Parsing completed of: "+Property); for (int i
* = 0; i < parse.length; i++) { * = 0; i < parse.length; i++) {
* System.out.println("parse["+i+"]: "+parse[i]); } * System.out.println("parse["+i+"]: "+parse[i]); }
*/ */
@@ -6458,13 +6449,13 @@ public class Card extends GameEntity implements Comparable<Card> {
} }
// These predicated refer to ongoing combat. If no combat happens, they'll return false (meaning not attacking/blocking ATM) // These predicated refer to ongoing combat. If no combat happens, they'll return false (meaning not attacking/blocking ATM)
else if (property.startsWith("attacking")) { else if (property.startsWith("attacking")) {
if ( null == combat ) return false; if (null == combat) return false;
if (property.equals("attacking")) return combat.isAttacking(this); if (property.equals("attacking")) return combat.isAttacking(this);
if (property.equals("attackingYou")) return combat.isAttacking(this, sourceController); if (property.equals("attackingYou")) return combat.isAttacking(this, sourceController);
} else if (property.startsWith("notattacking")) { } else if (property.startsWith("notattacking")) {
return null == combat || !combat.isAttacking(this); return null == combat || !combat.isAttacking(this);
} else if (property.equals("attackedBySourceThisCombat")) { } else if (property.equals("attackedBySourceThisCombat")) {
if ( null == combat ) return false; if (null == combat) return false;
final GameEntity defender = combat.getDefenderByAttacker(source); final GameEntity defender = combat.getDefenderByAttacker(source);
if (defender instanceof Card) { if (defender instanceof Card) {
if (!this.equals((Card) defender)) { if (!this.equals((Card) defender)) {
@@ -6472,10 +6463,10 @@ public class Card extends GameEntity implements Comparable<Card> {
} }
} }
} else if (property.startsWith("blocking")) { } else if (property.startsWith("blocking")) {
if ( null == combat ) return false; if (null == combat) return false;
String what = property.substring("blocking".length()); String what = property.substring("blocking".length());
if( StringUtils.isEmpty(what)) return combat.isBlocking(this); if (StringUtils.isEmpty(what)) return combat.isBlocking(this);
if (what.startsWith("Source")) return combat.isBlocking(this, source) ; if (what.startsWith("Source")) return combat.isBlocking(this, source) ;
if (what.startsWith("CreatureYouCtrl")) { if (what.startsWith("CreatureYouCtrl")) {
for (final Card c : CardLists.filter(sourceController.getCardsIn(ZoneType.Battlefield), Presets.CREATURES)) for (final Card c : CardLists.filter(sourceController.getCardsIn(ZoneType.Battlefield), Presets.CREATURES))
@@ -6517,7 +6508,7 @@ public class Card extends GameEntity implements Comparable<Card> {
} else if (property.startsWith("blockedSource")) { } else if (property.startsWith("blockedSource")) {
return null != combat && combat.isBlocking(this, source); return null != combat && combat.isBlocking(this, source);
} else if (property.startsWith("isBlockedByRemembered")) { } else if (property.startsWith("isBlockedByRemembered")) {
if ( null == combat ) return false; if (null == combat) return false;
for (final Object o : source.getRemembered()) { for (final Object o : source.getRemembered()) {
if (o instanceof Card && combat.isBlocking((Card) o, this)) { if (o instanceof Card && combat.isBlocking((Card) o, this)) {
return true; return true;
@@ -6684,7 +6675,7 @@ public class Card extends GameEntity implements Comparable<Card> {
return false; return false;
} }
} else if (property.equals("IsCommander")) { } else if (property.equals("IsCommander")) {
if(!this.isCommander) { if (!this.isCommander) {
return false; return false;
} }
} else { } else {
@@ -7048,7 +7039,7 @@ public class Card extends GameEntity implements Comparable<Card> {
public final void setDamage(final int n) { public final void setDamage(final int n) {
int oldDamae = damage; int oldDamae = damage;
this.damage = n; this.damage = n;
if( n != oldDamae ) if (n != oldDamae)
getGame().fireEvent(new GameEventCardStatsChanged(this)); getGame().fireEvent(new GameEventCardStatsChanged(this));
} }
@@ -7605,14 +7596,14 @@ public class Card extends GameEntity implements Comparable<Card> {
if (this.isPlaneswalker()) { if (this.isPlaneswalker()) {
this.subtractCounter(CounterType.LOYALTY, damageToAdd); this.subtractCounter(CounterType.LOYALTY, damageToAdd);
damageType = DamageType.LoyaltyLoss; damageType = DamageType.LoyaltyLoss;
} else { }
else {
final Game game = source.getGame(); final Game game = source.getGame();
final String s = this + " - destroy"; final String s = this + " - destroy";
final int amount = this.getAmountOfKeyword("When CARDNAME is dealt damage, destroy it."); final int amount = this.getAmountOfKeyword("When CARDNAME is dealt damage, destroy it.");
if(amount > 0) { if (amount > 0) {
final Ability abDestroy = new Ability(source, ManaCost.ZERO){ final Ability abDestroy = new Ability(source, ManaCost.ZERO){
@Override public void resolve() { game.getAction().destroy(Card.this, this); } @Override public void resolve() { game.getAction().destroy(Card.this, this); }
}; };
@@ -7624,7 +7615,7 @@ public class Card extends GameEntity implements Comparable<Card> {
} }
final int amount2 = this.getAmountOfKeyword("When CARDNAME is dealt damage, destroy it. It can't be regenerated."); final int amount2 = this.getAmountOfKeyword("When CARDNAME is dealt damage, destroy it. It can't be regenerated.");
if( amount2 > 0 ) { if (amount2 > 0) {
final Ability abDestoryNoRegen = new Ability(source, ManaCost.ZERO){ final Ability abDestoryNoRegen = new Ability(source, ManaCost.ZERO){
@Override public void resolve() { game.getAction().destroyNoRegeneration(Card.this, this); } @Override public void resolve() { game.getAction().destroyNoRegeneration(Card.this, this); }
}; };
@@ -8575,7 +8566,7 @@ public class Card extends GameEntity implements Comparable<Card> {
} }
public void setSplitStateToPlayAbility(SpellAbility sa) { public void setSplitStateToPlayAbility(SpellAbility sa) {
if( !isSplitCard() ) return; // just in case if (!isSplitCard()) return; // just in case
// Split card support // Split card support
for (SpellAbility a : getState(CardCharacteristicName.LeftSplit).getSpellAbility()) { for (SpellAbility a : getState(CardCharacteristicName.LeftSplit).getSpellAbility()) {
if (sa == a || sa.getDescription().equals(String.format("%s (without paying its mana cost)", a.getDescription()))) { if (sa == a || sa.getDescription().equals(String.format("%s (without paying its mana cost)", a.getDescription()))) {
@@ -8589,7 +8580,7 @@ public class Card extends GameEntity implements Comparable<Card> {
return; return;
} }
} }
if ( sa.getSourceCard().hasKeyword("Fuse") ) // it's ok that such card won't change its side if (sa.getSourceCard().hasKeyword("Fuse")) // it's ok that such card won't change its side
return; return;
throw new RuntimeException("Not found which part to choose for ability " + sa + " from card " + this); throw new RuntimeException("Not found which part to choose for ability " + sa + " from card " + this);
@@ -8607,7 +8598,6 @@ public class Card extends GameEntity implements Comparable<Card> {
*/ */
@Override @Override
public Game getGame() { public Game getGame() {
Player controller = getController(); Player controller = getController();
if (null != controller) if (null != controller)
return controller.getGame(); return controller.getGame();
@@ -8655,7 +8645,6 @@ public class Card extends GameEntity implements Comparable<Card> {
return abilities; return abilities;
} }
public static Card fromPaperCard(IPaperCard pc, Player owner) { public static Card fromPaperCard(IPaperCard pc, Player owner) {
return CardFactory.getCard(pc, owner); return CardFactory.getCard(pc, owner);
} }