consolidate duplicate implementations as default methods in IRenderableCard
parent
59ee8699b9
commit
a6830b0786
|
@ -209,10 +209,6 @@ public class MagicCard
|
|||
return getCost().getConvertedCost();
|
||||
}
|
||||
|
||||
public MagicManaCost getCost() {
|
||||
return getCardDefinition().getCost();
|
||||
}
|
||||
|
||||
public MagicManaCost getGameCost() {
|
||||
return getGame().modCost(this, getCost());
|
||||
}
|
||||
|
@ -494,34 +490,12 @@ public class MagicCard
|
|||
return counters.keySet();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getText() {
|
||||
//Returns oracle text, no in-game changes
|
||||
return getCardDefinition().getText();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Collection<MagicManaActivation> getManaActivations() {
|
||||
// Returning from CardDefinition - Cards technically don't, also no in-game changes
|
||||
return getCardDefinition().getManaActivations();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getNumColors() {
|
||||
int numColors = 0;
|
||||
for (final MagicColor color : MagicColor.values()) {
|
||||
if (hasColor(color)) {
|
||||
numColors++;
|
||||
}
|
||||
}
|
||||
return numColors;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getImageName() {
|
||||
return getCardDefinition().getImageName();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getPowerToughnessText() {
|
||||
if (isCreature()) {
|
||||
|
@ -530,75 +504,4 @@ public class MagicCard
|
|||
return "";
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getSubTypeText() {
|
||||
// Returning from CardDefinition, no in-game changes
|
||||
return getCardDefinition().getSubTypeText();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Set<MagicType> getTypes() {
|
||||
Set<MagicType> types = new HashSet<MagicType>();
|
||||
for (MagicType type : MagicType.values()) {
|
||||
if (hasType(type)) {
|
||||
types.add(type);
|
||||
}
|
||||
}
|
||||
return types;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isHybrid() {
|
||||
final List<MagicIcon> list = getCost().getIcons();
|
||||
//If doesn't contain single color mana, and does contain hybrid mana. Checks for absence
|
||||
return Collections.disjoint(list, MagicIcon.COLOR_MANA) && !Collections.disjoint(list, MagicIcon.HYBRID_COLOR_MANA);
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isMulti() {
|
||||
return getNumColors() > 1;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasText() {
|
||||
return cardDefinition.hasText();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getStartingLoyalty() {
|
||||
return getCardDefinition().getStartingLoyalty();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isCreature() {return hasType(MagicType.Creature);}
|
||||
|
||||
@Override
|
||||
public boolean isArtifact() {return hasType(MagicType.Artifact);}
|
||||
|
||||
@Override
|
||||
public boolean isLand() {return hasType(MagicType.Land);}
|
||||
|
||||
@Override
|
||||
public boolean isEnchantment() {return hasType(MagicType.Enchantment);}
|
||||
|
||||
@Override
|
||||
public boolean isInstant() {return hasType(MagicType.Instant);}
|
||||
|
||||
@Override
|
||||
public boolean isSorcery() {return hasType(MagicType.Sorcery);}
|
||||
|
||||
@Override
|
||||
public boolean isHidden() {return cardDefinition.isHidden();}
|
||||
|
||||
@Override
|
||||
public Character getRarityChar() {
|
||||
return cardDefinition.getRarityChar();
|
||||
}
|
||||
|
||||
@Override
|
||||
public MagicCardDefinition getTransformedDefinition() {
|
||||
return cardDefinition.getTransformedDefinition();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -394,6 +394,10 @@ public class MagicCardDefinition implements MagicAbilityStore, IRenderableCard {
|
|||
return transformCardDefinition;
|
||||
}
|
||||
|
||||
public MagicCardDefinition getCardDefinition() {
|
||||
return this;
|
||||
}
|
||||
|
||||
public boolean isBasic() {
|
||||
return hasType(MagicType.Basic);
|
||||
}
|
||||
|
@ -1033,12 +1037,6 @@ public class MagicCardDefinition implements MagicAbilityStore, IRenderableCard {
|
|||
return MagicFileSystem.getCardImageFile(this).exists() == false;
|
||||
}
|
||||
|
||||
public boolean isHybrid() {
|
||||
final List<MagicIcon> list = getCost().getIcons();
|
||||
//If doesn't contain single color mana, and does contain hybrid mana. Checks for absence
|
||||
return Collections.disjoint(list, MagicIcon.COLOR_MANA) && !Collections.disjoint(list, MagicIcon.HYBRID_COLOR_MANA);
|
||||
}
|
||||
|
||||
public void setPowerToughnessText(String string) {
|
||||
powerToughnessText = string;
|
||||
}
|
||||
|
@ -1072,33 +1070,6 @@ public class MagicCardDefinition implements MagicAbilityStore, IRenderableCard {
|
|||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getNumColors() {
|
||||
int numColors = 0;
|
||||
for (final MagicColor color : MagicColor.values()) {
|
||||
if (hasColor(color)) {
|
||||
numColors++;
|
||||
}
|
||||
}
|
||||
return numColors;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Set<MagicType> getTypes() {
|
||||
Set<MagicType> types = new HashSet<MagicType>();
|
||||
for (MagicType type : MagicType.values()) {
|
||||
if (hasType(type)) {
|
||||
types.add(type);
|
||||
}
|
||||
}
|
||||
return types;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isMulti() {
|
||||
return getNumColors() > 1;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasText() {
|
||||
if (getText().contains("NONE") || getText().length() <=1) {
|
||||
|
|
|
@ -1122,10 +1122,6 @@ public class MagicPermanent extends MagicObjectImpl implements MagicSource,Magic
|
|||
return hasType(MagicType.Basic);
|
||||
}
|
||||
|
||||
public boolean isLand() {
|
||||
return hasType(MagicType.Land);
|
||||
}
|
||||
|
||||
public boolean isEquipment() {
|
||||
return isArtifact() && hasSubType(MagicSubType.Equipment);
|
||||
}
|
||||
|
@ -1332,39 +1328,11 @@ public class MagicPermanent extends MagicObjectImpl implements MagicSource,Magic
|
|||
}
|
||||
};
|
||||
|
||||
@Override
|
||||
public MagicManaCost getCost() {
|
||||
// Returning from CardDefinition, no in-game changes
|
||||
return getCardDefinition().getCost();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getText() {
|
||||
// Returning from CardDefinition, no in-game changes
|
||||
return getCardDefinition().getText();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Set<MagicSubType> getSubTypes() {
|
||||
return EnumSet.copyOf(cachedSubTypeFlags);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getNumColors() {
|
||||
int numColors = 0;
|
||||
for (final MagicColor color : MagicColor.values()) {
|
||||
if (hasColor(color)) {
|
||||
numColors++;
|
||||
}
|
||||
}
|
||||
return numColors;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getImageName() {
|
||||
return getCardDefinition().getImageName();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getPowerToughnessText() {
|
||||
if (isCreature()) {
|
||||
|
@ -1373,63 +1341,4 @@ public class MagicPermanent extends MagicObjectImpl implements MagicSource,Magic
|
|||
return "";
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getSubTypeText() {
|
||||
// Returning from CardDefinition, no in-game changes
|
||||
return getCardDefinition().getSubTypeText();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Set<MagicType> getTypes() {
|
||||
Set<MagicType> types = new HashSet<MagicType>();
|
||||
for (MagicType type : MagicType.values()) {
|
||||
if (hasType(type)) {
|
||||
types.add(type);
|
||||
}
|
||||
}
|
||||
return types;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isHybrid() {
|
||||
final List<MagicIcon> list = getCost().getIcons();
|
||||
//If doesn't contain single color mana, and does contain hybrid mana. Checks for absence
|
||||
return Collections.disjoint(list, MagicIcon.COLOR_MANA) && !Collections.disjoint(list, MagicIcon.HYBRID_COLOR_MANA);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isMulti() {
|
||||
return getNumColors() > 1;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasText() {
|
||||
return cardDefinition.hasText();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getStartingLoyalty() {
|
||||
return getCardDefinition().getStartingLoyalty();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isSorcery() {return hasType(MagicType.Sorcery);}
|
||||
|
||||
@Override
|
||||
public boolean isInstant() {return hasType(MagicType.Instant);}
|
||||
|
||||
@Override
|
||||
public boolean isHidden() {return cardDefinition.isHidden();}
|
||||
|
||||
@Override
|
||||
public Character getRarityChar(){
|
||||
return cardDefinition.getRarityChar();
|
||||
}
|
||||
|
||||
@Override
|
||||
public MagicCardDefinition getTransformedDefinition() {
|
||||
return cardDefinition.getTransformedDefinition();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -1,7 +1,10 @@
|
|||
package magic.ui.cardBuilder;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
import java.util.HashSet;
|
||||
|
||||
import magic.model.MagicAbility;
|
||||
import magic.model.MagicCardDefinition;
|
||||
|
@ -10,39 +13,114 @@ import magic.model.MagicManaCost;
|
|||
import magic.model.MagicSubType;
|
||||
import magic.model.MagicType;
|
||||
import magic.model.event.MagicManaActivation;
|
||||
import magic.data.MagicIcon;
|
||||
|
||||
public interface IRenderableCard {
|
||||
|
||||
MagicManaCost getCost();
|
||||
String getText();
|
||||
Collection<MagicManaActivation> getManaActivations();
|
||||
Set<MagicSubType> getSubTypes();
|
||||
int getColorFlags();
|
||||
int getNumColors();
|
||||
String getImageName();
|
||||
String getPowerToughnessText();
|
||||
String getName();
|
||||
String getSubTypeText();
|
||||
Set<MagicType> getTypes();
|
||||
boolean hasSubType(MagicSubType subType);
|
||||
boolean hasColor(MagicColor color);
|
||||
boolean isHybrid();
|
||||
boolean isMulti();
|
||||
boolean hasType(MagicType type);
|
||||
boolean isToken();
|
||||
boolean isFlipCard();
|
||||
boolean isDoubleFaced();
|
||||
boolean hasAbility(MagicAbility ability);
|
||||
boolean hasText();
|
||||
int getStartingLoyalty();
|
||||
boolean isPlaneswalker();
|
||||
boolean isCreature();
|
||||
boolean isLand();
|
||||
boolean isArtifact();
|
||||
boolean isSorcery();
|
||||
boolean isInstant();
|
||||
boolean isEnchantment();
|
||||
boolean isHidden();
|
||||
Character getRarityChar();
|
||||
MagicCardDefinition getTransformedDefinition();
|
||||
MagicCardDefinition getCardDefinition();
|
||||
|
||||
default MagicCardDefinition getTransformedDefinition() {
|
||||
return getCardDefinition().getTransformedDefinition();
|
||||
}
|
||||
|
||||
default boolean isLand() {
|
||||
return hasType(MagicType.Land);
|
||||
}
|
||||
|
||||
default boolean isHybrid() {
|
||||
final List<MagicIcon> list = getCost().getIcons();
|
||||
//If doesn't contain single color mana, and does contain hybrid mana. Checks for absence
|
||||
return Collections.disjoint(list, MagicIcon.COLOR_MANA) && !Collections.disjoint(list, MagicIcon.HYBRID_COLOR_MANA);
|
||||
}
|
||||
default boolean isMulti() {
|
||||
return getNumColors() > 1;
|
||||
}
|
||||
|
||||
default int getStartingLoyalty() {
|
||||
return getCardDefinition().getStartingLoyalty();
|
||||
}
|
||||
|
||||
default boolean isCreature() {
|
||||
return hasType(MagicType.Creature);
|
||||
}
|
||||
|
||||
default boolean isArtifact() {
|
||||
return hasType(MagicType.Artifact);
|
||||
}
|
||||
|
||||
default boolean isEnchantment() {
|
||||
return hasType(MagicType.Enchantment);
|
||||
}
|
||||
|
||||
default boolean isInstant() {
|
||||
return hasType(MagicType.Instant);
|
||||
}
|
||||
|
||||
default boolean isSorcery() {
|
||||
return hasType(MagicType.Sorcery);
|
||||
}
|
||||
|
||||
default boolean isHidden() {
|
||||
return getCardDefinition().isHidden();
|
||||
}
|
||||
|
||||
default Character getRarityChar() {
|
||||
return getCardDefinition().getRarityChar();
|
||||
}
|
||||
|
||||
default boolean hasText() {
|
||||
return getCardDefinition().hasText();
|
||||
}
|
||||
|
||||
default int getNumColors() {
|
||||
int numColors = 0;
|
||||
for (final MagicColor color : MagicColor.values()) {
|
||||
if (hasColor(color)) {
|
||||
numColors++;
|
||||
}
|
||||
}
|
||||
return numColors;
|
||||
}
|
||||
|
||||
default Set<MagicType> getTypes() {
|
||||
Set<MagicType> types = new HashSet<MagicType>();
|
||||
for (MagicType type : MagicType.values()) {
|
||||
if (hasType(type)) {
|
||||
types.add(type);
|
||||
}
|
||||
}
|
||||
return types;
|
||||
}
|
||||
|
||||
default String getSubTypeText() {
|
||||
// returning from CardDefinition, no in-game changes
|
||||
return getCardDefinition().getSubTypeText();
|
||||
}
|
||||
|
||||
default String getImageName() {
|
||||
return getCardDefinition().getImageName();
|
||||
}
|
||||
|
||||
default String getText() {
|
||||
// returns oracle text, no in-game changes
|
||||
return getCardDefinition().getText();
|
||||
}
|
||||
|
||||
default MagicManaCost getCost() {
|
||||
// returning from CardDefinition, no in-game changes
|
||||
return getCardDefinition().getCost();
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue