diff --git a/Mage.Client/src/main/java/mage/client/deckeditor/table/CardHelper.java b/Mage.Client/src/main/java/mage/client/deckeditor/table/CardHelper.java deleted file mode 100644 index 356dafdfd8..0000000000 --- a/Mage.Client/src/main/java/mage/client/deckeditor/table/CardHelper.java +++ /dev/null @@ -1,69 +0,0 @@ -/* -* Copyright 2010 BetaSteward_at_googlemail.com. All rights reserved. -* -* Redistribution and use in source and binary forms, with or without modification, are -* permitted provided that the following conditions are met: -* -* 1. Redistributions of source code must retain the above copyright notice, this list of -* conditions and the following disclaimer. -* -* 2. Redistributions in binary form must reproduce the above copyright notice, this list -* of conditions and the following disclaimer in the documentation and/or other materials -* provided with the distribution. -* -* THIS SOFTWARE IS PROVIDED BY BetaSteward_at_googlemail.com ``AS IS'' AND ANY EXPRESS OR IMPLIED -* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND -* FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL BetaSteward_at_googlemail.com OR -* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON -* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF -* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -* -* The views and conclusions contained in the software and documentation are those of the -* authors and should not be interpreted as representing official policies, either expressed -* or implied, of BetaSteward_at_googlemail.com. -*/ - -package mage.client.deckeditor.table; - -import mage.constants.CardType; -import mage.cards.MageCard; -import mage.constants.SuperType; -import mage.view.CardView; - -/** - * Helper methods for {@link MageCard}. - * - * @author nantuko - */ -public final class CardHelper { - private CardHelper() { - } - - public static String getType(CardView c) { - StringBuilder type = new StringBuilder(); - for (SuperType superType : c.getSuperTypes()) { - type.append(superType.toString()); - type.append(' '); - } - for (CardType cardType : c.getCardTypes()) { - type.append(cardType.toString()); - type.append(' '); - } - if (!c.getSubTypes().isEmpty()) { - type.append("- "); - for (String subType : c.getSubTypes()) { - type.append(subType); - type.append(' '); - } - } - if (type.length() > 0) { - // remove trailing space - type.deleteCharAt(type.length() - 1); - } - return type.toString(); - } - -} diff --git a/Mage.Client/src/main/java/mage/client/deckeditor/table/MageCardComparator.java b/Mage.Client/src/main/java/mage/client/deckeditor/table/MageCardComparator.java index b8b145d09d..0ae3255a20 100644 --- a/Mage.Client/src/main/java/mage/client/deckeditor/table/MageCardComparator.java +++ b/Mage.Client/src/main/java/mage/client/deckeditor/table/MageCardComparator.java @@ -79,8 +79,8 @@ public class MageCardComparator implements Comparator { break; // Type case 4: - aCom = CardHelper.getType(a); - bCom = CardHelper.getType(b); + aCom = a.getTypeText(); + bCom = b.getTypeText(); break; // Stats, attack and defense case 5: diff --git a/Mage.Client/src/main/java/mage/client/deckeditor/table/TableModel.java b/Mage.Client/src/main/java/mage/client/deckeditor/table/TableModel.java index e4f2452900..09b2a3c2e3 100644 --- a/Mage.Client/src/main/java/mage/client/deckeditor/table/TableModel.java +++ b/Mage.Client/src/main/java/mage/client/deckeditor/table/TableModel.java @@ -254,7 +254,7 @@ public class TableModel extends AbstractTableModel implements ICardGrid { case 3: return c.getColorText(); case 4: - return CardHelper.getType(c); + return c.getTypeText(); case 5: return c.isCreature() ? c.getPower() + '/' + c.getToughness() : "-"; diff --git a/Mage.Client/src/test/java/mage/client/util/CardHelperTest.java b/Mage.Client/src/test/java/mage/client/util/CardHelperTest.java deleted file mode 100644 index 6e6a3b3be1..0000000000 --- a/Mage.Client/src/test/java/mage/client/util/CardHelperTest.java +++ /dev/null @@ -1,27 +0,0 @@ -package mage.client.util; - -import mage.client.deckeditor.table.CardHelper; -import mage.constants.CardType; -import mage.view.CardView; -import org.junit.Assert; -import org.junit.Test; - -import static org.hamcrest.core.Is.is; - -/** - * Created by IGOUDT on 3-3-2017. - */ -public class CardHelperTest { - - @Test - public void testCardTypeOrder() { - CardView v = new CardView(true); - v.getCardTypes().add(CardType.CREATURE); - v.getCardTypes().add(CardType.ARTIFACT); - String cardtypeText = CardHelper.getType(v); - Assert.assertThat(cardtypeText, is("Artifact Creature")); - - } - - -} diff --git a/Mage.Common/src/mage/view/CardView.java b/Mage.Common/src/mage/view/CardView.java index e9eba628fa..b7f1936c27 100644 --- a/Mage.Common/src/mage/view/CardView.java +++ b/Mage.Common/src/mage/view/CardView.java @@ -972,4 +972,28 @@ public class CardView extends SimpleCardView { return ""; } + public String getTypeText() { + StringBuilder type = new StringBuilder(); + for (SuperType superType : getSuperTypes()) { + type.append(superType.toString()); + type.append(' '); + } + for (CardType cardType : getCardTypes()) { + type.append(cardType.toString()); + type.append(' '); + } + if (!getSubTypes().isEmpty()) { + type.append("- "); + for (String subType : getSubTypes()) { + type.append(subType); + type.append(' '); + } + } + if (type.length() > 0) { + // remove trailing space + type.deleteCharAt(type.length() - 1); + } + return type.toString(); + } + }