mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-16 02:38:02 +00:00
Break out card detail formatting into shared utility class
This commit is contained in:
1
.gitattributes
vendored
1
.gitattributes
vendored
@@ -16114,6 +16114,7 @@ forge-gui/src/main/java/forge/UiCommand.java svneol=native#text/plain
|
||||
forge-gui/src/main/java/forge/assets/FSkinProp.java -text
|
||||
forge-gui/src/main/java/forge/assets/ISkinImage.java -text
|
||||
forge-gui/src/main/java/forge/assets/ImageUtil.java -text
|
||||
forge-gui/src/main/java/forge/card/CardDetailUtil.java -text
|
||||
forge-gui/src/main/java/forge/card/CardPreferences.java -text
|
||||
forge-gui/src/main/java/forge/card/CardReaderExperiments.java -text
|
||||
forge-gui/src/main/java/forge/card/CardScriptInfo.java -text
|
||||
|
||||
@@ -20,23 +20,17 @@ package forge.gui;
|
||||
|
||||
import forge.Singletons;
|
||||
import forge.card.CardCharacteristicName;
|
||||
import forge.card.CardDetailUtil;
|
||||
import forge.card.CardEdition;
|
||||
import forge.card.CardType;
|
||||
import forge.card.ColorSet;
|
||||
import forge.game.GameEntity;
|
||||
import forge.game.card.Card;
|
||||
import forge.game.card.CardUtil;
|
||||
import forge.game.card.CounterType;
|
||||
import forge.game.player.Player;
|
||||
import forge.game.zone.ZoneType;
|
||||
import forge.item.IPaperCard;
|
||||
import forge.item.InventoryItemFromSet;
|
||||
import forge.item.PreconDeck;
|
||||
import forge.item.SealedProduct;
|
||||
import forge.model.FModel;
|
||||
import forge.toolbox.*;
|
||||
import forge.toolbox.FSkin.SkinnedPanel;
|
||||
import forge.util.Lang;
|
||||
import forge.view.FDialog;
|
||||
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
@@ -45,8 +39,6 @@ import javax.swing.*;
|
||||
import javax.swing.border.EmptyBorder;
|
||||
|
||||
import java.awt.*;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Iterator;
|
||||
|
||||
/**
|
||||
* The class CardDetailPanel. Shows the details of a card.
|
||||
@@ -127,20 +119,12 @@ public class CardDetailPanel extends SkinnedPanel {
|
||||
this.scrArea.setBounds(0, y, getWidth(), getHeight() - y);
|
||||
}
|
||||
|
||||
public String getItemDescription(InventoryItemFromSet i) {
|
||||
if( i instanceof SealedProduct )
|
||||
return ((SealedProduct)i).getDescription();
|
||||
if( i instanceof PreconDeck)
|
||||
return ((PreconDeck) i).getDescription();
|
||||
return i.getName();
|
||||
}
|
||||
|
||||
public final void setItem(InventoryItemFromSet item) {
|
||||
nameCostLabel.setText(item.getName());
|
||||
typeLabel.setVisible(false);
|
||||
powerToughnessLabel.setVisible(false);
|
||||
idLabel.setText("");
|
||||
cdArea.setText(getItemDescription(item));
|
||||
cdArea.setText(CardDetailUtil.getItemDescription(item));
|
||||
this.updateBorder(item instanceof IPaperCard ? ((IPaperCard)item).getRules().getColor() : null, false);
|
||||
|
||||
String set = item.getEdition();
|
||||
@@ -208,7 +192,7 @@ public class CardDetailPanel extends SkinnedPanel {
|
||||
}
|
||||
this.nameCostLabel.setText(FSkin.encodeSymbols(card.getName() + " - " + manaCost, true));
|
||||
}
|
||||
this.typeLabel.setText(formatCardType(card));
|
||||
this.typeLabel.setText(CardDetailUtil.formatCardType(card));
|
||||
|
||||
String set = card.getCurSetCode();
|
||||
this.setInfoLabel.setText(set);
|
||||
@@ -259,32 +243,12 @@ public class CardDetailPanel extends SkinnedPanel {
|
||||
|
||||
this.updateBorder(CardUtil.getColors(card), canShowThis);
|
||||
|
||||
StringBuilder ptText = new StringBuilder();
|
||||
if (card.isCreature()) {
|
||||
ptText.append(card.getNetAttack()).append(" / ").append(card.getNetDefense());
|
||||
}
|
||||
this.powerToughnessLabel.setText(CardDetailUtil.formatPowerToughness(card));
|
||||
|
||||
if (card.isPlaneswalker()) {
|
||||
if (ptText.length() > 0) {
|
||||
ptText.insert(0, "P/T: ");
|
||||
ptText.append(" - ").append("Loy: ");
|
||||
} else {
|
||||
ptText.append("Loyalty: ");
|
||||
}
|
||||
|
||||
int loyalty = card.getCounters(CounterType.LOYALTY);
|
||||
if (loyalty == 0) {
|
||||
loyalty = card.getBaseLoyalty();
|
||||
}
|
||||
ptText.append(loyalty);
|
||||
}
|
||||
|
||||
this.powerToughnessLabel.setText(ptText.toString());
|
||||
|
||||
this.idLabel.setText(card.getUniqueNumber() > 0 ? "[" + card.getUniqueNumber() + "]" : "");
|
||||
this.idLabel.setText(CardDetailUtil.formatCardId(card));
|
||||
|
||||
// fill the card text
|
||||
this.cdArea.setText(composeCardText(card, canShowThis));
|
||||
this.cdArea.setText(FSkin.encodeSymbols(CardDetailUtil.composeCardText(card, canShowThis), true));
|
||||
|
||||
SwingUtilities.invokeLater(new Runnable() {
|
||||
@Override
|
||||
@@ -294,292 +258,6 @@ public class CardDetailPanel extends SkinnedPanel {
|
||||
});
|
||||
}
|
||||
|
||||
private String composeCardText(final Card card, final boolean canShow) {
|
||||
final StringBuilder area = new StringBuilder();
|
||||
|
||||
// Token
|
||||
if (card.isToken()) {
|
||||
area.append("Token");
|
||||
}
|
||||
|
||||
if (canShow) {
|
||||
// card text
|
||||
if (area.length() != 0) {
|
||||
area.append("\n");
|
||||
}
|
||||
String text = card.getText();
|
||||
// LEVEL [0-9]+-[0-9]+
|
||||
// LEVEL [0-9]+\+
|
||||
|
||||
String regex = "LEVEL [0-9]+-[0-9]+ ";
|
||||
text = text.replaceAll(regex, "$0\r\n");
|
||||
|
||||
regex = "LEVEL [0-9]+\\+ ";
|
||||
text = text.replaceAll(regex, "\r\n$0\r\n");
|
||||
|
||||
// displays keywords that have dots in them a little better:
|
||||
regex = "\\., ";
|
||||
text = text.replaceAll(regex, ".\r\n");
|
||||
|
||||
area.append(text);
|
||||
}
|
||||
|
||||
if (card.isPhasedOut()) {
|
||||
if (area.length() != 0) {
|
||||
area.append("\n");
|
||||
}
|
||||
area.append("Phased Out");
|
||||
}
|
||||
|
||||
// counter text
|
||||
final CounterType[] counters = CounterType.values();
|
||||
for (final CounterType counter : counters) {
|
||||
if (card.getCounters(counter) != 0) {
|
||||
if (area.length() != 0) {
|
||||
area.append("\n");
|
||||
}
|
||||
area.append(counter.getName() + " counters: ");
|
||||
area.append(card.getCounters(counter));
|
||||
}
|
||||
}
|
||||
|
||||
if (card.isCreature()) {
|
||||
int damage = card.getDamage();
|
||||
if (damage > 0) {
|
||||
if (area.length() != 0) {
|
||||
area.append("\n");
|
||||
}
|
||||
area.append("Damage: " + damage);
|
||||
}
|
||||
int assigned = card.getTotalAssignedDamage();
|
||||
if (assigned > 0) {
|
||||
if (area.length() != 0) {
|
||||
area.append("\n");
|
||||
}
|
||||
area.append("Assigned Damage: " + assigned);
|
||||
}
|
||||
}
|
||||
if (card.isPlaneswalker()) {
|
||||
int assigned = card.getTotalAssignedDamage();
|
||||
if (assigned > 0) {
|
||||
if (area.length() != 0) {
|
||||
area.append("\n");
|
||||
}
|
||||
area.append("Assigned Damage: " + assigned);
|
||||
}
|
||||
}
|
||||
|
||||
// Regeneration Shields
|
||||
final int regenShields = card.getShield().size();
|
||||
if (regenShields > 0) {
|
||||
if (area.length() != 0) {
|
||||
area.append("\n");
|
||||
}
|
||||
area.append("Regeneration Shield(s): ").append(regenShields);
|
||||
}
|
||||
|
||||
// Damage Prevention
|
||||
final int preventNextDamage = card.getPreventNextDamageTotalShields();
|
||||
if (preventNextDamage > 0) {
|
||||
area.append("\n");
|
||||
area.append("Prevent the next ").append(preventNextDamage).append(" damage that would be dealt to ");
|
||||
area.append(card.getName()).append(" this turn.");
|
||||
}
|
||||
|
||||
// top revealed
|
||||
if ((card.hasKeyword("Play with the top card of your library revealed.") || card
|
||||
.hasKeyword("Players play with the top card of their libraries revealed."))
|
||||
&& card.getController() != null
|
||||
&& (card.isInZone(ZoneType.Battlefield) || (card.isInZone(ZoneType.Command) && !card.isCommander()))
|
||||
&& !card.getController().getZone(ZoneType.Library).isEmpty()) {
|
||||
area.append("\r\nTop card of your library: ");
|
||||
area.append(card.getController().getCardsIn(ZoneType.Library, 1));
|
||||
if (card.hasKeyword("Players play with the top card of their libraries revealed.")) {
|
||||
for (final Player p : card.getController().getAllOtherPlayers()) {
|
||||
if (p.getZone(ZoneType.Library).isEmpty()) {
|
||||
area.append(p.getName());
|
||||
area.append("'s library is empty.");
|
||||
} else {
|
||||
area.append("\r\nTop card of ");
|
||||
area.append(p.getName());
|
||||
area.append("'s library: ");
|
||||
area.append(p.getCardsIn(ZoneType.Library, 1));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// chosen type
|
||||
if (!card.getChosenType().equals("")) {
|
||||
if (area.length() != 0) {
|
||||
area.append("\n");
|
||||
}
|
||||
area.append("(chosen type: ");
|
||||
area.append(card.getChosenType());
|
||||
area.append(")");
|
||||
}
|
||||
|
||||
// chosen color
|
||||
if (!card.getChosenColor().isEmpty()) {
|
||||
if (area.length() != 0) {
|
||||
area.append("\n");
|
||||
}
|
||||
area.append("(chosen colors: ");
|
||||
area.append(card.getChosenColor());
|
||||
area.append(")");
|
||||
}
|
||||
|
||||
// chosen player
|
||||
if (card.getChosenPlayer() != null) {
|
||||
if (area.length() != 0) {
|
||||
area.append("\n");
|
||||
}
|
||||
area.append("(chosen player: " + card.getChosenPlayer() + ")");
|
||||
}
|
||||
|
||||
// named card
|
||||
if (!card.getNamedCard().equals("")) {
|
||||
if (area.length() != 0) {
|
||||
area.append("\n");
|
||||
}
|
||||
area.append("(named card: ");
|
||||
area.append(card.getNamedCard());
|
||||
area.append(")");
|
||||
}
|
||||
|
||||
// equipping
|
||||
if (!card.getEquipping().isEmpty()) {
|
||||
if (area.length() != 0) {
|
||||
area.append("\n");
|
||||
}
|
||||
area.append("=Equipping ");
|
||||
area.append(card.getEquipping().get(0));
|
||||
area.append("=");
|
||||
}
|
||||
|
||||
// equipped by
|
||||
if (!card.getEquippedBy().isEmpty()) {
|
||||
if (area.length() != 0) {
|
||||
area.append("\n");
|
||||
}
|
||||
area.append("=Equipped by ");
|
||||
for (final Iterator<Card> it = card.getEquippedBy().iterator(); it.hasNext();) {
|
||||
area.append(it.next());
|
||||
if (it.hasNext()) {
|
||||
area.append(", ");
|
||||
}
|
||||
}
|
||||
area.append("=");
|
||||
}
|
||||
|
||||
// enchanting
|
||||
final GameEntity entity = card.getEnchanting();
|
||||
if (entity != null) {
|
||||
if (area.length() != 0) {
|
||||
area.append("\n");
|
||||
}
|
||||
area.append("*Enchanting ");
|
||||
|
||||
if (entity instanceof Card) {
|
||||
final Card c = (Card) entity;
|
||||
if (!Singletons.getControl().mayShowCard(c)) {
|
||||
area.append("Morph (");
|
||||
area.append(card.getUniqueNumber());
|
||||
area.append(")");
|
||||
} else {
|
||||
area.append(entity);
|
||||
}
|
||||
} else {
|
||||
area.append(entity);
|
||||
}
|
||||
area.append("*");
|
||||
}
|
||||
|
||||
// enchanted by
|
||||
if (!card.getEnchantedBy().isEmpty()) {
|
||||
if (area.length() != 0) {
|
||||
area.append("\n");
|
||||
}
|
||||
area.append("*Enchanted by ");
|
||||
for (final Iterator<Card> it = card.getEnchantedBy().iterator(); it.hasNext();) {
|
||||
area.append(it.next());
|
||||
if (it.hasNext()) {
|
||||
area.append(", ");
|
||||
}
|
||||
}
|
||||
area.append("*");
|
||||
}
|
||||
|
||||
// controlling
|
||||
if (card.getGainControlTargets().size() > 0) {
|
||||
if (area.length() != 0) {
|
||||
area.append("\n");
|
||||
}
|
||||
area.append("+Controlling: ");
|
||||
for (final Iterator<Card> it = card.getGainControlTargets().iterator(); it.hasNext();) {
|
||||
area.append(it.next());
|
||||
if (it.hasNext()) {
|
||||
area.append(", ");
|
||||
}
|
||||
}
|
||||
area.append("+");
|
||||
}
|
||||
|
||||
// cloned via
|
||||
if (card.getCloneOrigin() != null) {
|
||||
if (area.length() != 0) {
|
||||
area.append("\n");
|
||||
}
|
||||
area.append("^Cloned via: ");
|
||||
area.append(card.getCloneOrigin().getName());
|
||||
area.append("^");
|
||||
}
|
||||
|
||||
// Imprint
|
||||
if (!card.getImprinted().isEmpty()) {
|
||||
if (area.length() != 0) {
|
||||
area.append("\n");
|
||||
}
|
||||
area.append("Imprinting: ");
|
||||
for (final Iterator<Card> it = card.getImprinted().iterator(); it.hasNext();) {
|
||||
area.append(it.next());
|
||||
if (it.hasNext()) {
|
||||
area.append(", ");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Haunt
|
||||
if (!card.getHauntedBy().isEmpty()) {
|
||||
if (area.length() != 0) {
|
||||
area.append("\n");
|
||||
}
|
||||
area.append("Haunted by: ");
|
||||
for (final Iterator<Card> it = card.getHauntedBy().iterator(); it.hasNext();) {
|
||||
area.append(it.next());
|
||||
if (it.hasNext()) {
|
||||
area.append(", ");
|
||||
}
|
||||
}
|
||||
}
|
||||
if (card.getHaunting() != null) {
|
||||
if (area.length() != 0) {
|
||||
area.append("\n");
|
||||
}
|
||||
area.append("Haunting " + card.getHaunting());
|
||||
}
|
||||
|
||||
// must block
|
||||
if (card.getMustBlockCards() != null) {
|
||||
if (area.length() != 0) {
|
||||
area.append("\n");
|
||||
}
|
||||
String mustBlockThese = Lang.joinHomogenous(card.getMustBlockCards());
|
||||
area.append("Must block " + mustBlockThese);
|
||||
}
|
||||
return FSkin.encodeSymbols(area.toString(), true);
|
||||
}
|
||||
|
||||
/** @return FLabel */
|
||||
public FLabel getNameCostLabel() {
|
||||
return this.nameCostLabel;
|
||||
@@ -605,49 +283,6 @@ public class CardDetailPanel extends SkinnedPanel {
|
||||
return this.cdArea;
|
||||
}
|
||||
|
||||
public static String formatCardType(final Card card) {
|
||||
final ArrayList<String> list = card.getType();
|
||||
final StringBuilder sb = new StringBuilder();
|
||||
|
||||
final ArrayList<String> superTypes = new ArrayList<String>();
|
||||
final ArrayList<String> cardTypes = new ArrayList<String>();
|
||||
final ArrayList<String> subTypes = new ArrayList<String>();
|
||||
final boolean allCreatureTypes = list.contains("AllCreatureTypes");
|
||||
|
||||
for (final String t : list) {
|
||||
if (allCreatureTypes && t.equals("AllCreatureTypes")) {
|
||||
continue;
|
||||
}
|
||||
if (CardType.isASuperType(t) && !superTypes.contains(t)) {
|
||||
superTypes.add(t);
|
||||
}
|
||||
if (CardType.isACardType(t) && !cardTypes.contains(t)) {
|
||||
cardTypes.add(t);
|
||||
}
|
||||
if (CardType.isASubType(t) && !subTypes.contains(t) && (!allCreatureTypes || !CardType.isACreatureType(t))) {
|
||||
subTypes.add(t);
|
||||
}
|
||||
}
|
||||
|
||||
for (final String type : superTypes) {
|
||||
sb.append(type).append(" ");
|
||||
}
|
||||
for (final String type : cardTypes) {
|
||||
sb.append(type).append(" ");
|
||||
}
|
||||
if (!subTypes.isEmpty() || allCreatureTypes) {
|
||||
sb.append("- ");
|
||||
}
|
||||
if (allCreatureTypes) {
|
||||
sb.append("All creature types ");
|
||||
}
|
||||
for (final String type : subTypes) {
|
||||
sb.append(type).append(" ");
|
||||
}
|
||||
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
private void updateBorder(ColorSet list, final boolean canShow) {
|
||||
// color info
|
||||
if (list == null) {
|
||||
|
||||
386
forge-gui/src/main/java/forge/card/CardDetailUtil.java
Normal file
386
forge-gui/src/main/java/forge/card/CardDetailUtil.java
Normal file
@@ -0,0 +1,386 @@
|
||||
package forge.card;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Iterator;
|
||||
|
||||
import forge.GuiBase;
|
||||
import forge.game.GameEntity;
|
||||
import forge.game.card.Card;
|
||||
import forge.game.card.CounterType;
|
||||
import forge.game.player.Player;
|
||||
import forge.game.zone.ZoneType;
|
||||
import forge.item.InventoryItemFromSet;
|
||||
import forge.item.PreconDeck;
|
||||
import forge.item.SealedProduct;
|
||||
import forge.util.Lang;
|
||||
|
||||
public class CardDetailUtil {
|
||||
private CardDetailUtil() {
|
||||
}
|
||||
|
||||
public static String getItemDescription(final InventoryItemFromSet item) {
|
||||
if (item instanceof SealedProduct) {
|
||||
return ((SealedProduct)item).getDescription();
|
||||
}
|
||||
if (item instanceof PreconDeck) {
|
||||
return ((PreconDeck) item).getDescription();
|
||||
}
|
||||
return item.getName();
|
||||
}
|
||||
|
||||
public static String formatCardType(final Card card) {
|
||||
final ArrayList<String> list = card.getType();
|
||||
final StringBuilder sb = new StringBuilder();
|
||||
|
||||
final ArrayList<String> superTypes = new ArrayList<String>();
|
||||
final ArrayList<String> cardTypes = new ArrayList<String>();
|
||||
final ArrayList<String> subTypes = new ArrayList<String>();
|
||||
final boolean allCreatureTypes = list.contains("AllCreatureTypes");
|
||||
|
||||
for (final String t : list) {
|
||||
if (allCreatureTypes && t.equals("AllCreatureTypes")) {
|
||||
continue;
|
||||
}
|
||||
if (CardType.isASuperType(t) && !superTypes.contains(t)) {
|
||||
superTypes.add(t);
|
||||
}
|
||||
if (CardType.isACardType(t) && !cardTypes.contains(t)) {
|
||||
cardTypes.add(t);
|
||||
}
|
||||
if (CardType.isASubType(t) && !subTypes.contains(t) && (!allCreatureTypes || !CardType.isACreatureType(t))) {
|
||||
subTypes.add(t);
|
||||
}
|
||||
}
|
||||
|
||||
for (final String type : superTypes) {
|
||||
sb.append(type).append(" ");
|
||||
}
|
||||
for (final String type : cardTypes) {
|
||||
sb.append(type).append(" ");
|
||||
}
|
||||
if (!subTypes.isEmpty() || allCreatureTypes) {
|
||||
sb.append("- ");
|
||||
}
|
||||
if (allCreatureTypes) {
|
||||
sb.append("All creature types ");
|
||||
}
|
||||
for (final String type : subTypes) {
|
||||
sb.append(type).append(" ");
|
||||
}
|
||||
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
public static String formatPowerToughness(final Card card) {
|
||||
StringBuilder ptText = new StringBuilder();
|
||||
if (card.isCreature()) {
|
||||
ptText.append(card.getNetAttack()).append(" / ").append(card.getNetDefense());
|
||||
}
|
||||
|
||||
if (card.isPlaneswalker()) {
|
||||
if (ptText.length() > 0) {
|
||||
ptText.insert(0, "P/T: ");
|
||||
ptText.append(" - ").append("Loy: ");
|
||||
} else {
|
||||
ptText.append("Loyalty: ");
|
||||
}
|
||||
|
||||
int loyalty = card.getCounters(CounterType.LOYALTY);
|
||||
if (loyalty == 0) {
|
||||
loyalty = card.getBaseLoyalty();
|
||||
}
|
||||
ptText.append(loyalty);
|
||||
}
|
||||
return ptText.toString();
|
||||
}
|
||||
|
||||
public static String formatCardId(final Card card) {
|
||||
return card.getUniqueNumber() > 0 ? "[" + card.getUniqueNumber() + "]" : "";
|
||||
}
|
||||
|
||||
public static String composeCardText(final Card card, final boolean canShow) {
|
||||
final StringBuilder area = new StringBuilder();
|
||||
|
||||
// Token
|
||||
if (card.isToken()) {
|
||||
area.append("Token");
|
||||
}
|
||||
|
||||
if (canShow) {
|
||||
// card text
|
||||
if (area.length() != 0) {
|
||||
area.append("\n");
|
||||
}
|
||||
String text = card.getText();
|
||||
// LEVEL [0-9]+-[0-9]+
|
||||
// LEVEL [0-9]+\+
|
||||
|
||||
String regex = "LEVEL [0-9]+-[0-9]+ ";
|
||||
text = text.replaceAll(regex, "$0\r\n");
|
||||
|
||||
regex = "LEVEL [0-9]+\\+ ";
|
||||
text = text.replaceAll(regex, "\r\n$0\r\n");
|
||||
|
||||
// displays keywords that have dots in them a little better:
|
||||
regex = "\\., ";
|
||||
text = text.replaceAll(regex, ".\r\n");
|
||||
|
||||
area.append(text);
|
||||
}
|
||||
|
||||
if (card.isPhasedOut()) {
|
||||
if (area.length() != 0) {
|
||||
area.append("\n");
|
||||
}
|
||||
area.append("Phased Out");
|
||||
}
|
||||
|
||||
// counter text
|
||||
final CounterType[] counters = CounterType.values();
|
||||
for (final CounterType counter : counters) {
|
||||
if (card.getCounters(counter) != 0) {
|
||||
if (area.length() != 0) {
|
||||
area.append("\n");
|
||||
}
|
||||
area.append(counter.getName() + " counters: ");
|
||||
area.append(card.getCounters(counter));
|
||||
}
|
||||
}
|
||||
|
||||
if (card.isCreature()) {
|
||||
int damage = card.getDamage();
|
||||
if (damage > 0) {
|
||||
if (area.length() != 0) {
|
||||
area.append("\n");
|
||||
}
|
||||
area.append("Damage: " + damage);
|
||||
}
|
||||
int assigned = card.getTotalAssignedDamage();
|
||||
if (assigned > 0) {
|
||||
if (area.length() != 0) {
|
||||
area.append("\n");
|
||||
}
|
||||
area.append("Assigned Damage: " + assigned);
|
||||
}
|
||||
}
|
||||
if (card.isPlaneswalker()) {
|
||||
int assigned = card.getTotalAssignedDamage();
|
||||
if (assigned > 0) {
|
||||
if (area.length() != 0) {
|
||||
area.append("\n");
|
||||
}
|
||||
area.append("Assigned Damage: " + assigned);
|
||||
}
|
||||
}
|
||||
|
||||
// Regeneration Shields
|
||||
final int regenShields = card.getShield().size();
|
||||
if (regenShields > 0) {
|
||||
if (area.length() != 0) {
|
||||
area.append("\n");
|
||||
}
|
||||
area.append("Regeneration Shield(s): ").append(regenShields);
|
||||
}
|
||||
|
||||
// Damage Prevention
|
||||
final int preventNextDamage = card.getPreventNextDamageTotalShields();
|
||||
if (preventNextDamage > 0) {
|
||||
area.append("\n");
|
||||
area.append("Prevent the next ").append(preventNextDamage).append(" damage that would be dealt to ");
|
||||
area.append(card.getName()).append(" this turn.");
|
||||
}
|
||||
|
||||
// top revealed
|
||||
if ((card.hasKeyword("Play with the top card of your library revealed.") || card
|
||||
.hasKeyword("Players play with the top card of their libraries revealed."))
|
||||
&& card.getController() != null
|
||||
&& (card.isInZone(ZoneType.Battlefield) || (card.isInZone(ZoneType.Command) && !card.isCommander()))
|
||||
&& !card.getController().getZone(ZoneType.Library).isEmpty()) {
|
||||
area.append("\r\nTop card of your library: ");
|
||||
area.append(card.getController().getCardsIn(ZoneType.Library, 1));
|
||||
if (card.hasKeyword("Players play with the top card of their libraries revealed.")) {
|
||||
for (final Player p : card.getController().getAllOtherPlayers()) {
|
||||
if (p.getZone(ZoneType.Library).isEmpty()) {
|
||||
area.append(p.getName());
|
||||
area.append("'s library is empty.");
|
||||
} else {
|
||||
area.append("\r\nTop card of ");
|
||||
area.append(p.getName());
|
||||
area.append("'s library: ");
|
||||
area.append(p.getCardsIn(ZoneType.Library, 1));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// chosen type
|
||||
if (!card.getChosenType().equals("")) {
|
||||
if (area.length() != 0) {
|
||||
area.append("\n");
|
||||
}
|
||||
area.append("(chosen type: ");
|
||||
area.append(card.getChosenType());
|
||||
area.append(")");
|
||||
}
|
||||
|
||||
// chosen color
|
||||
if (!card.getChosenColor().isEmpty()) {
|
||||
if (area.length() != 0) {
|
||||
area.append("\n");
|
||||
}
|
||||
area.append("(chosen colors: ");
|
||||
area.append(card.getChosenColor());
|
||||
area.append(")");
|
||||
}
|
||||
|
||||
// chosen player
|
||||
if (card.getChosenPlayer() != null) {
|
||||
if (area.length() != 0) {
|
||||
area.append("\n");
|
||||
}
|
||||
area.append("(chosen player: " + card.getChosenPlayer() + ")");
|
||||
}
|
||||
|
||||
// named card
|
||||
if (!card.getNamedCard().equals("")) {
|
||||
if (area.length() != 0) {
|
||||
area.append("\n");
|
||||
}
|
||||
area.append("(named card: ");
|
||||
area.append(card.getNamedCard());
|
||||
area.append(")");
|
||||
}
|
||||
|
||||
// equipping
|
||||
if (!card.getEquipping().isEmpty()) {
|
||||
if (area.length() != 0) {
|
||||
area.append("\n");
|
||||
}
|
||||
area.append("=Equipping ");
|
||||
area.append(card.getEquipping().get(0));
|
||||
area.append("=");
|
||||
}
|
||||
|
||||
// equipped by
|
||||
if (!card.getEquippedBy().isEmpty()) {
|
||||
if (area.length() != 0) {
|
||||
area.append("\n");
|
||||
}
|
||||
area.append("=Equipped by ");
|
||||
for (final Iterator<Card> it = card.getEquippedBy().iterator(); it.hasNext();) {
|
||||
area.append(it.next());
|
||||
if (it.hasNext()) {
|
||||
area.append(", ");
|
||||
}
|
||||
}
|
||||
area.append("=");
|
||||
}
|
||||
|
||||
// enchanting
|
||||
final GameEntity entity = card.getEnchanting();
|
||||
if (entity != null) {
|
||||
if (area.length() != 0) {
|
||||
area.append("\n");
|
||||
}
|
||||
area.append("*Enchanting ");
|
||||
|
||||
if (entity instanceof Card) {
|
||||
final Card c = (Card) entity;
|
||||
if (!GuiBase.getInterface().mayShowCard(c)) {
|
||||
area.append("Morph (");
|
||||
area.append(card.getUniqueNumber());
|
||||
area.append(")");
|
||||
} else {
|
||||
area.append(entity);
|
||||
}
|
||||
} else {
|
||||
area.append(entity);
|
||||
}
|
||||
area.append("*");
|
||||
}
|
||||
|
||||
// enchanted by
|
||||
if (!card.getEnchantedBy().isEmpty()) {
|
||||
if (area.length() != 0) {
|
||||
area.append("\n");
|
||||
}
|
||||
area.append("*Enchanted by ");
|
||||
for (final Iterator<Card> it = card.getEnchantedBy().iterator(); it.hasNext();) {
|
||||
area.append(it.next());
|
||||
if (it.hasNext()) {
|
||||
area.append(", ");
|
||||
}
|
||||
}
|
||||
area.append("*");
|
||||
}
|
||||
|
||||
// controlling
|
||||
if (card.getGainControlTargets().size() > 0) {
|
||||
if (area.length() != 0) {
|
||||
area.append("\n");
|
||||
}
|
||||
area.append("+Controlling: ");
|
||||
for (final Iterator<Card> it = card.getGainControlTargets().iterator(); it.hasNext();) {
|
||||
area.append(it.next());
|
||||
if (it.hasNext()) {
|
||||
area.append(", ");
|
||||
}
|
||||
}
|
||||
area.append("+");
|
||||
}
|
||||
|
||||
// cloned via
|
||||
if (card.getCloneOrigin() != null) {
|
||||
if (area.length() != 0) {
|
||||
area.append("\n");
|
||||
}
|
||||
area.append("^Cloned via: ");
|
||||
area.append(card.getCloneOrigin().getName());
|
||||
area.append("^");
|
||||
}
|
||||
|
||||
// Imprint
|
||||
if (!card.getImprinted().isEmpty()) {
|
||||
if (area.length() != 0) {
|
||||
area.append("\n");
|
||||
}
|
||||
area.append("Imprinting: ");
|
||||
for (final Iterator<Card> it = card.getImprinted().iterator(); it.hasNext();) {
|
||||
area.append(it.next());
|
||||
if (it.hasNext()) {
|
||||
area.append(", ");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Haunt
|
||||
if (!card.getHauntedBy().isEmpty()) {
|
||||
if (area.length() != 0) {
|
||||
area.append("\n");
|
||||
}
|
||||
area.append("Haunted by: ");
|
||||
for (final Iterator<Card> it = card.getHauntedBy().iterator(); it.hasNext();) {
|
||||
area.append(it.next());
|
||||
if (it.hasNext()) {
|
||||
area.append(", ");
|
||||
}
|
||||
}
|
||||
}
|
||||
if (card.getHaunting() != null) {
|
||||
if (area.length() != 0) {
|
||||
area.append("\n");
|
||||
}
|
||||
area.append("Haunting " + card.getHaunting());
|
||||
}
|
||||
|
||||
// must block
|
||||
if (card.getMustBlockCards() != null) {
|
||||
if (area.length() != 0) {
|
||||
area.append("\n");
|
||||
}
|
||||
String mustBlockThese = Lang.joinHomogenous(card.getMustBlockCards());
|
||||
area.append("Must block " + mustBlockThese);
|
||||
}
|
||||
return area.toString();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user