mirror of
https://github.com/correl/mage.git
synced 2024-12-24 11:50:45 +00:00
remove CardHelper class
This commit is contained in:
parent
22e376699e
commit
08197f192c
5 changed files with 27 additions and 99 deletions
|
@ -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();
|
||||
}
|
||||
|
||||
}
|
|
@ -79,8 +79,8 @@ public class MageCardComparator implements Comparator<CardView> {
|
|||
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:
|
||||
|
|
|
@ -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() : "-";
|
||||
|
|
|
@ -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"));
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
|
@ -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();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue