mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-16 10:48:00 +00:00
Code cleanup
This commit is contained in:
@@ -132,7 +132,7 @@ public class Card extends GameEntity implements Comparable<Card> {
|
|||||||
// fortifying size will always be 0 or 1
|
// fortifying size will always be 0 or 1
|
||||||
// if this card is of the type fortification, what card is it currently fortifying?
|
// if this card is of the type fortification, what card is it currently fortifying?
|
||||||
private ArrayList<Card> fortifying = new ArrayList<Card>();
|
private ArrayList<Card> fortifying = new ArrayList<Card>();
|
||||||
|
|
||||||
// which auras enchanted this card?
|
// which auras enchanted this card?
|
||||||
// if this card is an Aura, what Entity is it enchanting?
|
// if this card is an Aura, what Entity is it enchanting?
|
||||||
private GameEntity enchanting = null;
|
private GameEntity enchanting = null;
|
||||||
@@ -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;
|
||||||
@@ -248,7 +248,7 @@ public class Card extends GameEntity implements Comparable<Card> {
|
|||||||
|
|
||||||
// Soulbond pairing card
|
// Soulbond pairing card
|
||||||
private Card pairedWith = null;
|
private Card pairedWith = null;
|
||||||
|
|
||||||
// Zone-changing spells should store card's zone here
|
// Zone-changing spells should store card's zone here
|
||||||
private Zone currentZone = null;
|
private Zone currentZone = null;
|
||||||
|
|
||||||
@@ -484,11 +484,11 @@ public class Card extends GameEntity implements Comparable<Card> {
|
|||||||
public final boolean isFlipCard() {
|
public final boolean isFlipCard() {
|
||||||
return characteristicsMap.containsKey(CardCharacteristicName.Flipped);
|
return characteristicsMap.containsKey(CardCharacteristicName.Flipped);
|
||||||
}
|
}
|
||||||
|
|
||||||
public final boolean isSplitCard() {
|
public final boolean isSplitCard() {
|
||||||
return characteristicsMap.containsKey(CardCharacteristicName.LeftSplit);
|
return characteristicsMap.containsKey(CardCharacteristicName.LeftSplit);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Checks if is cloned.
|
* Checks if is cloned.
|
||||||
*
|
*
|
||||||
@@ -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);
|
||||||
@@ -1457,7 +1457,7 @@ public class Card extends GameEntity implements Comparable<Card> {
|
|||||||
public final ManaCost getManaCost() {
|
public final ManaCost getManaCost() {
|
||||||
return this.getCharacteristics().getManaCost();
|
return this.getCharacteristics().getManaCost();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* <p>
|
* <p>
|
||||||
@@ -1562,9 +1562,9 @@ 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,14 +2106,14 @@ 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));
|
||||||
} else if (keyword.equals("Unblockable")) {
|
} else if (keyword.equals("Unblockable")) {
|
||||||
sbLong.append(this.getName()).append(" can't be blocked.\r\n");
|
sbLong.append(this.getName()).append(" can't be blocked.\r\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
else {
|
else {
|
||||||
if ((i != 0) && (sb.length() != 0)) {
|
if ((i != 0) && (sb.length() != 0)) {
|
||||||
sb.append(", ");
|
sb.append(", ");
|
||||||
@@ -2148,13 +2148,13 @@ public class Card extends GameEntity implements Comparable<Card> {
|
|||||||
boolean negative = true;
|
boolean negative = true;
|
||||||
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;
|
||||||
}
|
}
|
||||||
@@ -2166,74 +2166,74 @@ public class Card extends GameEntity implements Comparable<Card> {
|
|||||||
|
|
||||||
final boolean allNegative = negative;
|
final boolean allNegative = negative;
|
||||||
final String byClause = allNegative ? "except by " : "by ";
|
final String byClause = allNegative ? "except by " : "by ";
|
||||||
|
|
||||||
final Function<Pair<Boolean, String>, String> withToString = new Function<Pair<Boolean, String>, String>() {
|
final Function<Pair<Boolean, String>, String> withToString = new Function<Pair<Boolean, String>, String>() {
|
||||||
@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");
|
||||||
}
|
}
|
||||||
|
|
||||||
sbShort.append(" with ");
|
sbShort.append(" with ");
|
||||||
sbShort.append(Lang.joinHomogenous(postponedAdjectives, withToString, allNegative ? "or" : "and"));
|
sbShort.append(Lang.joinHomogenous(postponedAdjectives, withToString, allNegative ? "or" : "and"));
|
||||||
}
|
}
|
||||||
|
|
||||||
} 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"));
|
||||||
}
|
}
|
||||||
@@ -2980,8 +2980,7 @@ public class Card extends GameEntity implements Comparable<Card> {
|
|||||||
public final void addChangeControllerCommand(final Command c) {
|
public final void addChangeControllerCommand(final Command c) {
|
||||||
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();
|
||||||
@@ -3039,7 +3038,6 @@ public class Card extends GameEntity implements Comparable<Card> {
|
|||||||
public void setBecameTargetThisTurn(boolean becameTargetThisTurn) {
|
public void setBecameTargetThisTurn(boolean becameTargetThisTurn) {
|
||||||
this.becameTargetThisTurn = becameTargetThisTurn;
|
this.becameTargetThisTurn = becameTargetThisTurn;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return the startedTheTurnUntapped
|
* @return the startedTheTurnUntapped
|
||||||
@@ -3054,7 +3052,6 @@ public class Card extends GameEntity implements Comparable<Card> {
|
|||||||
public void setStartedTheTurnUntapped(boolean untapped) {
|
public void setStartedTheTurnUntapped(boolean untapped) {
|
||||||
this.startedTheTurnUntapped = untapped;
|
this.startedTheTurnUntapped = untapped;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* <p>
|
* <p>
|
||||||
@@ -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() {
|
||||||
@@ -3310,13 +3306,13 @@ public class Card extends GameEntity implements Comparable<Card> {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Card oldTarget = null;
|
Card oldTarget = null;
|
||||||
if (this.isEquipping()) {
|
if (this.isEquipping()) {
|
||||||
oldTarget = this.getEquipping().get(0);
|
oldTarget = this.getEquipping().get(0);
|
||||||
this.unEquipCard(oldTarget);
|
this.unEquipCard(oldTarget);
|
||||||
}
|
}
|
||||||
|
|
||||||
// They use double links... it's doubtful
|
// They use double links... it's doubtful
|
||||||
this.equipping.add(c);
|
this.equipping.add(c);
|
||||||
this.setTimestamp(this.getGame().getNextTimestamp());
|
this.setTimestamp(this.getGame().getNextTimestamp());
|
||||||
@@ -3324,7 +3320,7 @@ public class Card extends GameEntity implements Comparable<Card> {
|
|||||||
|
|
||||||
// Play the Equip sound
|
// Play the Equip sound
|
||||||
getGame().fireEvent(new GameEventCardAttachment(this, oldTarget, c, AttachMethod.Equip));
|
getGame().fireEvent(new GameEventCardAttachment(this, oldTarget, c, AttachMethod.Equip));
|
||||||
|
|
||||||
// run trigger
|
// run trigger
|
||||||
final HashMap<String, Object> runParams = new HashMap<String, Object>();
|
final HashMap<String, Object> runParams = new HashMap<String, Object>();
|
||||||
runParams.put("AttachSource", this);
|
runParams.put("AttachSource", this);
|
||||||
@@ -3347,7 +3343,7 @@ public class Card extends GameEntity implements Comparable<Card> {
|
|||||||
oldTarget = this.getFortifying().get(0);
|
oldTarget = this.getFortifying().get(0);
|
||||||
this.unFortifyCard(oldTarget);
|
this.unFortifyCard(oldTarget);
|
||||||
}
|
}
|
||||||
|
|
||||||
this.fortifying.add(c);
|
this.fortifying.add(c);
|
||||||
this.setTimestamp(this.getGame().getNextTimestamp());
|
this.setTimestamp(this.getGame().getNextTimestamp());
|
||||||
c.fortifiedBy.add(this);
|
c.fortifiedBy.add(this);
|
||||||
@@ -3369,13 +3365,12 @@ 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);
|
||||||
|
|
||||||
getGame().fireEvent(new GameEventCardAttachment(this, c, null, AttachMethod.Equip));
|
getGame().fireEvent(new GameEventCardAttachment(this, c, null, AttachMethod.Equip));
|
||||||
|
|
||||||
// Run triggers
|
// Run triggers
|
||||||
final Map<String, Object> runParams = new TreeMap<String, Object>();
|
final Map<String, Object> runParams = new TreeMap<String, Object>();
|
||||||
runParams.put("Equipment", this);
|
runParams.put("Equipment", this);
|
||||||
@@ -3394,7 +3389,7 @@ public class Card extends GameEntity implements Comparable<Card> {
|
|||||||
public final void unFortifyCard(final Card c) { // fortification.unEquipCard(fortifiedCard);
|
public final void unFortifyCard(final Card c) { // fortification.unEquipCard(fortifiedCard);
|
||||||
this.fortifying.remove(c);
|
this.fortifying.remove(c);
|
||||||
c.fortifiedBy.remove(this);
|
c.fortifiedBy.remove(this);
|
||||||
|
|
||||||
getGame().fireEvent(new GameEventCardAttachment(this, c, null, AttachMethod.Fortify));
|
getGame().fireEvent(new GameEventCardAttachment(this, c, null, AttachMethod.Fortify));
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -3543,7 +3538,7 @@ public class Card extends GameEntity implements Comparable<Card> {
|
|||||||
this.enchanting = entity;
|
this.enchanting = entity;
|
||||||
this.setTimestamp(this.getGame().getNextTimestamp());
|
this.setTimestamp(this.getGame().getNextTimestamp());
|
||||||
entity.addEnchantedBy(this);
|
entity.addEnchantedBy(this);
|
||||||
|
|
||||||
getGame().fireEvent(new GameEventCardAttachment(this, null, entity, AttachMethod.Enchant));
|
getGame().fireEvent(new GameEventCardAttachment(this, null, entity, AttachMethod.Enchant));
|
||||||
|
|
||||||
// run trigger
|
// run trigger
|
||||||
@@ -3636,7 +3631,6 @@ public class Card extends GameEntity implements Comparable<Card> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
return newType;
|
return newType;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -3945,11 +3939,11 @@ public class Card extends GameEntity implements Comparable<Card> {
|
|||||||
total += this.getTempAttackBoost() + this.getSemiPermanentAttackBoost() + getPowerBonusFromCounters();
|
total += this.getTempAttackBoost() + this.getSemiPermanentAttackBoost() + getPowerBonusFromCounters();
|
||||||
return total;
|
return total;
|
||||||
}
|
}
|
||||||
|
|
||||||
public final int getPowerBonusFromCounters() {
|
public final int getPowerBonusFromCounters() {
|
||||||
int total = 0;
|
int total = 0;
|
||||||
|
|
||||||
total += this.getCounters(CounterType.P1P1) + this.getCounters(CounterType.P1P2) + this.getCounters(CounterType.P1P0)
|
total += this.getCounters(CounterType.P1P1) + this.getCounters(CounterType.P1P2) + this.getCounters(CounterType.P1P0)
|
||||||
- this.getCounters(CounterType.M1M1) + 2 * this.getCounters(CounterType.P2P2) - 2 * this.getCounters(CounterType.M2M1)
|
- this.getCounters(CounterType.M1M1) + 2 * this.getCounters(CounterType.P2P2) - 2 * this.getCounters(CounterType.M2M1)
|
||||||
- 2 * this.getCounters(CounterType.M2M2) - this.getCounters(CounterType.M1M0) + 2 * this.getCounters(CounterType.P2P0);
|
- 2 * this.getCounters(CounterType.M2M2) - this.getCounters(CounterType.M1M0) + 2 * this.getCounters(CounterType.P2P0);
|
||||||
return total;
|
return total;
|
||||||
@@ -3999,7 +3993,7 @@ public class Card extends GameEntity implements Comparable<Card> {
|
|||||||
total += this.getTempDefenseBoost() + this.getSemiPermanentDefenseBoost() + getToughnessBonusFromCounters();
|
total += this.getTempDefenseBoost() + this.getSemiPermanentDefenseBoost() + getToughnessBonusFromCounters();
|
||||||
return total;
|
return total;
|
||||||
}
|
}
|
||||||
|
|
||||||
public final int getToughnessBonusFromCounters() {
|
public final int getToughnessBonusFromCounters() {
|
||||||
int total = 0;
|
int total = 0;
|
||||||
|
|
||||||
@@ -4046,11 +4040,11 @@ public class Card extends GameEntity implements Comparable<Card> {
|
|||||||
private int multiKickerMagnitude = 0;
|
private int multiKickerMagnitude = 0;
|
||||||
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;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -4214,7 +4208,7 @@ public class Card extends GameEntity implements Comparable<Card> {
|
|||||||
public final void tap() {
|
public final void tap() {
|
||||||
if (this.isTapped())
|
if (this.isTapped())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
// Run triggers
|
// Run triggers
|
||||||
final Map<String, Object> runParams = new TreeMap<String, Object>();
|
final Map<String, Object> runParams = new TreeMap<String, Object>();
|
||||||
runParams.put("Card", this);
|
runParams.put("Card", this);
|
||||||
@@ -4236,7 +4230,7 @@ public class Card extends GameEntity implements Comparable<Card> {
|
|||||||
final HashMap<String, Object> repRunParams = new HashMap<String, Object>();
|
final HashMap<String, Object> repRunParams = new HashMap<String, Object>();
|
||||||
repRunParams.put("Event", "Untap");
|
repRunParams.put("Event", "Untap");
|
||||||
repRunParams.put("Affected", this);
|
repRunParams.put("Affected", this);
|
||||||
|
|
||||||
if (getGame().getReplacementHandler().run(repRunParams) != ReplacementResult.NotReplaced) {
|
if (getGame().getReplacementHandler().run(repRunParams) != ReplacementResult.NotReplaced) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -4301,7 +4295,7 @@ public class Card extends GameEntity implements Comparable<Card> {
|
|||||||
*/
|
*/
|
||||||
public final void addChangedCardKeywords(final List<String> keywords, final List<String> removeKeywords,
|
public final void addChangedCardKeywords(final List<String> keywords, final List<String> removeKeywords,
|
||||||
final boolean removeAllKeywords, final long timestamp) {
|
final boolean removeAllKeywords, final long timestamp) {
|
||||||
|
|
||||||
// if the key already exists - merge entries
|
// if the key already exists - merge entries
|
||||||
if (changedCardKeywords.containsKey(timestamp)) {
|
if (changedCardKeywords.containsKey(timestamp)) {
|
||||||
List<String> kws = keywords;
|
List<String> kws = keywords;
|
||||||
@@ -4687,15 +4681,12 @@ public class Card extends GameEntity implements Comparable<Card> {
|
|||||||
public final boolean isEquipment() { return this.typeContains("Equipment"); }
|
public final boolean isEquipment() { return this.typeContains("Equipment"); }
|
||||||
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")) {
|
||||||
@@ -5603,7 +5594,7 @@ public class Card extends GameEntity implements Comparable<Card> {
|
|||||||
final String restriction = property.substring(10);
|
final String restriction = property.substring(10);
|
||||||
if (restriction.equals("Remembered")) {
|
if (restriction.equals("Remembered")) {
|
||||||
for (final Object rem : source.getRemembered()) {
|
for (final Object rem : source.getRemembered()) {
|
||||||
if (!(rem instanceof Card) || !((Card) rem).canBeEnchantedBy(this))
|
if (!(rem instanceof Card) || !((Card) rem).canBeEnchantedBy(this))
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
} else if (restriction.equals("Source")) {
|
} else if (restriction.equals("Source")) {
|
||||||
@@ -5648,7 +5639,7 @@ public class Card extends GameEntity implements Comparable<Card> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else if (property.substring(10).equals("Enchanted")) {
|
} else if (property.substring(10).equals("Enchanted")) {
|
||||||
if (source.getEnchantingCard() == null ||
|
if (source.getEnchantingCard() == null ||
|
||||||
!this.equippedBy.contains(source.getEnchantingCard())) {
|
!this.equippedBy.contains(source.getEnchantingCard())) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@@ -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;
|
||||||
@@ -6105,7 +6096,7 @@ public class Card extends GameEntity implements Comparable<Card> {
|
|||||||
} else {
|
} else {
|
||||||
final String restriction = property.split("sharesTypeWith ")[1];
|
final String restriction = property.split("sharesTypeWith ")[1];
|
||||||
if (restriction.equals("FirstImprinted")) {
|
if (restriction.equals("FirstImprinted")) {
|
||||||
if (source.getImprinted().isEmpty() ||
|
if (source.getImprinted().isEmpty() ||
|
||||||
!this.sharesTypeWith(source.getImprinted().get(0))) {
|
!this.sharesTypeWith(source.getImprinted().get(0))) {
|
||||||
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 {
|
||||||
@@ -6813,7 +6804,7 @@ public class Card extends GameEntity implements Comparable<Card> {
|
|||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* <p>
|
* <p>
|
||||||
* sharesControllerWith.
|
* sharesControllerWith.
|
||||||
@@ -6828,7 +6819,7 @@ public class Card extends GameEntity implements Comparable<Card> {
|
|||||||
if (c1 == null) {
|
if (c1 == null) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
return this.getController().equals(c1.getController());
|
return this.getController().equals(c1.getController());
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -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,15 +7596,15 @@ 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); }
|
||||||
};
|
};
|
||||||
abDestroy.setStackDescription(s + ", it cannot be regenerated.");
|
abDestroy.setStackDescription(s + ", it cannot be regenerated.");
|
||||||
@@ -7622,19 +7613,19 @@ public class Card extends GameEntity implements Comparable<Card> {
|
|||||||
game.getStack().addSimultaneousStackEntry(abDestroy);
|
game.getStack().addSimultaneousStackEntry(abDestroy);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
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); }
|
||||||
};
|
};
|
||||||
abDestoryNoRegen.setStackDescription(s);
|
abDestoryNoRegen.setStackDescription(s);
|
||||||
|
|
||||||
for (int i = 0; i < amount2; i++) {
|
for (int i = 0; i < amount2; i++) {
|
||||||
game.getStack().addSimultaneousStackEntry(abDestoryNoRegen);
|
game.getStack().addSimultaneousStackEntry(abDestoryNoRegen);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
boolean wither = (getGame().getStaticEffects().getGlobalRuleChange(GlobalRuleChange.alwaysWither)
|
boolean wither = (getGame().getStaticEffects().getGlobalRuleChange(GlobalRuleChange.alwaysWither)
|
||||||
|| source.hasKeyword("Wither") || source.hasKeyword("Infect"));
|
|| source.hasKeyword("Wither") || source.hasKeyword("Infect"));
|
||||||
|
|
||||||
@@ -7645,11 +7636,11 @@ public class Card extends GameEntity implements Comparable<Card> {
|
|||||||
} else
|
} else
|
||||||
this.damage += damageToAdd;
|
this.damage += damageToAdd;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (source.hasKeyword("Deathtouch") && this.isCreature()) {
|
if (source.hasKeyword("Deathtouch") && this.isCreature()) {
|
||||||
getGame().getAction().destroy(this, null);
|
getGame().getAction().destroy(this, null);
|
||||||
damageType = DamageType.Deathtouch;
|
damageType = DamageType.Deathtouch;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Play the Damage sound
|
// Play the Damage sound
|
||||||
game.fireEvent(new GameEventCardDamaged(this, source, damageToAdd, damageType));
|
game.fireEvent(new GameEventCardDamaged(this, source, damageToAdd, damageType));
|
||||||
@@ -7695,7 +7686,7 @@ public class Card extends GameEntity implements Comparable<Card> {
|
|||||||
public final void setRarity(CardRarity r) {
|
public final void setRarity(CardRarity r) {
|
||||||
this.getCharacteristics().setRarity(r);
|
this.getCharacteristics().setRarity(r);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* <p>
|
* <p>
|
||||||
* getMostRecentSet.
|
* getMostRecentSet.
|
||||||
@@ -7714,11 +7705,11 @@ public class Card extends GameEntity implements Comparable<Card> {
|
|||||||
public final String getImageKey() {
|
public final String getImageKey() {
|
||||||
return this.getCharacteristics().getImageKey();
|
return this.getCharacteristics().getImageKey();
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getImageKey(CardCharacteristicName state) {
|
public String getImageKey(CardCharacteristicName state) {
|
||||||
CardCharacteristics c = this.characteristicsMap.get(state);
|
CardCharacteristics c = this.characteristicsMap.get(state);
|
||||||
return (c != null ? c.getImageKey() : "");
|
return (c != null ? c.getImageKey() : "");
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* <p>
|
* <p>
|
||||||
@@ -8027,27 +8018,27 @@ public class Card extends GameEntity implements Comparable<Card> {
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (kw.equals("Protection from white")) {
|
if (kw.equals("Protection from white")) {
|
||||||
if (source.isWhite() && !source.getName().equals("White Ward")
|
if (source.isWhite() && !source.getName().equals("White Ward")
|
||||||
&& !source.getName().contains("Pledge of Loyalty")) {
|
&& !source.getName().contains("Pledge of Loyalty")) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
} else if (kw.equals("Protection from blue")) {
|
} else if (kw.equals("Protection from blue")) {
|
||||||
if (source.isBlue() && !source.getName().equals("Blue Ward")
|
if (source.isBlue() && !source.getName().equals("Blue Ward")
|
||||||
&& !source.getName().contains("Pledge of Loyalty")) {
|
&& !source.getName().contains("Pledge of Loyalty")) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
} else if (kw.equals("Protection from black")) {
|
} else if (kw.equals("Protection from black")) {
|
||||||
if (source.isBlack() && !source.getName().equals("Black Ward")
|
if (source.isBlack() && !source.getName().equals("Black Ward")
|
||||||
&& !source.getName().contains("Pledge of Loyalty")) {
|
&& !source.getName().contains("Pledge of Loyalty")) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
} else if (kw.equals("Protection from red")) {
|
} else if (kw.equals("Protection from red")) {
|
||||||
if (source.isRed() && !source.getName().equals("Red Ward")
|
if (source.isRed() && !source.getName().equals("Red Ward")
|
||||||
&& !source.getName().contains("Pledge of Loyalty")) {
|
&& !source.getName().contains("Pledge of Loyalty")) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
} else if (kw.equals("Protection from green")) {
|
} else if (kw.equals("Protection from green")) {
|
||||||
if (source.isGreen() && !source.getName().equals("Green Ward")
|
if (source.isGreen() && !source.getName().equals("Green Ward")
|
||||||
&& !source.getName().contains("Pledge of Loyalty")) {
|
&& !source.getName().contains("Pledge of Loyalty")) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@@ -8124,12 +8115,12 @@ public class Card extends GameEntity implements Comparable<Card> {
|
|||||||
public Zone getZone() {
|
public Zone getZone() {
|
||||||
return currentZone;
|
return currentZone;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setZone(Zone zone) {
|
public void setZone(Zone zone) {
|
||||||
currentZone = zone;
|
currentZone = zone;
|
||||||
}
|
}
|
||||||
|
|
||||||
public final boolean canBeDestroyed() {
|
public final boolean canBeDestroyed() {
|
||||||
return isInPlay() && (!hasKeyword("Indestructible") || (isCreature() && getNetDefense() <= 0));
|
return isInPlay() && (!hasKeyword("Indestructible") || (isCreature() && getNetDefense() <= 0));
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -8165,11 +8156,11 @@ public class Card extends GameEntity implements Comparable<Card> {
|
|||||||
if (this.hasProtectionFrom(sa.getSourceCard())) {
|
if (this.hasProtectionFrom(sa.getSourceCard())) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this.isPhasedOut()) {
|
if (this.isPhasedOut()) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
final Card source = sa.getSourceCard();
|
final Card source = sa.getSourceCard();
|
||||||
|
|
||||||
if (this.getKeyword() != null) {
|
if (this.getKeyword() != null) {
|
||||||
@@ -8271,7 +8262,7 @@ public class Card extends GameEntity implements Comparable<Card> {
|
|||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* canBeEquippedBy.
|
* canBeEquippedBy.
|
||||||
*
|
*
|
||||||
@@ -8328,7 +8319,7 @@ public class Card extends GameEntity implements Comparable<Card> {
|
|||||||
* the rE
|
* the rE
|
||||||
*/
|
*/
|
||||||
public ReplacementEffect addReplacementEffect(final ReplacementEffect replacementEffect) {
|
public ReplacementEffect addReplacementEffect(final ReplacementEffect replacementEffect) {
|
||||||
final ReplacementEffect replacementEffectCopy = replacementEffect.getCopy(); // doubtful - every caller provides a newly parsed instance, why copy?
|
final ReplacementEffect replacementEffectCopy = replacementEffect.getCopy(); // doubtful - every caller provides a newly parsed instance, why copy?
|
||||||
replacementEffectCopy.setHostCard(this);
|
replacementEffectCopy.setHostCard(this);
|
||||||
this.getCharacteristics().getReplacementEffects().add(replacementEffectCopy);
|
this.getCharacteristics().getReplacementEffects().add(replacementEffectCopy);
|
||||||
return replacementEffectCopy;
|
return replacementEffectCopy;
|
||||||
@@ -8475,10 +8466,10 @@ public class Card extends GameEntity implements Comparable<Card> {
|
|||||||
}
|
}
|
||||||
final Game game = this.getGame();
|
final Game game = this.getGame();
|
||||||
if (getController() == viewer && hasKeyword("You may look at this card.")) {
|
if (getController() == viewer && hasKeyword("You may look at this card.")) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
if (getController().isOpponentOf(viewer) && hasKeyword("Your opponent may look at this card.")) {
|
if (getController().isOpponentOf(viewer) && hasKeyword("Your opponent may look at this card.")) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
for (Card host : game.getCardsIn(ZoneType.Battlefield)) {
|
for (Card host : game.getCardsIn(ZoneType.Battlefield)) {
|
||||||
final ArrayList<StaticAbility> staticAbilities = host.getStaticAbilities();
|
final ArrayList<StaticAbility> staticAbilities = host.getStaticAbilities();
|
||||||
@@ -8513,14 +8504,14 @@ public class Card extends GameEntity implements Comparable<Card> {
|
|||||||
if (getGame().getCardsIn(ZoneType.Stack).contains(this) && getManaCost() != null) {
|
if (getGame().getCardsIn(ZoneType.Stack).contains(this) && getManaCost() != null) {
|
||||||
xPaid = getXManaCostPaid() * getManaCost().countX();
|
xPaid = getXManaCostPaid() * getManaCost().countX();
|
||||||
}
|
}
|
||||||
|
|
||||||
int requestedCMC = 0;
|
int requestedCMC = 0;
|
||||||
|
|
||||||
if (isSplitCard()) {
|
if (isSplitCard()) {
|
||||||
switch(mode) {
|
switch(mode) {
|
||||||
case CurrentSideCMC:
|
case CurrentSideCMC:
|
||||||
// TODO: test if this returns combined CMC for the full face (then get rid of CombinedCMC mode?)
|
// TODO: test if this returns combined CMC for the full face (then get rid of CombinedCMC mode?)
|
||||||
requestedCMC = getManaCost().getCMC() + xPaid;
|
requestedCMC = getManaCost().getCMC() + xPaid;
|
||||||
break;
|
break;
|
||||||
case LeftSplitCMC:
|
case LeftSplitCMC:
|
||||||
requestedCMC = getState(CardCharacteristicName.LeftSplit).getManaCost().getCMC() + xPaid;
|
requestedCMC = getState(CardCharacteristicName.LeftSplit).getManaCost().getCMC() + xPaid;
|
||||||
@@ -8529,7 +8520,7 @@ public class Card extends GameEntity implements Comparable<Card> {
|
|||||||
requestedCMC = getState(CardCharacteristicName.RightSplit).getManaCost().getCMC() + xPaid;
|
requestedCMC = getState(CardCharacteristicName.RightSplit).getManaCost().getCMC() + xPaid;
|
||||||
break;
|
break;
|
||||||
case CombinedCMC:
|
case CombinedCMC:
|
||||||
requestedCMC += getState(CardCharacteristicName.LeftSplit).getManaCost().getCMC();
|
requestedCMC += getState(CardCharacteristicName.LeftSplit).getManaCost().getCMC();
|
||||||
requestedCMC += getState(CardCharacteristicName.RightSplit).getManaCost().getCMC();
|
requestedCMC += getState(CardCharacteristicName.RightSplit).getManaCost().getCMC();
|
||||||
requestedCMC += xPaid;
|
requestedCMC += xPaid;
|
||||||
break;
|
break;
|
||||||
@@ -8569,13 +8560,13 @@ public class Card extends GameEntity implements Comparable<Card> {
|
|||||||
// TODO - have a field
|
// TODO - have a field
|
||||||
return this.isCommander;
|
return this.isCommander;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setCommander(boolean b) {
|
public void setCommander(boolean b) {
|
||||||
this.isCommander = b;
|
this.isCommander = b;
|
||||||
}
|
}
|
||||||
|
|
||||||
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);
|
||||||
@@ -8603,19 +8594,18 @@ public class Card extends GameEntity implements Comparable<Card> {
|
|||||||
public boolean isOptionalCostPaid(OptionalCost cost) { return costsPaid.contains(cost); }
|
public boolean isOptionalCostPaid(OptionalCost cost) { return costsPaid.contains(cost); }
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Fetch GameState for this card from references to players who may own or control this card.
|
* Fetch GameState for this card from references to players who may own or control this 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();
|
||||||
|
|
||||||
Player owner = getOwner();
|
Player owner = getOwner();
|
||||||
if (null != owner)
|
if (null != owner)
|
||||||
return owner.getGame();
|
return owner.getGame();
|
||||||
|
|
||||||
throw new IllegalStateException("Card " + toString() + " has no means to determine the game it belongs to!");
|
throw new IllegalStateException("Card " + toString() + " has no means to determine the game it belongs to!");
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -8628,7 +8618,7 @@ public class Card extends GameEntity implements Comparable<Card> {
|
|||||||
*/
|
*/
|
||||||
public List<SpellAbility> getAllPossibleAbilities(Player player, boolean removeUnplayable) {
|
public List<SpellAbility> getAllPossibleAbilities(Player player, boolean removeUnplayable) {
|
||||||
// this can only be called by the Human
|
// this can only be called by the Human
|
||||||
|
|
||||||
final List<SpellAbility> abilities = new ArrayList<SpellAbility>();
|
final List<SpellAbility> abilities = new ArrayList<SpellAbility>();
|
||||||
for (SpellAbility sa : getSpellAbilities()) {
|
for (SpellAbility sa : getSpellAbilities()) {
|
||||||
//add alternative costs as additional spell abilities
|
//add alternative costs as additional spell abilities
|
||||||
@@ -8646,15 +8636,14 @@ public class Card extends GameEntity implements Comparable<Card> {
|
|||||||
abilities.remove(i);
|
abilities.remove(i);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isLand() && player.canPlayLand(this)) {
|
if (isLand() && player.canPlayLand(this)) {
|
||||||
Ability.PLAY_LAND_SURROGATE.setSourceCard(this);
|
Ability.PLAY_LAND_SURROGATE.setSourceCard(this);
|
||||||
abilities.add(Ability.PLAY_LAND_SURROGATE);
|
abilities.add(Ability.PLAY_LAND_SURROGATE);
|
||||||
}
|
}
|
||||||
|
|
||||||
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);
|
||||||
@@ -8665,20 +8654,20 @@ public class Card extends GameEntity implements Comparable<Card> {
|
|||||||
if (pc instanceof PaperCard) {
|
if (pc instanceof PaperCard) {
|
||||||
Card res = cp2card.get(pc);
|
Card res = cp2card.get(pc);
|
||||||
if (res == null) {
|
if (res == null) {
|
||||||
res = fromPaperCard(pc, null);
|
res = fromPaperCard(pc, null);
|
||||||
cp2card.put((PaperCard) pc, res);
|
cp2card.put((PaperCard) pc, res);
|
||||||
}
|
}
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
return fromPaperCard(pc, null);
|
return fromPaperCard(pc, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Fetch from Forge's Card instance. Well, there should be no errors, but
|
// Fetch from Forge's Card instance. Well, there should be no errors, but
|
||||||
// we'll still check
|
// we'll still check
|
||||||
public PaperCard getPaperCard() {
|
public PaperCard getPaperCard() {
|
||||||
final String name = getName();
|
final String name = getName();
|
||||||
final String set = getCurSetCode();
|
final String set = getCurSetCode();
|
||||||
|
|
||||||
if (StringUtils.isNotBlank(set)) {
|
if (StringUtils.isNotBlank(set)) {
|
||||||
PaperCard cp = Singletons.getMagicDb().getVariantCards().tryGetCard(name, set);
|
PaperCard cp = Singletons.getMagicDb().getVariantCards().tryGetCard(name, set);
|
||||||
return cp == null ? Singletons.getMagicDb().getCommonCards().getCard(name, set) : cp;
|
return cp == null ? Singletons.getMagicDb().getCommonCards().getCard(name, set) : cp;
|
||||||
|
|||||||
Reference in New Issue
Block a user