remove CardHelper class

This commit is contained in:
ingmargoudt 2017-04-07 09:59:17 +02:00
parent 22e376699e
commit 08197f192c
5 changed files with 27 additions and 99 deletions

View file

@ -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();
}
}

View file

@ -79,8 +79,8 @@ public class MageCardComparator implements Comparator<CardView> {
break; break;
// Type // Type
case 4: case 4:
aCom = CardHelper.getType(a); aCom = a.getTypeText();
bCom = CardHelper.getType(b); bCom = b.getTypeText();
break; break;
// Stats, attack and defense // Stats, attack and defense
case 5: case 5:

View file

@ -254,7 +254,7 @@ public class TableModel extends AbstractTableModel implements ICardGrid {
case 3: case 3:
return c.getColorText(); return c.getColorText();
case 4: case 4:
return CardHelper.getType(c); return c.getTypeText();
case 5: case 5:
return c.isCreature() ? c.getPower() + '/' return c.isCreature() ? c.getPower() + '/'
+ c.getToughness() : "-"; + c.getToughness() : "-";

View file

@ -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"));
}
}

View file

@ -972,4 +972,28 @@ public class CardView extends SimpleCardView {
return ""; 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();
}
} }