Fix so Oracle Text appears on fallback image for copies

This commit is contained in:
drdev
2014-09-05 14:18:16 +00:00
parent 09221a180e
commit 162435ca52
5 changed files with 23 additions and 16 deletions

View File

@@ -116,7 +116,7 @@ public class AiAttackController {
} }
}; };
for (Card c : CardLists.filter(defender.getCardsIn(ZoneType.Battlefield), canAnimate)) { for (Card c : CardLists.filter(defender.getCardsIn(ZoneType.Battlefield), canAnimate)) {
if (c.isToken() && !c.isCopiedToken()) { if (c.isToken() && c.getCopiedPermanent() == null) {
continue; continue;
} }
for (SpellAbility sa : c.getSpellAbilities()) { for (SpellAbility sa : c.getSpellAbilities()) {

View File

@@ -152,7 +152,7 @@ public class CopyPermanentEffect extends SpellAbilityEffect {
for (int i = 0; i < multiplier; i++) { for (int i = 0; i < multiplier; i++) {
final Card copy = CardFactory.copyCopiableCharacteristics(c, sa.getActivatingPlayer()); final Card copy = CardFactory.copyCopiableCharacteristics(c, sa.getActivatingPlayer());
copy.setToken(true); copy.setToken(true);
copy.setCopiedToken(true); copy.setCopiedPermanent(c);
CardFactory.copyCopiableAbilities(c, copy); CardFactory.copyCopiableAbilities(c, copy);
// add keywords from sa // add keywords from sa
for (final String kw : keywords) { for (final String kw : keywords) {

View File

@@ -148,7 +148,7 @@ public class Card extends GameEntity implements Comparable<Card> {
private boolean tapped = false; private boolean tapped = false;
private boolean sickness = true; // summoning sickness private boolean sickness = true; // summoning sickness
private boolean token = false; private boolean token = false;
private boolean copiedToken = false; private Card copiedPermanent = null;
private boolean copiedSpell = false; private boolean copiedSpell = false;
private ArrayList<Card> mustBlockCards = null; private ArrayList<Card> mustBlockCards = null;
@@ -2921,25 +2921,25 @@ public class Card extends GameEntity implements Comparable<Card> {
/** /**
* <p> * <p>
* Setter for the field <code>copiedToken</code>. * Getter for the field <code>copiedPermanent</code>.
* </p> * </p>
* *
* @param b * @return a Card.
* a boolean.
*/ */
public final void setCopiedToken(final boolean b) { public final Card getCopiedPermanent() {
this.copiedToken = b; return this.copiedPermanent;
} }
/** /**
* <p> * <p>
* isCopiedToken. * Setter for the field <code>copiedPermanent</code>.
* </p> * </p>
* *
* @return a boolean. * @param c
* a Card.
*/ */
public final boolean isCopiedToken() { public final void setCopiedPermanent(final Card c) {
return this.copiedToken; this.copiedPermanent = c;
} }
/** /**
@@ -8939,7 +8939,7 @@ public class Card extends GameEntity implements Comparable<Card> {
} }
public int getCMC(SplitCMCMode mode) { public int getCMC(SplitCMCMode mode) {
if (isToken() && !isCopiedToken()) { if (isToken() && getCopiedPermanent() == null) {
return 0; return 0;
} }
@@ -9157,4 +9157,12 @@ public class Card extends GameEntity implements Comparable<Card> {
public Card getCardForUi() { public Card getCardForUi() {
return this; return this;
} }
public String getOracleText() {
CardRules rules = cardRules;
if (copiedPermanent != null) { //return oracle text of copied permanent if applicable
rules = copiedPermanent.getRules();
}
return rules != null ? rules.getOracleText() : "";
}
} // end Card class } // end Card class

View File

@@ -73,7 +73,7 @@ public class CardFactory {
*/ */
public final static Card copyCard(final Card in, boolean assignNewId) { public final static Card copyCard(final Card in, boolean assignNewId) {
Card out; Card out;
if (!(in.isToken() || in.isCopiedToken())) { if (!(in.isToken() || in.getCopiedPermanent() != null)) {
out = assignNewId ? getCard(in.getPaperCard(), in.getOwner()) out = assignNewId ? getCard(in.getPaperCard(), in.getOwner())
: getCard(in.getPaperCard(), in.getOwner(), in.getUniqueNumber()); : getCard(in.getPaperCard(), in.getOwner(), in.getUniqueNumber());
} else { // token } else { // token

View File

@@ -255,8 +255,7 @@ public class CardImageRenderer {
g.drawImage(image, x + (w - iconSize) / 2, y + (h - iconSize) / 2, iconSize, iconSize); g.drawImage(image, x + (w - iconSize) / 2, y + (h - iconSize) / 2, iconSize, iconSize);
} }
else { else {
if (card.getRules() == null) { return; } //this can happen with certain tokens String text = card.getOracleText();
String text = card.getRules().getOracleText();
if (StringUtils.isEmpty(text)) { return; } if (StringUtils.isEmpty(text)) { return; }
text = text.replace("\\n", "\n"); //replace new line placeholders with actual new line characters text = text.replace("\\n", "\n"); //replace new line placeholders with actual new line characters