* UI: multiple improves for adventure/split cards:

* Split cards shows left and right mana cost (in deck editor, hand, etc);
 * Adventure cards shows adventure and normal cost (in deck editor, hand, etc);
 * Adventure cards shows adventure spell name in deck editor's list;
 * Fixed missing loading cursor in deck editor searching;
This commit is contained in:
Oleg Agafonov 2020-01-07 11:49:55 +04:00
parent c4ad761ebb
commit 339c419d4b
18 changed files with 311 additions and 102 deletions

View file

@ -417,9 +417,9 @@ public class CardSelector extends javax.swing.JPanel implements ComponentListene
private void filterCards() { private void filterCards() {
FilterCard filter = buildFilter(); FilterCard filter = buildFilter();
MageFrame.getDesktop().setCursor(new Cursor(Cursor.WAIT_CURSOR));
try { try {
java.util.List<Card> filteredCards = new ArrayList<>(); java.util.List<Card> filteredCards = new ArrayList<>();
setCursor(new Cursor(Cursor.WAIT_CURSOR));
boolean chkPD = chkPennyDreadful.isSelected(); boolean chkPD = chkPennyDreadful.isSelected();
if (chkPD) { if (chkPD) {
@ -452,7 +452,7 @@ public class CardSelector extends javax.swing.JPanel implements ComponentListene
this.currentView.loadCards(new CardsView(filteredCards), sortSetting, bigCard, null, false); this.currentView.loadCards(new CardsView(filteredCards), sortSetting, bigCard, null, false);
this.cardCount.setText(String.valueOf(filteredCards.size())); this.cardCount.setText(String.valueOf(filteredCards.size()));
} finally { } finally {
setCursor(new Cursor(Cursor.DEFAULT_CURSOR)); MageFrame.getDesktop().setCursor(new Cursor(Cursor.DEFAULT_CURSOR));
} }
} }

View file

@ -212,7 +212,7 @@ public class TableModel extends AbstractTableModel implements ICardGrid {
} }
return ""; return "";
case 1: case 1:
return c.getName(); return c.getDisplayFullName(); // show full name in deck editor table, e.g. adventure with spell name
case 2: case 2:
// new svg images version // new svg images version
return ManaSymbols.getStringManaCost(c.getManaCost()); return ManaSymbols.getStringManaCost(c.getManaCost());

View file

@ -18,8 +18,6 @@ import mage.game.Game;
import mage.game.GameImpl; import mage.game.GameImpl;
import mage.game.command.Emblem; import mage.game.command.Emblem;
import mage.game.command.Plane; import mage.game.command.Plane;
import mage.game.command.emblems.AjaniAdversaryOfTyrantsEmblem;
import mage.game.command.planes.AkoumPlane;
import mage.game.match.MatchType; import mage.game.match.MatchType;
import mage.game.mulligan.Mulligan; import mage.game.mulligan.Mulligan;
import mage.game.mulligan.MulliganType; import mage.game.mulligan.MulliganType;
@ -97,6 +95,21 @@ public class TestCardRenderDialog extends MageDialog {
return cardView; return cardView;
} }
private CardView createHandCard(Game game, UUID controllerId, String code, String cardNumber, int power, int toughness, int damage) {
CardInfo cardInfo = CardRepository.instance.findCard(code, cardNumber);
ExpansionInfo setInfo = ExpansionRepository.instance.getSetByCode(code);
CardSetInfo testSet = new CardSetInfo(cardInfo.getName(), setInfo.getCode(), cardNumber, cardInfo.getRarity(),
new CardGraphicInfo(cardInfo.getFrameStyle(), cardInfo.usesVariousArt()));
Card card = CardImpl.createCard(cardInfo.getClassName(), testSet);
Set<Card> cardsList = new HashSet<>();
cardsList.add(card);
game.loadCards(cardsList, controllerId);
CardView cardView = new CardView(card);
return cardView;
}
private AbilityView createEmblem(Emblem emblem) { private AbilityView createEmblem(Emblem emblem) {
AbilityView emblemView = new AbilityView(emblem.getAbilities().get(0), emblem.getName(), new CardView(new EmblemView(emblem))); AbilityView emblemView = new AbilityView(emblem.getAbilities().get(0), emblem.getName(), new CardView(new EmblemView(emblem)));
emblemView.setName(emblem.getName()); emblemView.setName(emblem.getName());
@ -121,10 +134,17 @@ public class TestCardRenderDialog extends MageDialog {
BigCard big = new BigCard(); BigCard big = new BigCard();
CardsView view = new CardsView(); CardsView view = new CardsView();
CardView card; CardView card;
/*
card = createCard(game, player.getId(), "RNA", "263", 0, 0, 0); // mountain card = createCard(game, player.getId(), "RNA", "263", 0, 0, 0); // mountain
view.put(card.getId(), card); view.put(card.getId(), card);
card = createCard(game, player.getId(), "RNA", "185", 0, 0, 0); // Judith, the Scourge Diva card = createCard(game, player.getId(), "RNA", "185", 0, 0, 0); // Judith, the Scourge Diva
view.put(card.getId(), card); view.put(card.getId(), card);
//*/
card = createHandCard(game, player.getId(), "DIS", "153", 0, 0, 0); // Odds // Ends (split card)
view.put(card.getId(), card);
card = createHandCard(game, player.getId(), "ELD", "38", 2, 2, 0); // Animating Faerie (adventure card)
view.put(card.getId(), card);
/*
card = createCard(game, player.getId(), "RNA", "78", 125, 89, 0); // Noxious Groodion card = createCard(game, player.getId(), "RNA", "78", 125, 89, 0); // Noxious Groodion
view.put(card.getId(), card); view.put(card.getId(), card);
card = createCard(game, player.getId(), "RNA", "14", 3, 5, 2); // Knight of Sorrows card = createCard(game, player.getId(), "RNA", "14", 3, 5, 2); // Knight of Sorrows
@ -139,6 +159,7 @@ public class TestCardRenderDialog extends MageDialog {
view.put(card.getId(), card); view.put(card.getId(), card);
card = createPlane(new AkoumPlane()); // Plane - Akoum card = createPlane(new AkoumPlane()); // Plane - Akoum
view.put(card.getId(), card); view.put(card.getId(), card);
//*/
cardsPanel.setCustomCardSize(new Dimension(getCardWidth(), getCardHeight())); cardsPanel.setCustomCardSize(new Dimension(getCardWidth(), getCardHeight()));
cardsPanel.changeGUISize(); cardsPanel.changeGUISize();

View file

@ -525,7 +525,7 @@ public class CardPanelComponentImpl extends CardPanel {
int manaX = getCardXOffset() + getCardWidth() - manaMarginRight - manaWidth; int manaX = getCardXOffset() + getCardWidth() - manaMarginRight - manaWidth;
int manaY = getCardYOffset() + manaMarginTop; int manaY = getCardYOffset() + manaMarginTop;
ManaSymbols.draw(g, manaCost, manaX, manaY, getSymbolWidth(), Color.black, symbolMarginX); ManaSymbols.draw(g, manaCost, manaX, manaY, getSymbolWidth(), ModernCardRenderer.MANA_ICONS_TEXT_COLOR, symbolMarginX);
} }
} }

View file

@ -1,6 +1,7 @@
package org.mage.card.arcane; package org.mage.card.arcane;
import mage.abilities.hint.HintUtils; import mage.abilities.hint.HintUtils;
import mage.cards.repository.CardInfo;
import mage.cards.repository.ExpansionRepository; import mage.cards.repository.ExpansionRepository;
import mage.client.MageFrame; import mage.client.MageFrame;
import mage.client.constants.Constants; import mage.client.constants.Constants;
@ -587,7 +588,7 @@ public final class ManaSymbols {
} }
public static void draw(Graphics g, String manaCost, int x, int y, int symbolWidth) { public static void draw(Graphics g, String manaCost, int x, int y, int symbolWidth) {
draw(g, manaCost, x, y, symbolWidth, Color.white, 0); draw(g, manaCost, x, y, symbolWidth, ModernCardRenderer.MANA_ICONS_TEXT_COLOR, 0);
} }
public static void draw(Graphics g, String manaCost, int x, int y, int symbolWidth, Color symbolsTextColor, int symbolMarginX) { public static void draw(Graphics g, String manaCost, int x, int y, int symbolWidth, Color symbolsTextColor, int symbolMarginX) {
@ -657,20 +658,24 @@ public final class ManaSymbols {
if (image == null) { if (image == null) {
// TEXT draw // TEXT draw
String sampleAutoFontText = "{W}"; // need same font size for all -- use max symbol ever, not current text
if (symbol.equals(CardInfo.SPLIT_MANA_SEPARATOR_SHORT)) {
labelRender.setText(CardInfo.SPLIT_MANA_SEPARATOR_RENDER);
sampleAutoFontText = CardInfo.SPLIT_MANA_SEPARATOR_RENDER; // separator must be big
} else {
labelRender.setText("{" + symbol + "}"); labelRender.setText("{" + symbol + "}");
labelRender.setForeground(symbolsTextColor); }
labelRender.setSize(symbolWidth, symbolWidth); labelRender.setSize(symbolWidth, symbolWidth);
labelRender.setVerticalAlignment(SwingConstants.CENTER); labelRender.setVerticalAlignment(SwingConstants.CENTER);
labelRender.setForeground(symbolsTextColor);
labelRender.setHorizontalAlignment(SwingConstants.CENTER); labelRender.setHorizontalAlignment(SwingConstants.CENTER);
//labelRender.setBorder(new LineBorder(new Color(125, 250, 250), 1)); //labelRender.setBorder(new LineBorder(new Color(125, 250, 250), 1)); // debug draw
// fix font size for mana text // fix font size for mana text
// work for labels WITHOUT borders // work for labels WITHOUT borders
// https://stackoverflow.com/questions/2715118/how-to-change-the-size-of-the-font-of-a-jlabel-to-take-the-maximum-size // https://stackoverflow.com/questions/2715118/how-to-change-the-size-of-the-font-of-a-jlabel-to-take-the-maximum-size
Font labelFont = labelRender.getFont(); Font labelFont = labelRender.getFont();
String labelText = "{W}"; //labelRender.getText(); // need same font size for all -- use max symbol ever, not current text int stringWidth = labelRender.getFontMetrics(labelFont).stringWidth(sampleAutoFontText);
int stringWidth = labelRender.getFontMetrics(labelFont).stringWidth(labelText);
int componentWidth = labelRender.getWidth(); int componentWidth = labelRender.getWidth();
// Find out how much the font can grow in width. // Find out how much the font can grow in width.
double widthRatio = (double) componentWidth / (double) stringWidth; double widthRatio = (double) componentWidth / (double) stringWidth;
@ -702,7 +707,11 @@ public final class ManaSymbols {
for (String s : manaCost) { for (String s : manaCost) {
sb.append(s); sb.append(s);
} }
return sb.toString().replace("/", "").replace("{", "").replace("}", " ").trim(); return sb.toString()
.replace("/", "")
.replace("{", "")
.replace("}", " ")
.trim();
} }
public enum Type { public enum Type {
@ -767,6 +776,7 @@ public final class ManaSymbols {
htmlImagesPath = htmlImagesPath htmlImagesPath = htmlImagesPath
.replace("$", "@S@"); // paths with $ will rise error, need escape that .replace("$", "@S@"); // paths with $ will rise error, need escape that
replaced = replaced.replace(CardInfo.SPLIT_MANA_SEPARATOR_FULL, CardInfo.SPLIT_MANA_SEPARATOR_RENDER);
replaced = REPLACE_SYMBOLS_PATTERN.matcher(replaced).replaceAll( replaced = REPLACE_SYMBOLS_PATTERN.matcher(replaced).replaceAll(
"<img src='" + filePathToUrl(htmlImagesPath) + "$1$2" + ".png' alt='$1$2' width=" "<img src='" + filePathToUrl(htmlImagesPath) + "$1$2" + ".png' alt='$1$2' width="
+ symbolSize + " height=" + symbolSize + '>'); + symbolSize + " height=" + symbolSize + '>');

View file

@ -1,5 +1,6 @@
package org.mage.card.arcane; package org.mage.card.arcane;
import mage.cards.repository.CardInfo;
import mage.client.util.GUISizeHelper; import mage.client.util.GUISizeHelper;
import javax.swing.*; import javax.swing.*;
@ -45,17 +46,23 @@ public final class ManaSymbolsCellRenderer extends DefaultTableCellRenderer {
String symbol = tok.nextToken(); String symbol = tok.nextToken();
JLabel symbolLabel = new JLabel(); JLabel symbolLabel = new JLabel();
//symbolLabel.setBorder(new LineBorder(new Color(150, 150, 150))); // debug symbolLabel.setFont(GUISizeHelper.tableFont);
symbolLabel.setBorder(new EmptyBorder(0, symbolHorizontalMargin, 0, 0)); symbolLabel.setBorder(new EmptyBorder(0, symbolHorizontalMargin, 0, 0));
//symbolLabel.setBorder(new LineBorder(new Color(150, 150, 150))); // debug draw
BufferedImage image = ManaSymbols.getSizedManaSymbol(symbol, symbolWidth); BufferedImage image = ManaSymbols.getSizedManaSymbol(symbol, symbolWidth);
if (image != null) { if (image != null) {
// icon // icon
symbolLabel.setIcon(new ImageIcon(image)); symbolLabel.setIcon(new ImageIcon(image));
} else { } else {
// text // text (mana symbols withoiut brackets like R U * B)
// TODO: add auto-size text from ManaSymbols.draw
if (symbol.equals(CardInfo.SPLIT_MANA_SEPARATOR_SHORT)) {
symbolLabel.setText(CardInfo.SPLIT_MANA_SEPARATOR_RENDER);
} else {
symbolLabel.setText("{" + symbol + "}"); symbolLabel.setText("{" + symbol + "}");
symbolLabel.setOpaque(baseComp.isOpaque()); }
symbolLabel.setOpaque(false);
symbolLabel.setForeground(baseComp.getForeground()); symbolLabel.setForeground(baseComp.getForeground());
symbolLabel.setBackground(baseComp.getBackground()); symbolLabel.setBackground(baseComp.getBackground());
} }

View file

@ -59,6 +59,7 @@ public class ModernCardRenderer extends CardRenderer {
private static final Logger LOGGER = Logger.getLogger(ModernCardRenderer.class); private static final Logger LOGGER = Logger.getLogger(ModernCardRenderer.class);
private static final GlowText glowTextRenderer = new GlowText(); private static final GlowText glowTextRenderer = new GlowText();
public static final Color MANA_ICONS_TEXT_COLOR = Color.DARK_GRAY; // text color of missing mana icons in IMAGE render mode
/////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////
// Textures for modern frame cards // Textures for modern frame cards
@ -879,7 +880,7 @@ public class ModernCardRenderer extends CardRenderer {
// Draw the mana symbols // Draw the mana symbols
if (!cardView.isAbility() && !cardView.isFaceDown()) { if (!cardView.isAbility() && !cardView.isFaceDown()) {
ManaSymbols.draw(g, manaCost, x + w - manaCostWidth, y + boxTextOffset, boxTextHeight, Color.black, 2); ManaSymbols.draw(g, manaCost, x + w - manaCostWidth, y + boxTextOffset, boxTextHeight, ModernCardRenderer.MANA_ICONS_TEXT_COLOR, 2);
} }
} }
@ -1256,18 +1257,18 @@ public class ModernCardRenderer extends CardRenderer {
String symbs = symbol; String symbs = symbol;
int symbHeight = (int) (0.8 * h); int symbHeight = (int) (0.8 * h);
int manaCostWidth = CardRendererUtils.getManaCostWidth(symbs, symbHeight); int manaCostWidth = CardRendererUtils.getManaCostWidth(symbs, symbHeight);
ManaSymbols.draw(g, symbs, x + (w - manaCostWidth) / 2, y + (h - symbHeight) / 2, symbHeight, Color.black, 2); ManaSymbols.draw(g, symbs, x + (w - manaCostWidth) / 2, y + (h - symbHeight) / 2, symbHeight, ModernCardRenderer.MANA_ICONS_TEXT_COLOR, 2);
} }
private void drawBasicManaSymbol(Graphics2D g, int x, int y, int w, int h, String symbol) { private void drawBasicManaSymbol(Graphics2D g, int x, int y, int w, int h, String symbol) {
String symbs = symbol; String symbs = symbol;
if (getSizedManaSymbol(symbol) != null) { if (getSizedManaSymbol(symbol) != null) {
ManaSymbols.draw(g, symbs, x, y, w, Color.black, 2); ManaSymbols.draw(g, symbs, x, y, w, ModernCardRenderer.MANA_ICONS_TEXT_COLOR, 2);
} }
if (symbol.length() == 2) { if (symbol.length() == 2) {
String symbs2 = "" + symbol.charAt(1) + symbol.charAt(0); String symbs2 = "" + symbol.charAt(1) + symbol.charAt(0);
if (getSizedManaSymbol(symbs2) != null) { if (getSizedManaSymbol(symbs2) != null) {
ManaSymbols.draw(g, symbs2, x, y, w, Color.black, 2); ManaSymbols.draw(g, symbs2, x, y, w, ModernCardRenderer.MANA_ICONS_TEXT_COLOR, 2);
} }
} }
} }

View file

@ -1,21 +1,17 @@
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package org.mage.card.arcane; package org.mage.card.arcane;
import java.awt.Image; import mage.cards.repository.CardInfo;
import mage.view.CardView;
import org.apache.log4j.Logger;
import java.awt.*;
import java.util.ArrayDeque; import java.util.ArrayDeque;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Deque; import java.util.Deque;
import java.util.regex.Matcher; import java.util.regex.Matcher;
import java.util.regex.Pattern; import java.util.regex.Pattern;
import mage.view.CardView;
import org.apache.log4j.Logger;
/** /**
*
* @author StravantUser * @author StravantUser
*/ */
public final class TextboxRuleParser { public final class TextboxRuleParser {
@ -120,12 +116,17 @@ public final class TextboxRuleParser {
index = closeIndex + 1; index = closeIndex + 1;
} else { } else {
// Bad entry // Bad entry
if (contents.equals(CardInfo.SPLIT_MANA_SEPARATOR_FULL)) {
build.append(CardInfo.SPLIT_MANA_SEPARATOR_RENDER);
outputIndex += contents.length() - CardInfo.SPLIT_MANA_SEPARATOR_RENDER.length();
} else {
build.append('{'); build.append('{');
build.append(contents); build.append(contents);
build.append('}'); build.append('}');
index = closeIndex + 1;
outputIndex += (contents.length() + 2); outputIndex += (contents.length() + 2);
} }
index = closeIndex + 1;
}
} }
} }
break; break;

View file

@ -1,5 +1,3 @@
package mage.view; package mage.view;
import mage.ObjectColor; import mage.ObjectColor;
@ -35,7 +33,8 @@ public class AbilityView extends CardView {
this.subTypes = new SubTypeList(); this.subTypes = new SubTypeList();
this.superTypes = EnumSet.noneOf(SuperType.class); this.superTypes = EnumSet.noneOf(SuperType.class);
this.color = new ObjectColor(); this.color = new ObjectColor();
this.manaCost = ability.getManaCosts().getSymbols(); this.manaCostLeft = ability.getManaCosts().getSymbols();
this.manaCostRight = new ArrayList<>();
} }
public CardView getSourceCard() { public CardView getSourceCard() {

View file

@ -1,8 +1,6 @@
package mage.view; package mage.view;
import com.google.gson.annotations.Expose; import com.google.gson.annotations.Expose;
import java.util.*;
import java.util.stream.Collectors;
import mage.MageObject; import mage.MageObject;
import mage.ObjectColor; import mage.ObjectColor;
import mage.abilities.Abilities; import mage.abilities.Abilities;
@ -12,6 +10,8 @@ import mage.abilities.SpellAbility;
import mage.abilities.costs.mana.ManaCosts; import mage.abilities.costs.mana.ManaCosts;
import mage.abilities.keyword.AftermathAbility; import mage.abilities.keyword.AftermathAbility;
import mage.cards.*; import mage.cards.*;
import mage.cards.mock.MockCard;
import mage.cards.repository.CardInfo;
import mage.constants.*; import mage.constants.*;
import mage.counters.Counter; import mage.counters.Counter;
import mage.counters.CounterType; import mage.counters.CounterType;
@ -26,8 +26,12 @@ import mage.game.stack.Spell;
import mage.game.stack.StackAbility; import mage.game.stack.StackAbility;
import mage.target.Target; import mage.target.Target;
import mage.target.Targets; import mage.target.Targets;
import mage.util.CardUtil;
import mage.util.SubTypeList; import mage.util.SubTypeList;
import java.util.*;
import java.util.stream.Collectors;
/** /**
* @author BetaSteward_at_googlemail.com * @author BetaSteward_at_googlemail.com
*/ */
@ -41,6 +45,8 @@ public class CardView extends SimpleCardView {
@Expose @Expose
protected String displayName; protected String displayName;
@Expose @Expose
protected String displayFullName;
@Expose
protected List<String> rules; protected List<String> rules;
@Expose @Expose
protected String power; protected String power;
@ -55,7 +61,9 @@ public class CardView extends SimpleCardView {
protected ObjectColor color; protected ObjectColor color;
protected ObjectColor frameColor; protected ObjectColor frameColor;
protected FrameStyle frameStyle; protected FrameStyle frameStyle;
protected List<String> manaCost; // can combine multiple costs for MockCard from deck editor or db (left/right, card/adventure)
protected List<String> manaCostLeft;
protected List<String> manaCostRight;
protected int convertedManaCost; protected int convertedManaCost;
protected Rarity rarity; protected Rarity rarity;
@ -137,6 +145,7 @@ public class CardView extends SimpleCardView {
this.parentId = cardView.parentId; this.parentId = cardView.parentId;
this.name = cardView.name; this.name = cardView.name;
this.displayName = cardView.displayName; this.displayName = cardView.displayName;
this.displayFullName = cardView.displayFullName;
this.rules = cardView.rules; this.rules = cardView.rules;
this.power = cardView.power; this.power = cardView.power;
this.toughness = cardView.toughness; this.toughness = cardView.toughness;
@ -148,7 +157,8 @@ public class CardView extends SimpleCardView {
this.color = cardView.color; this.color = cardView.color;
this.frameColor = cardView.frameColor; this.frameColor = cardView.frameColor;
this.frameStyle = cardView.frameStyle; this.frameStyle = cardView.frameStyle;
this.manaCost = cardView.manaCost; this.manaCostLeft = cardView.manaCostLeft;
this.manaCostRight = cardView.manaCostRight;
this.convertedManaCost = cardView.convertedManaCost; this.convertedManaCost = cardView.convertedManaCost;
this.rarity = cardView.rarity; this.rarity = cardView.rarity;
@ -275,6 +285,7 @@ public class CardView extends SimpleCardView {
if (controlled) { if (controlled) {
this.name = card.getName(); this.name = card.getName();
this.displayName = card.getName(); this.displayName = card.getName();
this.displayFullName = card.getName();
this.alternateName = card.getName(); this.alternateName = card.getName();
} }
this.power = "2"; this.power = "2";
@ -313,6 +324,15 @@ public class CardView extends SimpleCardView {
break; break;
} }
} }
AdventureCard adventureCard = null;
AdventureCardSpell adventureCardSpell = null;
if (card instanceof AdventureCard) {
adventureCard = (AdventureCard) card;
adventureCardSpell = (AdventureCardSpell) adventureCard.getSpellCard();
}
String fullCardName;
if (splitCard != null) { if (splitCard != null) {
this.isSplitCard = true; this.isSplitCard = true;
leftSplitName = splitCard.getLeftHalfCard().getName(); leftSplitName = splitCard.getLeftHalfCard().getName();
@ -323,16 +343,34 @@ public class CardView extends SimpleCardView {
rightSplitCosts = splitCard.getRightHalfCard().getManaCost(); rightSplitCosts = splitCard.getRightHalfCard().getManaCost();
rightSplitRules = splitCard.getRightHalfCard().getRules(game); rightSplitRules = splitCard.getRightHalfCard().getRules(game);
rightSplitTypeLine = getCardTypeLine(game, splitCard.getRightHalfCard()); rightSplitTypeLine = getCardTypeLine(game, splitCard.getRightHalfCard());
fullCardName = card.getName(); // split card contains full name as normal
this.manaCostLeft = splitCard.getLeftHalfCard().getManaCost().getSymbols();
this.manaCostRight = splitCard.getRightHalfCard().getManaCost().getSymbols();
} else if (adventureCard != null) {
fullCardName = adventureCard.getName() + MockCard.ADVENTURE_NAME_SEPARATOR + adventureCardSpell.getName();
this.manaCostLeft = adventureCardSpell.getManaCost().getSymbols();
this.manaCostRight = adventureCard.getManaCost().getSymbols();
} else if (card instanceof MockCard) {
// deck editor cards
fullCardName = ((MockCard) card).getFullName(true);
this.manaCostLeft = ((MockCard) card).getManaCost(CardInfo.ManaCostSide.LEFT).getSymbols();
this.manaCostRight = ((MockCard) card).getManaCost(CardInfo.ManaCostSide.RIGHT).getSymbols();
} else {
fullCardName = card.getName();
this.manaCostLeft = card.getManaCost().getSymbols();
this.manaCostRight = new ArrayList<>();
} }
//this.manaCost = card.getManaCost().getSymbols();
this.name = card.getImageName(); this.name = card.getImageName();
this.displayName = card.getName(); this.displayName = card.getName();
this.displayFullName = fullCardName;
if (game == null) { if (game == null) {
this.rules = card.getRules(); this.rules = card.getRules();
} else { } else {
this.rules = card.getRules(game); this.rules = card.getRules(game);
} }
this.manaCost = card.getManaCost().getSymbols();
this.convertedManaCost = card.getManaCost().convertedManaCost(); this.convertedManaCost = card.getManaCost().convertedManaCost();
if (card instanceof Permanent) { if (card instanceof Permanent) {
@ -475,6 +513,7 @@ public class CardView extends SimpleCardView {
this.name = object.getName(); this.name = object.getName();
this.displayName = object.getName(); this.displayName = object.getName();
this.displayFullName = object.getName();
if (object instanceof Permanent) { if (object instanceof Permanent) {
this.mageObjectType = MageObjectType.PERMANENT; this.mageObjectType = MageObjectType.PERMANENT;
this.power = Integer.toString(object.getPower().getValue()); this.power = Integer.toString(object.getPower().getValue());
@ -489,7 +528,8 @@ public class CardView extends SimpleCardView {
this.subTypes = object.getSubtype(null); this.subTypes = object.getSubtype(null);
this.superTypes = object.getSuperType(); this.superTypes = object.getSuperType();
this.color = object.getColor(null); this.color = object.getColor(null);
this.manaCost = object.getManaCost().getSymbols(); this.manaCostLeft = object.getManaCost().getSymbols();
this.manaCostRight = new ArrayList<>();
this.convertedManaCost = object.getManaCost().convertedManaCost(); this.convertedManaCost = object.getManaCost().convertedManaCost();
if (object instanceof PermanentToken) { if (object instanceof PermanentToken) {
this.mageObjectType = MageObjectType.TOKEN; this.mageObjectType = MageObjectType.TOKEN;
@ -547,6 +587,7 @@ public class CardView extends SimpleCardView {
this.mageObjectType = MageObjectType.EMBLEM; this.mageObjectType = MageObjectType.EMBLEM;
this.name = emblem.getName(); this.name = emblem.getName();
this.displayName = name; this.displayName = name;
this.displayFullName = name;
this.rules = emblem.getRules(); this.rules = emblem.getRules();
// emblem images are always with common (black) symbol // emblem images are always with common (black) symbol
this.frameStyle = FrameStyle.M15_NORMAL; this.frameStyle = FrameStyle.M15_NORMAL;
@ -561,6 +602,7 @@ public class CardView extends SimpleCardView {
this.mageObjectType = MageObjectType.PLANE; this.mageObjectType = MageObjectType.PLANE;
this.name = plane.getName(); this.name = plane.getName();
this.displayName = name; this.displayName = name;
this.displayFullName = name;
this.rules = plane.getRules(); this.rules = plane.getRules();
// Display the plane in landscape (similar to Fused cards) // Display the plane in landscape (similar to Fused cards)
this.rotate = true; this.rotate = true;
@ -576,6 +618,7 @@ public class CardView extends SimpleCardView {
this.mageObjectType = MageObjectType.NULL; this.mageObjectType = MageObjectType.NULL;
this.name = designation.getName(); this.name = designation.getName();
this.displayName = name; this.displayName = name;
this.displayFullName = name;
this.rules = new ArrayList<>(); this.rules = new ArrayList<>();
this.rules.add(stackAbility.getRule(designation.getName())); this.rules.add(stackAbility.getRule(designation.getName()));
this.frameStyle = FrameStyle.M15_NORMAL; this.frameStyle = FrameStyle.M15_NORMAL;
@ -594,6 +637,7 @@ public class CardView extends SimpleCardView {
private void fillEmpty(Card card, boolean controlled) { private void fillEmpty(Card card, boolean controlled) {
this.name = "Face Down"; this.name = "Face Down";
this.displayName = name; this.displayName = name;
this.displayFullName = name;
this.rules = new ArrayList<>(); this.rules = new ArrayList<>();
this.power = ""; this.power = "";
this.toughness = ""; this.toughness = "";
@ -605,7 +649,8 @@ public class CardView extends SimpleCardView {
this.color = new ObjectColor(); this.color = new ObjectColor();
this.frameColor = new ObjectColor(); this.frameColor = new ObjectColor();
this.frameStyle = FrameStyle.M15_NORMAL; this.frameStyle = FrameStyle.M15_NORMAL;
this.manaCost = new ArrayList<>(); this.manaCostLeft = new ArrayList<>();
this.manaCostRight = new ArrayList<>();
this.convertedManaCost = 0; this.convertedManaCost = 0;
// the controller can see more information (e.g. enlarged image) than other players for face down cards (e.g. Morph played face down) // the controller can see more information (e.g. enlarged image) than other players for face down cards (e.g. Morph played face down)
@ -641,6 +686,7 @@ public class CardView extends SimpleCardView {
this.id = token.getId(); this.id = token.getId();
this.name = token.getName(); this.name = token.getName();
this.displayName = token.getName(); this.displayName = token.getName();
this.displayFullName = token.getName();
this.rules = token.getAbilities().getRules(this.name); this.rules = token.getAbilities().getRules(this.name);
this.power = token.getPower().toString(); this.power = token.getPower().toString();
this.toughness = token.getToughness().toString(); this.toughness = token.getToughness().toString();
@ -652,7 +698,8 @@ public class CardView extends SimpleCardView {
this.color = token.getColor(null); this.color = token.getColor(null);
this.frameColor = token.getFrameColor(null); this.frameColor = token.getFrameColor(null);
this.frameStyle = token.getFrameStyle(); this.frameStyle = token.getFrameStyle();
this.manaCost = token.getManaCost().getSymbols(); this.manaCostLeft = token.getManaCost().getSymbols();
this.manaCostRight = new ArrayList<>();
this.rarity = Rarity.SPECIAL; this.rarity = Rarity.SPECIAL;
this.type = token.getTokenType(); this.type = token.getTokenType();
this.tokenDescriptor = token.getTokenDescriptor(); this.tokenDescriptor = token.getTokenDescriptor();
@ -680,6 +727,10 @@ public class CardView extends SimpleCardView {
return displayName; return displayName;
} }
public String getDisplayFullName() {
return displayFullName;
}
public List<String> getRules() { public List<String> getRules() {
return rules; return rules;
} }
@ -745,7 +796,7 @@ public class CardView extends SimpleCardView {
} }
public List<String> getManaCost() { public List<String> getManaCost() {
return manaCost; return CardUtil.concatManaSymbols(CardInfo.SPLIT_MANA_SEPARATOR_FULL, this.manaCostLeft, this.manaCostRight);
} }
public int getConvertedManaCost() { public int getConvertedManaCost() {

View file

@ -40,12 +40,12 @@ public class StackAbilityView extends CardView {
this.subTypes = ability.getSubtype(game); this.subTypes = ability.getSubtype(game);
this.superTypes = ability.getSuperType(); this.superTypes = ability.getSuperType();
this.color = ability.getColor(game); this.color = ability.getColor(game);
this.manaCost = ability.getManaCost().getSymbols(); this.manaCostLeft = ability.getManaCost().getSymbols();
this.manaCostRight = new ArrayList<>();
this.cardTypes = ability.getCardType(); this.cardTypes = ability.getCardType();
this.subTypes = ability.getSubtype(game); this.subTypes = ability.getSubtype(game);
this.superTypes = ability.getSuperType(); this.superTypes = ability.getSuperType();
this.color = ability.getColor(game); this.color = ability.getColor(game);
this.manaCost = ability.getManaCost().getSymbols();
this.power = ability.getPower().toString(); this.power = ability.getPower().toString();
this.toughness = ability.getToughness().toString(); this.toughness = ability.getToughness().toString();
String nameToShow; String nameToShow;
@ -56,7 +56,8 @@ public class StackAbilityView extends CardView {
tmpSourceCard.subTypes.clear(); tmpSourceCard.subTypes.clear();
tmpSourceCard.cardTypes.clear(); tmpSourceCard.cardTypes.clear();
tmpSourceCard.cardTypes.add(CardType.CREATURE); tmpSourceCard.cardTypes.add(CardType.CREATURE);
tmpSourceCard.manaCost.clear(); tmpSourceCard.manaCostLeft.clear();
tmpSourceCard.manaCostRight.clear();
tmpSourceCard.power = "2"; tmpSourceCard.power = "2";
tmpSourceCard.toughness = "2"; tmpSourceCard.toughness = "2";
nameToShow = "creature without name"; nameToShow = "creature without name";

View file

@ -248,7 +248,7 @@ public enum ChatManager {
CardInfo cardInfo = CardRepository.instance.findPreferedCoreExpansionCard(cardName, true); CardInfo cardInfo = CardRepository.instance.findPreferedCoreExpansionCard(cardName, true);
if (cardInfo != null) { if (cardInfo != null) {
cardInfo.getRules(); cardInfo.getRules();
message = "<font color=orange>" + cardInfo.getName() + "</font>: Cost:" + cardInfo.getManaCosts().toString() + ", Types:" + cardInfo.getTypes().toString() + ", "; message = "<font color=orange>" + cardInfo.getName() + "</font>: Cost:" + cardInfo.getManaCosts(CardInfo.ManaCostSide.ALL).toString() + ", Types:" + cardInfo.getTypes().toString() + ", ";
for (String rule : cardInfo.getRules()) { for (String rule : cardInfo.getRules()) {
message = message + rule; message = message + rule;
} }

View file

@ -2,6 +2,8 @@ package mage.cards.mock;
import mage.MageInt; import mage.MageInt;
import mage.abilities.Ability; import mage.abilities.Ability;
import mage.abilities.costs.mana.ManaCost;
import mage.abilities.costs.mana.ManaCosts;
import mage.abilities.costs.mana.ManaCostsImpl; import mage.abilities.costs.mana.ManaCostsImpl;
import mage.cards.CardImpl; import mage.cards.CardImpl;
import mage.cards.repository.CardInfo; import mage.cards.repository.CardInfo;
@ -11,15 +13,24 @@ import org.apache.log4j.Logger;
import java.util.List; import java.util.List;
/** /**
* Mock card for GUI (deck editor and panels)
*
* @author North * @author North
*/ */
public class MockCard extends CardImpl { public class MockCard extends CardImpl {
static public String ADVENTURE_NAME_SEPARATOR = " // ";
// Needs to be here, as it is normally calculated from the // Needs to be here, as it is normally calculated from the
// PlaneswalkerEntersWithLoyaltyAbility of the card... but the MockCard // PlaneswalkerEntersWithLoyaltyAbility of the card... but the MockCard
// only has MockAbilities. // only has MockAbilities.
private int startingLoyalty; private int startingLoyalty;
// mana cost extra info for multiple mana drawing
protected ManaCosts<ManaCost> manaCostLeft;
protected ManaCosts<ManaCost> manaCostRight;
protected String adventureSpellName;
public MockCard(CardInfo card) { public MockCard(CardInfo card) {
super(null, card.getName()); super(null, card.getName());
this.cardNumber = card.getCardNumber(); this.cardNumber = card.getCardNumber();
@ -33,7 +44,9 @@ public class MockCard extends CardImpl {
this.usesVariousArt = card.usesVariousArt(); this.usesVariousArt = card.usesVariousArt();
this.manaCost = new ManaCostsImpl(join(card.getManaCosts())); this.manaCostLeft = new ManaCostsImpl(join(card.getManaCosts(CardInfo.ManaCostSide.LEFT)));
this.manaCostRight = new ManaCostsImpl(join(card.getManaCosts(CardInfo.ManaCostSide.RIGHT)));
this.manaCost = new ManaCostsImpl(join(card.getManaCosts(CardInfo.ManaCostSide.ALL)));
this.color = card.getColor(); this.color = card.getColor();
@ -49,6 +62,10 @@ public class MockCard extends CardImpl {
this.secondSideCard = new MockCard(CardRepository.instance.findCardWPreferredSet(card.getSecondSideName(), card.getSetCode(), false)); this.secondSideCard = new MockCard(CardRepository.instance.findCardWPreferredSet(card.getSecondSideName(), card.getSetCode(), false));
} }
if (card.isAdventureCard()) {
this.adventureSpellName = card.getAdventureSpellName();
}
if (this.isPlaneswalker()) { if (this.isPlaneswalker()) {
String startingLoyaltyString = card.getStartingLoyalty(); String startingLoyaltyString = card.getStartingLoyalty();
if (startingLoyaltyString.isEmpty()) { if (startingLoyaltyString.isEmpty()) {
@ -82,6 +99,32 @@ public class MockCard extends CardImpl {
return new MockCard(this); return new MockCard(this);
} }
@Override
public ManaCosts<ManaCost> getManaCost() {
return manaCost;
}
public ManaCosts<ManaCost> getManaCost(CardInfo.ManaCostSide manaCostSide) {
switch (manaCostSide) {
case LEFT:
return manaCostLeft;
case RIGHT:
return manaCostRight;
default:
case ALL:
return manaCost;
}
}
public String getFullName(boolean showSecondName) {
if (adventureSpellName != null) {
return getName() + ADVENTURE_NAME_SEPARATOR + adventureSpellName;
} else {
return getName();
}
}
private MageInt mageIntFromString(String value) { private MageInt mageIntFromString(String value) {
try { try {
int intValue = Integer.parseInt(value); int intValue = Integer.parseInt(value);

View file

@ -20,8 +20,8 @@ public class MockSplitCard extends SplitCard {
public MockSplitCard(CardInfo card) { public MockSplitCard(CardInfo card) {
super(null, new CardSetInfo(card.getName(), card.getSetCode(), card.getCardNumber(), card.getRarity()), super(null, new CardSetInfo(card.getName(), card.getSetCode(), card.getCardNumber(), card.getRarity()),
card.getTypes().toArray(new CardType[0]), card.getTypes().toArray(new CardType[0]),
join(card.getManaCosts()), join(card.getManaCosts(CardInfo.ManaCostSide.LEFT)),
"", join(card.getManaCosts(CardInfo.ManaCostSide.RIGHT)),
getSpellAbilityType(card)); getSpellAbilityType(card));
this.expansionSetCode = card.getSetCode(); this.expansionSetCode = card.getSetCode();
this.power = mageIntFromString(card.getPower()); this.power = mageIntFromString(card.getPower());

View file

@ -1,11 +1,8 @@
package mage.cards.repository; package mage.cards.repository;
import com.j256.ormlite.field.DataType; import com.j256.ormlite.field.DataType;
import com.j256.ormlite.field.DatabaseField; import com.j256.ormlite.field.DatabaseField;
import com.j256.ormlite.table.DatabaseTable; import com.j256.ormlite.table.DatabaseTable;
import java.util.*;
import java.util.stream.Collectors;
import mage.ObjectColor; import mage.ObjectColor;
import mage.abilities.Ability; import mage.abilities.Ability;
import mage.abilities.SpellAbility; import mage.abilities.SpellAbility;
@ -18,6 +15,9 @@ import mage.util.CardUtil;
import mage.util.SubTypeList; import mage.util.SubTypeList;
import org.apache.log4j.Logger; import org.apache.log4j.Logger;
import java.util.*;
import java.util.stream.Collectors;
/** /**
* @author North * @author North
*/ */
@ -27,6 +27,11 @@ public class CardInfo {
private static final int MAX_RULE_LENGTH = 750; private static final int MAX_RULE_LENGTH = 750;
private static final String SEPARATOR = "@@@"; private static final String SEPARATOR = "@@@";
public static final String SPLIT_MANA_SEPARATOR_SHORT = "*";
public static final String SPLIT_MANA_SEPARATOR_FULL = "{" + SPLIT_MANA_SEPARATOR_SHORT + "}";
public static final String SPLIT_MANA_SEPARATOR_RENDER = " / ";
@DatabaseField(indexName = "name_index") @DatabaseField(indexName = "name_index")
protected String name; protected String name;
@DatabaseField(indexName = "setCode_cardNumber_index") @DatabaseField(indexName = "setCode_cardNumber_index")
@ -89,6 +94,14 @@ public class CardInfo {
protected String flipCardName; protected String flipCardName;
@DatabaseField @DatabaseField
protected String secondSideName; protected String secondSideName;
@DatabaseField
protected boolean adventureCard;
@DatabaseField
protected String adventureSpellName;
public enum ManaCostSide {
LEFT, RIGHT, ALL
}
public CardInfo() { public CardInfo() {
} }
@ -116,6 +129,11 @@ public class CardInfo {
this.secondSideName = secondSide.getName(); this.secondSideName = secondSide.getName();
} }
if (card instanceof AdventureCard) {
this.adventureCard = true;
this.adventureSpellName = ((AdventureCard) card).getSpellCard().getName();
}
this.frameStyle = card.getFrameStyle().toString(); this.frameStyle = card.getFrameStyle().toString();
this.frameColor = card.getFrameColor(null).toString(); this.frameColor = card.getFrameColor(null).toString();
this.variousArt = card.getUsesVariousArt(); this.variousArt = card.getUsesVariousArt();
@ -128,7 +146,19 @@ public class CardInfo {
this.setTypes(card.getCardType()); this.setTypes(card.getCardType());
this.setSubtypes(card.getSubtype(null).stream().map(SubType::toString).collect(Collectors.toList())); this.setSubtypes(card.getSubtype(null).stream().map(SubType::toString).collect(Collectors.toList()));
this.setSuperTypes(card.getSuperType()); this.setSuperTypes(card.getSuperType());
// mana cost can contains multiple cards (split left/right, card/adventure)
if (card instanceof SplitCard) {
List<String> manaCostLeft = ((SplitCard) card).getLeftHalfCard().getManaCost().getSymbols();
List<String> manaCostRight = ((SplitCard) card).getRightHalfCard().getManaCost().getSymbols();
this.setManaCosts(CardUtil.concatManaSymbols(SPLIT_MANA_SEPARATOR_FULL, manaCostLeft, manaCostRight));
} else if (card instanceof AdventureCard) {
List<String> manaCostLeft = ((AdventureCard) card).getSpellCard().getManaCost().getSymbols(); // Spell from left like MTGA
List<String> manaCostRight = card.getManaCost().getSymbols();
this.setManaCosts(CardUtil.concatManaSymbols(SPLIT_MANA_SEPARATOR_FULL, manaCostLeft, manaCostRight));
} else {
this.setManaCosts(card.getManaCost().getSymbols()); this.setManaCosts(card.getManaCost().getSymbols());
}
int length = 0; int length = 0;
List<String> rulesList = new ArrayList<>(); List<String> rulesList = new ArrayList<>();
@ -236,12 +266,27 @@ public class CardInfo {
return sb.toString(); return sb.toString();
} }
private List<String> parseList(String list) { private List<String> parseList(String list, ManaCostSide manaCostSide) {
if (list.isEmpty()) { if (list.isEmpty()) {
return Collections.emptyList(); return Collections.emptyList();
} }
return Arrays.asList(list.split(SEPARATOR)); List<String> res = new ArrayList<>();
boolean leftSide = true;
for (String s : list.split(SEPARATOR)) {
if (s.equals(SPLIT_MANA_SEPARATOR_FULL)) {
leftSide = false;
continue;
}
if (manaCostSide.equals(ManaCostSide.ALL)
|| (manaCostSide.equals(ManaCostSide.LEFT) && leftSide)
|| (manaCostSide.equals(ManaCostSide.RIGHT) && !leftSide)) {
res.add(s);
}
}
return res;
} }
public final Set<CardType> getTypes() { public final Set<CardType> getTypes() {
@ -267,8 +312,8 @@ public class CardInfo {
return convertedManaCost; return convertedManaCost;
} }
public final List<String> getManaCosts() { public final List<String> getManaCosts(ManaCostSide manaCostSide) {
return parseList(manaCosts); return parseList(manaCosts, manaCostSide);
} }
public final void setManaCosts(List<String> manaCosts) { public final void setManaCosts(List<String> manaCosts) {
@ -288,7 +333,7 @@ public class CardInfo {
} }
public final List<String> getRules() { public final List<String> getRules() {
return parseList(rules); return parseList(rules, ManaCostSide.ALL);
} }
public final void setRules(List<String> rules) { public final void setRules(List<String> rules) {
@ -388,4 +433,12 @@ public class CardInfo {
public String getSecondSideName() { public String getSecondSideName() {
return secondSideName; return secondSideName;
} }
public boolean isAdventureCard() {
return adventureCard;
}
public String getAdventureSpellName() {
return adventureSpellName;
}
} }

View file

@ -33,9 +33,9 @@ public enum CardRepository {
private static final String JDBC_URL = "jdbc:h2:file:./db/cards.h2;AUTO_SERVER=TRUE"; private static final String JDBC_URL = "jdbc:h2:file:./db/cards.h2;AUTO_SERVER=TRUE";
private static final String VERSION_ENTITY_NAME = "card"; private static final String VERSION_ENTITY_NAME = "card";
// raise this if db structure was changed // raise this if db structure was changed
private static final long CARD_DB_VERSION = 51; private static final long CARD_DB_VERSION = 52;
// raise this if new cards were added to the server // raise this if new cards were added to the server
private static final long CARD_CONTENT_VERSION = 227; private static final long CARD_CONTENT_VERSION = 228;
private Dao<CardInfo, Object> cardDao; private Dao<CardInfo, Object> cardDao;
private Set<String> classNames; private Set<String> classNames;
private RepositoryEventSource eventSource = new RepositoryEventSource(); private RepositoryEventSource eventSource = new RepositoryEventSource();
@ -458,7 +458,7 @@ public enum CardRepository {
public List<CardInfo> findCardsCaseInsensitive(String name) { public List<CardInfo> findCardsCaseInsensitive(String name) {
try { try {
String sqlName = name.toLowerCase(Locale.ENGLISH).replaceAll("\'", "\'\'"); String sqlName = name.toLowerCase(Locale.ENGLISH).replaceAll("'", "''");
GenericRawResults<CardInfo> rawResults = cardDao.queryRaw( GenericRawResults<CardInfo> rawResults = cardDao.queryRaw(
"select * from " + CardRepository.VERSION_ENTITY_NAME + " where lower(name) = '" + sqlName + '\'', "select * from " + CardRepository.VERSION_ENTITY_NAME + " where lower(name) = '" + sqlName + '\'',
cardDao.getRawRowMapper()); cardDao.getRawRowMapper());

View file

@ -1,18 +1,19 @@
package mage.filter.predicate.other; package mage.filter.predicate.other;
import java.util.HashMap;
import java.util.Locale;
import mage.cards.AdventureCard; import mage.cards.AdventureCard;
import mage.cards.Card; import mage.cards.Card;
import mage.cards.SplitCard; import mage.cards.SplitCard;
import mage.cards.mock.MockCard;
import mage.constants.SubType; import mage.constants.SubType;
import mage.constants.SuperType; import mage.constants.SuperType;
import mage.filter.predicate.Predicate; import mage.filter.predicate.Predicate;
import mage.game.Game; import mage.game.Game;
import java.util.HashMap;
import java.util.Locale;
/** /**
* Special predicate to search cards in deck editor
* *
* @author North * @author North
*/ */
@ -41,14 +42,22 @@ public class CardTextPredicate implements Predicate<Card> {
} }
if (text.isEmpty() && isUnique) { if (text.isEmpty() && isUnique) {
boolean found = !seenCards.keySet().contains(input.getName()); boolean found = !seenCards.containsKey(input.getName());
seenCards.put(input.getName(), true); seenCards.put(input.getName(), true);
return found; return found;
} }
// first check in card name // first check in card name
if (inNames && input.getName().toLowerCase(Locale.ENGLISH).contains(text.toLowerCase(Locale.ENGLISH))) { if (inNames) {
if (isUnique && seenCards.keySet().contains(input.getName())) { String fullName = input.getName();
if (input instanceof MockCard) {
fullName = ((MockCard) input).getFullName(true);
} else if (input instanceof AdventureCard) {
fullName = input.getName() + MockCard.ADVENTURE_NAME_SEPARATOR + ((AdventureCard) input).getSpellCard().getName();
}
if (fullName.toLowerCase(Locale.ENGLISH).contains(text.toLowerCase(Locale.ENGLISH))) {
if (isUnique && seenCards.containsKey(input.getName())) {
return false; return false;
} }
if (isUnique) { if (isUnique) {
@ -56,6 +65,7 @@ public class CardTextPredicate implements Predicate<Card> {
} }
return true; return true;
} }
}
//separate by spaces //separate by spaces
String[] tokens = text.toLowerCase(Locale.ENGLISH).split(" "); String[] tokens = text.toLowerCase(Locale.ENGLISH).split(" ");
@ -109,7 +119,7 @@ public class CardTextPredicate implements Predicate<Card> {
} }
} }
if (found && isUnique && seenCards.keySet().contains(input.getName())) { if (found && isUnique && seenCards.containsKey(input.getName())) {
found = false; found = false;
} }
if (!found) { if (!found) {

View file

@ -1,11 +1,5 @@
package mage.util; package mage.util;
import java.io.UnsupportedEncodingException;
import java.net.URLDecoder;
import java.net.URLEncoder;
import java.text.SimpleDateFormat;
import java.util.Objects;
import java.util.UUID;
import mage.MageObject; import mage.MageObject;
import mage.Mana; import mage.Mana;
import mage.abilities.Ability; import mage.abilities.Ability;
@ -21,6 +15,15 @@ import mage.game.permanent.Permanent;
import mage.game.permanent.token.Token; import mage.game.permanent.token.Token;
import mage.util.functions.CopyTokenFunction; import mage.util.functions.CopyTokenFunction;
import java.io.UnsupportedEncodingException;
import java.net.URLDecoder;
import java.net.URLEncoder;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.List;
import java.util.Objects;
import java.util.UUID;
/** /**
* @author nantuko * @author nantuko
*/ */
@ -630,4 +633,13 @@ public final class CardUtil {
} }
return false; return false;
} }
public static List<String> concatManaSymbols(String delimeter, List<String> mana1, List<String> mana2) {
List<String> res = new ArrayList<>(mana1);
if (res.size() > 0 && mana2.size() > 0 && delimeter != null && !delimeter.isEmpty()) {
res.add(delimeter);
}
res.addAll(mana2);
return res;
}
} }