2013-04-12 19:32:25 -07:00
|
|
|
package magic.model;
|
|
|
|
|
2020-01-15 12:02:42 -08:00
|
|
|
import java.util.ArrayList;
|
|
|
|
import java.util.Collection;
|
|
|
|
import java.util.Collections;
|
|
|
|
import java.util.Comparator;
|
|
|
|
import java.util.Date;
|
|
|
|
import java.util.EnumSet;
|
|
|
|
import java.util.LinkedList;
|
|
|
|
import java.util.List;
|
|
|
|
import java.util.Locale;
|
|
|
|
import java.util.Set;
|
2018-04-07 17:59:14 -07:00
|
|
|
|
2013-04-12 19:32:25 -07:00
|
|
|
import magic.ai.ArtificialScoringSystem;
|
2013-10-17 01:27:46 -07:00
|
|
|
import magic.data.CardDefinitions;
|
2014-04-18 06:58:52 -07:00
|
|
|
import magic.data.CardProperty;
|
2020-01-15 12:02:42 -08:00
|
|
|
import magic.model.condition.MagicCondition;
|
|
|
|
import magic.model.event.MagicActivation;
|
|
|
|
import magic.model.event.MagicActivationHints;
|
|
|
|
import magic.model.event.MagicAdditionalCost;
|
|
|
|
import magic.model.event.MagicCardEvent;
|
|
|
|
import magic.model.event.MagicEvent;
|
|
|
|
import magic.model.event.MagicEventSource;
|
|
|
|
import magic.model.event.MagicHandCastActivation;
|
|
|
|
import magic.model.event.MagicManaActivation;
|
|
|
|
import magic.model.event.MagicPayManaCostEvent;
|
|
|
|
import magic.model.event.MagicPermanentActivation;
|
|
|
|
import magic.model.event.MagicPlayCardEvent;
|
|
|
|
import magic.model.event.MagicTiming;
|
2013-04-12 19:32:25 -07:00
|
|
|
import magic.model.mstatic.MagicCDA;
|
|
|
|
import magic.model.mstatic.MagicStatic;
|
2018-05-03 23:17:55 -07:00
|
|
|
import magic.model.trigger.AtBeginOfFirstMainPhaseTrigger;
|
2015-11-22 07:33:59 -08:00
|
|
|
import magic.model.trigger.EntersBattlefieldTrigger;
|
2015-11-21 05:01:25 -08:00
|
|
|
import magic.model.trigger.EntersWithCounterTrigger;
|
2016-01-05 10:14:51 -08:00
|
|
|
import magic.model.trigger.MagicTrigger;
|
|
|
|
import magic.model.trigger.ThisCycleTrigger;
|
2015-11-26 04:55:01 -08:00
|
|
|
import magic.model.trigger.ThisDrawnTrigger;
|
2015-11-24 07:24:48 -08:00
|
|
|
import magic.model.trigger.ThisPutIntoGraveyardTrigger;
|
2015-11-24 06:42:52 -08:00
|
|
|
import magic.model.trigger.ThisSpellIsCastTrigger;
|
2017-01-21 07:46:54 -08:00
|
|
|
import magic.ui.MagicCardImages;
|
2013-04-12 19:32:25 -07:00
|
|
|
|
2015-12-19 08:27:28 -08:00
|
|
|
public class MagicCardDefinition implements MagicAbilityStore, IRenderableCard {
|
2013-04-12 19:32:25 -07:00
|
|
|
|
2017-05-05 05:09:11 -07:00
|
|
|
/**
|
|
|
|
* Comparator for sorting instances of {@code MagicCardDefinition} by distinct name.
|
|
|
|
*/
|
|
|
|
public static final Comparator<MagicCardDefinition> SORT_BY_NAME =
|
2018-04-07 17:59:14 -07:00
|
|
|
Comparator.comparing(MagicCardDefinition::getDistinctName);
|
2017-05-05 05:09:11 -07:00
|
|
|
|
2016-08-29 03:39:59 -07:00
|
|
|
private static final List<String> unsupportedStatuses = new ArrayList<>();
|
|
|
|
private static boolean isSorted = false;
|
|
|
|
|
2013-04-12 19:32:25 -07:00
|
|
|
public static final MagicCardDefinition UNKNOWN = new MagicCardDefinition() {
|
|
|
|
//definition for unknown cards
|
|
|
|
@Override
|
|
|
|
protected void initialize() {
|
|
|
|
setName("Unknown");
|
2015-05-09 07:01:39 -07:00
|
|
|
setDistinctName("Unknown");
|
2013-04-12 19:32:25 -07:00
|
|
|
setToken();
|
|
|
|
setValue(1);
|
|
|
|
addType(MagicType.Creature);
|
2016-01-06 17:43:52 -08:00
|
|
|
setColors("");
|
2013-04-12 19:32:25 -07:00
|
|
|
setPowerToughness(1,1);
|
|
|
|
setTiming(MagicTiming.Main);
|
2014-08-03 05:26:20 -07:00
|
|
|
setIndex(1000000);
|
2013-04-12 19:32:25 -07:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
// name displayed in UI, may be repeated in tokens
|
|
|
|
private String name;
|
|
|
|
|
|
|
|
// name used for mapping and persistence, must be unique
|
2015-05-09 07:01:39 -07:00
|
|
|
private String distinctName;
|
2015-06-16 11:38:33 -07:00
|
|
|
|
2013-04-12 19:32:25 -07:00
|
|
|
private String imageURL;
|
2015-03-10 06:44:17 -07:00
|
|
|
private Date imageUpdated;
|
2013-04-12 19:32:25 -07:00
|
|
|
private int index=-1;
|
|
|
|
private double value;
|
|
|
|
private int removal;
|
|
|
|
private int score=-1; // not initialized
|
|
|
|
private MagicRarity rarity;
|
2015-09-10 18:53:57 -07:00
|
|
|
private boolean valid = true;
|
2016-07-18 09:43:17 -07:00
|
|
|
private boolean token;
|
|
|
|
private boolean secondHalf;
|
|
|
|
private boolean hidden;
|
|
|
|
private boolean overlay;
|
|
|
|
private boolean excludeManaOrCombat;
|
2013-04-12 19:32:25 -07:00
|
|
|
private int typeFlags;
|
2015-05-12 21:50:41 -07:00
|
|
|
private EnumSet<MagicType> cardType = EnumSet.noneOf(MagicType.class);
|
2013-04-12 19:32:25 -07:00
|
|
|
private EnumSet<MagicSubType> subTypeFlags = EnumSet.noneOf(MagicSubType.class);
|
2015-12-19 08:27:28 -08:00
|
|
|
private String subTypeText ="";
|
2013-04-12 19:32:25 -07:00
|
|
|
private EnumSet<MagicAbility> abilityFlags = EnumSet.noneOf(MagicAbility.class);
|
2013-06-23 06:19:01 -07:00
|
|
|
private int colorFlags = -1;
|
2016-01-05 17:43:19 -08:00
|
|
|
private MagicManaCost cost = MagicManaCost.NONE;
|
2013-04-12 19:32:25 -07:00
|
|
|
private String manaSourceText="";
|
|
|
|
private final int[] manaSource=new int[MagicColor.NR_COLORS];
|
|
|
|
private int power;
|
|
|
|
private int toughness;
|
2015-12-19 08:27:28 -08:00
|
|
|
private String powerToughnessText = "";
|
2015-06-20 20:10:13 -07:00
|
|
|
private int startingLoyalty;
|
2013-04-12 19:32:25 -07:00
|
|
|
private String text = "";
|
|
|
|
private MagicStaticType staticType=MagicStaticType.None;
|
|
|
|
private MagicTiming timing=MagicTiming.None;
|
|
|
|
private MagicCardEvent cardEvent=MagicPlayCardEvent.create();
|
2018-04-07 17:59:14 -07:00
|
|
|
private final Collection<MagicActivation<MagicPermanent>> permActivations= new ArrayList<>();
|
|
|
|
private final Collection<MagicActivation<MagicPermanent>> morphActivations= new ArrayList<>();
|
|
|
|
private final LinkedList<MagicActivation<MagicCard>> handActivations = new LinkedList<>();
|
|
|
|
private final LinkedList<MagicActivation<MagicCard>> graveyardActivations = new LinkedList<>();
|
|
|
|
private final Collection<MagicCDA> CDAs = new ArrayList<>();
|
|
|
|
private final Collection<MagicTrigger<?>> triggers = new ArrayList<>();
|
|
|
|
private final Collection<MagicStatic> statics= new ArrayList<>();
|
|
|
|
private final LinkedList<EntersBattlefieldTrigger> etbTriggers = new LinkedList<>();
|
|
|
|
private final Collection<ThisSpellIsCastTrigger> spellIsCastTriggers = new ArrayList<>();
|
|
|
|
private final Collection<ThisCycleTrigger> cycleTriggers = new ArrayList<>();
|
|
|
|
private final Collection<ThisDrawnTrigger> drawnTriggers = new ArrayList<>();
|
|
|
|
private final Collection<ThisPutIntoGraveyardTrigger> putIntoGraveyardTriggers = new ArrayList<>();
|
|
|
|
private final Collection<MagicManaActivation> manaActivations= new ArrayList<>();
|
|
|
|
private final Collection<MagicEventSource> costEventSources= new ArrayList<>();
|
2015-06-16 11:38:33 -07:00
|
|
|
|
2014-08-06 08:29:43 -07:00
|
|
|
private MagicCardDefinition flipCardDefinition;
|
|
|
|
private MagicCardDefinition transformCardDefinition;
|
2016-01-31 07:06:24 -08:00
|
|
|
private MagicCardDefinition splitCardDefinition;
|
2013-04-12 19:32:25 -07:00
|
|
|
|
2013-10-21 23:39:48 -07:00
|
|
|
private String abilityProperty;
|
2013-04-12 19:32:25 -07:00
|
|
|
private String requiresGroovy;
|
2014-08-15 01:18:54 -07:00
|
|
|
private String effectProperty;
|
2014-08-17 13:54:38 -07:00
|
|
|
private String flipCardName;
|
2014-08-17 13:31:48 -07:00
|
|
|
private String transformCardName;
|
2016-07-18 05:38:56 -07:00
|
|
|
private String[] meldCardNames;
|
2016-01-31 07:06:24 -08:00
|
|
|
private String splitCardName;
|
2016-07-18 09:41:46 -07:00
|
|
|
private String status;
|
2013-06-23 18:33:35 -07:00
|
|
|
|
2013-04-12 19:32:25 -07:00
|
|
|
public MagicCardDefinition() {
|
2013-06-23 18:33:35 -07:00
|
|
|
initialize();
|
2013-04-12 19:32:25 -07:00
|
|
|
}
|
2015-06-16 11:38:33 -07:00
|
|
|
|
2016-09-23 22:21:56 -07:00
|
|
|
public static MagicCardDefinition token(final MagicObject obj, final MagicCardDefinitionInit init) {
|
|
|
|
return token(obj.getCardDefinition(), init);
|
2014-07-27 22:05:25 -07:00
|
|
|
}
|
2013-06-23 18:33:35 -07:00
|
|
|
|
2016-09-23 22:21:56 -07:00
|
|
|
public static MagicCardDefinition token(final MagicCardDefinition template, final MagicCardDefinitionInit init) {
|
2016-06-17 19:07:16 -07:00
|
|
|
final MagicCardDefinition cdef = new MagicCardDefinition();
|
|
|
|
cdef.setName(template.getName());
|
|
|
|
cdef.setDistinctName(template.getDistinctName());
|
|
|
|
cdef.setPowerToughness(template.getCardPower(), template.getCardToughness());
|
2017-01-31 05:47:24 -08:00
|
|
|
cdef.setPowerToughnessText(template.getPowerToughnessText());
|
2016-06-17 19:07:16 -07:00
|
|
|
cdef.setColorFlags(template.getColorFlags());
|
|
|
|
cdef.setSubTypes(template.genSubTypes());
|
2017-01-31 05:47:24 -08:00
|
|
|
cdef.setSubTypeText(template.getSubTypeText());
|
|
|
|
for (final MagicType t : template.getTypes()) {
|
|
|
|
cdef.addType(t);
|
|
|
|
}
|
|
|
|
if (template.hasExcludeManaOrCombat()) {
|
|
|
|
cdef.setExcludeManaOrCombat();
|
|
|
|
}
|
|
|
|
cdef.manaSourceText = template.manaSourceText;
|
|
|
|
cdef.setEvent(template.getCardEvent());
|
|
|
|
cdef.setText(template.getText());
|
2016-06-17 19:07:16 -07:00
|
|
|
cdef.setValue(template.getValue());
|
2016-07-18 09:41:46 -07:00
|
|
|
cdef.setStatus(template.getStatus());
|
2017-01-31 05:47:24 -08:00
|
|
|
|
|
|
|
cdef.setStartingLoyalty(template.getStartingLoyalty());
|
|
|
|
cdef.setAbilityProperty(template.abilityProperty);
|
|
|
|
cdef.setRequiresGroovy(template.requiresGroovy);
|
|
|
|
cdef.abilityFlags.addAll(template.abilityFlags);
|
|
|
|
cdef.permActivations.addAll(template.permActivations);
|
|
|
|
cdef.morphActivations.addAll(template.morphActivations);
|
|
|
|
cdef.CDAs.addAll(template.CDAs);
|
|
|
|
cdef.triggers.addAll(template.triggers);
|
|
|
|
cdef.statics.addAll(template.statics);
|
|
|
|
cdef.etbTriggers.addAll(template.etbTriggers);
|
|
|
|
cdef.manaActivations.addAll(template.manaActivations);
|
|
|
|
|
|
|
|
cdef.setToken();
|
2016-06-17 19:07:16 -07:00
|
|
|
init.initialize(cdef);
|
|
|
|
cdef.validate();
|
|
|
|
return cdef;
|
|
|
|
}
|
|
|
|
|
2016-03-26 04:10:02 -07:00
|
|
|
public boolean canHaveAnyNumberInDeck() {
|
|
|
|
return hasType(MagicType.Basic)
|
2018-06-20 19:39:27 -07:00
|
|
|
|| MagicDeckConstructionRule.isUnlimitedCard(name);
|
2016-03-26 04:10:02 -07:00
|
|
|
}
|
|
|
|
|
2013-04-12 19:32:25 -07:00
|
|
|
protected void initialize() {}
|
|
|
|
|
2013-10-21 23:39:48 -07:00
|
|
|
public void setAbilityProperty(final String value) {
|
|
|
|
abilityProperty = value;
|
|
|
|
}
|
2013-04-12 19:32:25 -07:00
|
|
|
|
|
|
|
public void setRequiresGroovy(final String value) {
|
|
|
|
requiresGroovy = value;
|
|
|
|
}
|
2015-06-16 11:38:33 -07:00
|
|
|
|
2014-08-15 01:18:54 -07:00
|
|
|
public void setEffectProperty(final String value) {
|
|
|
|
effectProperty = value;
|
|
|
|
}
|
2015-06-16 11:38:33 -07:00
|
|
|
|
2014-08-17 13:54:38 -07:00
|
|
|
public void setFlipCardName(final String value) {
|
|
|
|
flipCardName = value;
|
2014-08-05 11:43:05 -07:00
|
|
|
}
|
2015-06-16 11:38:33 -07:00
|
|
|
|
2014-08-17 13:31:48 -07:00
|
|
|
public void setTransformCardName(final String value) {
|
|
|
|
transformCardName = value;
|
2014-08-06 08:29:43 -07:00
|
|
|
}
|
2015-06-16 11:38:33 -07:00
|
|
|
|
2016-07-18 05:38:56 -07:00
|
|
|
public void setMeldCardNames(final String[] value) {
|
|
|
|
meldCardNames = value;
|
|
|
|
}
|
|
|
|
|
2016-01-31 07:06:24 -08:00
|
|
|
public void setSplitCardName(final String value) {
|
|
|
|
splitCardName = value;
|
|
|
|
}
|
|
|
|
|
2016-01-31 08:49:00 -08:00
|
|
|
public void setSecondHalf() {
|
|
|
|
secondHalf = true;
|
|
|
|
}
|
|
|
|
|
2017-06-16 20:19:03 -07:00
|
|
|
@Override
|
2016-01-31 08:49:00 -08:00
|
|
|
public boolean isSecondHalf() {
|
|
|
|
return secondHalf;
|
|
|
|
}
|
|
|
|
|
2014-08-05 14:26:47 -07:00
|
|
|
public void setHidden() {
|
|
|
|
hidden = true;
|
|
|
|
}
|
2015-11-21 05:01:25 -08:00
|
|
|
|
2017-06-16 20:19:03 -07:00
|
|
|
@Override
|
2014-08-05 14:26:47 -07:00
|
|
|
public boolean isHidden() {
|
|
|
|
return hidden;
|
|
|
|
}
|
2015-11-21 05:01:25 -08:00
|
|
|
|
2015-09-10 18:53:57 -07:00
|
|
|
public void setOverlay() {
|
|
|
|
overlay = true;
|
|
|
|
}
|
2015-11-21 05:01:25 -08:00
|
|
|
|
2015-09-10 18:53:57 -07:00
|
|
|
public boolean isOverlay() {
|
|
|
|
return overlay;
|
|
|
|
}
|
|
|
|
|
|
|
|
public boolean isPlayable() {
|
2016-07-18 09:43:17 -07:00
|
|
|
return !overlay && !token && !hidden && !secondHalf;
|
2015-09-10 18:53:57 -07:00
|
|
|
}
|
2015-11-21 05:01:25 -08:00
|
|
|
|
2015-09-10 18:53:57 -07:00
|
|
|
public boolean isNonPlayable() {
|
2016-07-18 09:43:17 -07:00
|
|
|
return !isPlayable();
|
2015-09-10 18:53:57 -07:00
|
|
|
}
|
2013-04-12 19:32:25 -07:00
|
|
|
|
2015-12-17 06:08:47 -08:00
|
|
|
public synchronized void loadAbilities() {
|
2017-08-08 02:39:35 -07:00
|
|
|
if (isPlayable() && (hasCost() || isLand()) && handActivations.isEmpty()) {
|
|
|
|
add(new MagicHandCastActivation(this));
|
2018-04-05 05:21:52 -07:00
|
|
|
if (isLegendary() && isSorcery()) {
|
|
|
|
add(MagicAdditionalCost.create(MagicCondition.LEGENDARY_SORCERY));
|
|
|
|
}
|
2017-08-08 02:39:35 -07:00
|
|
|
}
|
2016-01-10 10:14:09 -08:00
|
|
|
if (startingLoyalty > 0 && etbTriggers.isEmpty()) {
|
2015-11-21 05:01:25 -08:00
|
|
|
add(new EntersWithCounterTrigger(
|
2015-06-20 21:23:45 -07:00
|
|
|
MagicCounterType.Loyalty,
|
|
|
|
startingLoyalty
|
|
|
|
));
|
|
|
|
}
|
2018-05-03 23:17:55 -07:00
|
|
|
if (isSaga() && etbTriggers.isEmpty()) {
|
|
|
|
add(new EntersWithCounterTrigger(MagicCounterType.Lore, 1));
|
|
|
|
add(AtBeginOfFirstMainPhaseTrigger.Saga);
|
|
|
|
}
|
2013-04-12 19:32:25 -07:00
|
|
|
if (requiresGroovy != null) {
|
|
|
|
CardProperty.LOAD_GROOVY_CODE.setProperty(this, requiresGroovy);
|
|
|
|
requiresGroovy = null;
|
|
|
|
}
|
2013-10-21 23:39:48 -07:00
|
|
|
if (abilityProperty != null) {
|
|
|
|
CardProperty.LOAD_ABILITY.setProperty(this, abilityProperty);
|
|
|
|
abilityProperty = null;
|
|
|
|
}
|
2014-08-15 01:18:54 -07:00
|
|
|
if (effectProperty != null) {
|
|
|
|
CardProperty.LOAD_EFFECT.setProperty(this, effectProperty);
|
|
|
|
effectProperty = null;
|
|
|
|
}
|
2014-08-17 13:52:38 -07:00
|
|
|
if (getFlippedDefinition().isHidden()) {
|
2014-08-09 22:22:47 -07:00
|
|
|
flipCardDefinition.loadAbilities();
|
2014-08-05 20:51:09 -07:00
|
|
|
}
|
2014-08-17 13:33:49 -07:00
|
|
|
if (getTransformedDefinition().isHidden()) {
|
2014-08-09 22:22:47 -07:00
|
|
|
transformCardDefinition.loadAbilities();
|
2014-08-06 08:29:43 -07:00
|
|
|
}
|
2016-01-31 08:49:00 -08:00
|
|
|
if (getSplitDefinition().isSecondHalf()) {
|
2016-01-31 07:06:24 -08:00
|
|
|
splitCardDefinition.loadAbilities();
|
|
|
|
}
|
2013-04-12 19:32:25 -07:00
|
|
|
}
|
2013-06-23 18:33:35 -07:00
|
|
|
|
2013-04-12 19:32:25 -07:00
|
|
|
public boolean isValid() {
|
2015-09-10 18:53:57 -07:00
|
|
|
return valid;
|
2014-06-02 12:36:18 -07:00
|
|
|
}
|
2015-06-16 11:38:33 -07:00
|
|
|
|
2017-07-21 03:10:11 -07:00
|
|
|
@Override
|
2015-05-13 20:30:15 -07:00
|
|
|
public boolean isInvalid() {
|
2016-07-18 09:43:17 -07:00
|
|
|
return !valid;
|
2015-05-13 20:30:15 -07:00
|
|
|
}
|
2015-06-16 11:38:33 -07:00
|
|
|
|
2015-05-13 20:33:02 -07:00
|
|
|
public void setInvalid() {
|
2015-09-10 18:53:57 -07:00
|
|
|
valid = false;
|
2013-04-12 19:32:25 -07:00
|
|
|
}
|
|
|
|
|
2015-03-10 06:44:17 -07:00
|
|
|
public void setImageUpdated(final Date d) {
|
|
|
|
imageUpdated = d;
|
2013-04-12 19:32:25 -07:00
|
|
|
}
|
|
|
|
|
2015-11-16 05:41:00 -08:00
|
|
|
/**
|
|
|
|
* Returns true if script file has a non-null {@code image_updated} property
|
|
|
|
* whose value is a date that comes after the given date.
|
|
|
|
*/
|
2015-03-14 13:47:49 -07:00
|
|
|
public boolean isImageUpdatedAfter(final Date d) {
|
2015-03-10 06:44:17 -07:00
|
|
|
return imageUpdated != null && imageUpdated.after(d);
|
2013-04-12 19:32:25 -07:00
|
|
|
}
|
2013-06-23 18:33:35 -07:00
|
|
|
|
2015-05-09 07:48:03 -07:00
|
|
|
/**
|
|
|
|
* Returns the name of the card exactly as it appears on the printed card.
|
|
|
|
* <p>
|
|
|
|
* Note that in the case of token cards this means it may return the
|
|
|
|
* same name (eg. five different Wurm tokens would all return "Wurm").
|
|
|
|
*
|
|
|
|
* @see getDistinctName()
|
|
|
|
*/
|
2017-06-16 20:19:03 -07:00
|
|
|
@Override
|
2013-04-12 19:32:25 -07:00
|
|
|
public String getName() {
|
|
|
|
return name;
|
|
|
|
}
|
2013-06-23 18:33:35 -07:00
|
|
|
|
2013-04-12 19:32:25 -07:00
|
|
|
public void setName(final String name) {
|
|
|
|
this.name = name;
|
|
|
|
}
|
2013-06-23 18:33:35 -07:00
|
|
|
|
2015-05-09 07:48:03 -07:00
|
|
|
/**
|
|
|
|
* Returns a guaranteed distinct card name.
|
|
|
|
* <p>
|
|
|
|
* In most cases this will be the same as {@link getName()} but for tokens
|
|
|
|
* of the same type (eg. Wurm) this will return a name that clearly identifies
|
|
|
|
* the card (eg. 5/5 green Wurm creature token with trample).
|
|
|
|
*
|
|
|
|
*/
|
2015-05-09 07:01:39 -07:00
|
|
|
public String getDistinctName() {
|
2015-05-12 21:26:30 -07:00
|
|
|
return distinctName;
|
2013-04-12 19:32:25 -07:00
|
|
|
}
|
|
|
|
|
2015-05-09 08:12:14 -07:00
|
|
|
public void setDistinctName(String aName) {
|
2016-07-18 20:46:40 -07:00
|
|
|
assert !name.equals(aName) || name == aName : "Same name but using two separate strings. Should reference same string for efficiency.";
|
2015-05-09 08:12:14 -07:00
|
|
|
distinctName = aName;
|
2013-04-12 19:32:25 -07:00
|
|
|
}
|
2013-06-23 18:33:35 -07:00
|
|
|
|
2015-05-08 22:15:01 -07:00
|
|
|
/**
|
|
|
|
* Returns the name of the card containing only ASCII characters.
|
|
|
|
*/
|
|
|
|
public String getAsciiName() {
|
2015-05-09 07:01:39 -07:00
|
|
|
return CardDefinitions.getASCII(distinctName);
|
2015-05-08 22:15:01 -07:00
|
|
|
}
|
2015-06-16 11:38:33 -07:00
|
|
|
|
2015-05-08 22:15:01 -07:00
|
|
|
/**
|
|
|
|
* Returns the name of the script/groovy file without extension
|
|
|
|
*/
|
|
|
|
public String getFilename() {
|
2015-05-09 07:01:39 -07:00
|
|
|
return CardDefinitions.getCanonicalName(distinctName);
|
2015-05-08 22:15:01 -07:00
|
|
|
}
|
|
|
|
|
2013-04-12 19:32:25 -07:00
|
|
|
public void setIndex(final int index) {
|
|
|
|
this.index=index;
|
|
|
|
}
|
2013-06-23 18:33:35 -07:00
|
|
|
|
2013-04-12 19:32:25 -07:00
|
|
|
public int getIndex() {
|
|
|
|
return index;
|
|
|
|
}
|
2013-06-23 18:33:35 -07:00
|
|
|
|
2017-06-16 20:19:03 -07:00
|
|
|
@Override
|
2013-04-12 19:32:25 -07:00
|
|
|
public String getImageName() {
|
2014-07-31 19:47:14 -07:00
|
|
|
return token ?
|
2015-05-09 07:01:39 -07:00
|
|
|
CardDefinitions.getCanonicalName(distinctName):
|
|
|
|
distinctName.replaceAll("[<>:\"/\\\\|?*\\x00-\\x1F]", "_");
|
2013-04-12 19:32:25 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
public void setImageURL(final String imageURL) {
|
|
|
|
this.imageURL = imageURL;
|
|
|
|
}
|
2015-06-16 11:38:33 -07:00
|
|
|
|
2013-04-12 19:32:25 -07:00
|
|
|
public String getImageURL() {
|
|
|
|
return imageURL;
|
|
|
|
}
|
2013-06-23 18:33:35 -07:00
|
|
|
|
2015-11-16 08:09:38 -08:00
|
|
|
public boolean hasImageUrl() {
|
|
|
|
return imageURL != null;
|
|
|
|
}
|
|
|
|
|
2013-04-12 19:32:25 -07:00
|
|
|
public String getCardTextName() {
|
|
|
|
return getImageName();
|
|
|
|
}
|
2013-06-23 18:33:35 -07:00
|
|
|
|
2015-06-20 19:38:05 -07:00
|
|
|
public void setValue(final double aValue) {
|
|
|
|
value = aValue;
|
2013-04-12 19:32:25 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
public double getValue() {
|
|
|
|
return value;
|
|
|
|
}
|
2013-06-23 18:33:35 -07:00
|
|
|
|
2013-04-12 19:32:25 -07:00
|
|
|
public void setRemoval(final int removal) {
|
|
|
|
this.removal=removal;
|
|
|
|
}
|
2013-06-23 18:33:35 -07:00
|
|
|
|
2013-04-12 19:32:25 -07:00
|
|
|
public int getRemoval() {
|
|
|
|
return removal;
|
|
|
|
}
|
2013-06-23 18:33:35 -07:00
|
|
|
|
2013-04-12 19:32:25 -07:00
|
|
|
public int getScore() {
|
|
|
|
if (score<0) {
|
|
|
|
score=ArtificialScoringSystem.getCardDefinitionScore(this);
|
|
|
|
}
|
|
|
|
return score;
|
|
|
|
}
|
2013-06-23 18:33:35 -07:00
|
|
|
|
2013-04-12 19:32:25 -07:00
|
|
|
public int getFreeScore() {
|
|
|
|
if (score<0) {
|
|
|
|
score=ArtificialScoringSystem.getFreeCardDefinitionScore(this);
|
|
|
|
}
|
|
|
|
return score;
|
|
|
|
}
|
2013-06-23 18:33:35 -07:00
|
|
|
|
2013-04-12 19:32:25 -07:00
|
|
|
public void setRarity(final char c) {
|
2016-07-18 09:43:17 -07:00
|
|
|
rarity = MagicRarity.getRarity(c);
|
2013-04-12 19:32:25 -07:00
|
|
|
}
|
2013-06-23 18:33:35 -07:00
|
|
|
|
2013-04-12 19:32:25 -07:00
|
|
|
public boolean isRarity(final MagicRarity r) {
|
2016-07-18 09:43:17 -07:00
|
|
|
return rarity == r;
|
2013-04-12 19:32:25 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
public int getRarity() {
|
2016-02-22 22:19:20 -08:00
|
|
|
return rarity == null ? -1 : rarity.ordinal();
|
2013-04-12 19:32:25 -07:00
|
|
|
}
|
2013-06-23 18:33:35 -07:00
|
|
|
|
2013-04-12 19:32:25 -07:00
|
|
|
public String getRarityString() {
|
2016-07-18 09:43:17 -07:00
|
|
|
return rarity == null ? "" : rarity.getName();
|
2013-04-12 19:32:25 -07:00
|
|
|
}
|
2013-06-23 18:33:35 -07:00
|
|
|
|
2017-06-16 20:19:03 -07:00
|
|
|
@Override
|
2016-01-05 10:14:51 -08:00
|
|
|
public Character getRarityChar() {
|
2016-01-05 10:47:25 -08:00
|
|
|
return rarity == null ? 'C' : rarity.getChar();//Return common for null rarity
|
2016-01-05 10:14:51 -08:00
|
|
|
}
|
|
|
|
|
2013-04-12 19:32:25 -07:00
|
|
|
public void setToken() {
|
|
|
|
token=true;
|
|
|
|
}
|
2013-06-23 18:33:35 -07:00
|
|
|
|
2017-06-16 20:19:03 -07:00
|
|
|
@Override
|
2013-04-12 19:32:25 -07:00
|
|
|
public boolean isToken() {
|
|
|
|
return token;
|
|
|
|
}
|
2015-06-16 11:38:33 -07:00
|
|
|
|
2013-04-12 19:32:25 -07:00
|
|
|
int getTypeFlags() {
|
|
|
|
return typeFlags;
|
|
|
|
}
|
2013-06-23 18:33:35 -07:00
|
|
|
|
2013-04-12 19:32:25 -07:00
|
|
|
public void addType(final MagicType type) {
|
2013-06-23 19:31:32 -07:00
|
|
|
typeFlags |= type.getMask();
|
|
|
|
if (type == MagicType.Land) {
|
|
|
|
if (colorFlags == -1) {
|
|
|
|
// Lands default to colorless
|
|
|
|
colorFlags = 0;
|
|
|
|
} else {
|
2014-05-01 00:16:14 -07:00
|
|
|
assert colorFlags != 0 : "redundant color declaration: " + colorFlags;
|
2013-06-23 19:31:32 -07:00
|
|
|
}
|
|
|
|
}
|
2014-03-24 09:20:56 -07:00
|
|
|
cardType.add(type);
|
|
|
|
}
|
|
|
|
|
|
|
|
public Set<MagicType> getCardType() {
|
|
|
|
return cardType;
|
2013-04-12 19:32:25 -07:00
|
|
|
}
|
2013-06-23 18:33:35 -07:00
|
|
|
|
2017-06-16 20:19:03 -07:00
|
|
|
@Override
|
2013-04-12 19:32:25 -07:00
|
|
|
public boolean hasType(final MagicType type) {
|
|
|
|
return (typeFlags&type.getMask())!=0;
|
|
|
|
}
|
2015-06-16 11:38:33 -07:00
|
|
|
|
2014-08-05 11:43:05 -07:00
|
|
|
public MagicCardDefinition getFlippedDefinition() {
|
2014-08-17 13:52:38 -07:00
|
|
|
if (flipCardDefinition == null) {
|
|
|
|
flipCardDefinition = isFlipCard() ?
|
2016-01-05 19:03:35 -08:00
|
|
|
CardDefinitions.getMissingOrCard(flipCardName) :
|
2016-07-18 09:43:17 -07:00
|
|
|
UNKNOWN;
|
2014-08-17 13:52:38 -07:00
|
|
|
}
|
2014-08-05 18:48:53 -07:00
|
|
|
return flipCardDefinition;
|
2014-08-05 11:43:05 -07:00
|
|
|
}
|
2013-06-23 18:33:35 -07:00
|
|
|
|
2017-06-16 20:19:03 -07:00
|
|
|
@Override
|
2014-08-06 08:29:43 -07:00
|
|
|
public MagicCardDefinition getTransformedDefinition() {
|
2014-08-17 13:33:49 -07:00
|
|
|
if (transformCardDefinition == null) {
|
|
|
|
transformCardDefinition = isDoubleFaced() ?
|
2016-01-05 19:03:35 -08:00
|
|
|
CardDefinitions.getMissingOrCard(transformCardName) :
|
2016-07-18 09:43:17 -07:00
|
|
|
UNKNOWN;
|
2014-08-17 13:33:49 -07:00
|
|
|
}
|
2014-08-06 08:29:43 -07:00
|
|
|
return transformCardDefinition;
|
|
|
|
}
|
2015-06-16 11:38:33 -07:00
|
|
|
|
2017-06-16 20:19:03 -07:00
|
|
|
@Override
|
2016-01-31 07:06:24 -08:00
|
|
|
public MagicCardDefinition getSplitDefinition() {
|
|
|
|
if (splitCardDefinition == null) {
|
|
|
|
splitCardDefinition = isSplitCard() ?
|
|
|
|
CardDefinitions.getMissingOrCard(splitCardName) :
|
|
|
|
UNKNOWN;
|
|
|
|
}
|
|
|
|
return splitCardDefinition;
|
|
|
|
}
|
|
|
|
|
2017-06-16 20:19:03 -07:00
|
|
|
@Override
|
2016-01-05 22:26:58 -08:00
|
|
|
public MagicCardDefinition getCardDefinition() {
|
|
|
|
return this;
|
|
|
|
}
|
|
|
|
|
2013-04-12 19:32:25 -07:00
|
|
|
public boolean isBasic() {
|
|
|
|
return hasType(MagicType.Basic);
|
|
|
|
}
|
2013-06-23 18:33:35 -07:00
|
|
|
|
2013-04-12 19:32:25 -07:00
|
|
|
public boolean isEquipment() {
|
2014-04-13 08:06:07 -07:00
|
|
|
return hasSubType(MagicSubType.Equipment);
|
2013-04-12 19:32:25 -07:00
|
|
|
}
|
2013-06-23 18:33:35 -07:00
|
|
|
|
2016-01-06 01:24:01 -08:00
|
|
|
public boolean isTribal() {
|
|
|
|
return hasType(MagicType.Tribal);
|
|
|
|
}
|
2015-06-16 11:38:33 -07:00
|
|
|
|
2016-01-06 01:24:01 -08:00
|
|
|
public boolean isSnow() {
|
|
|
|
return hasType(MagicType.Snow);
|
|
|
|
}
|
2013-06-23 18:33:35 -07:00
|
|
|
|
2016-01-06 01:24:01 -08:00
|
|
|
public boolean isWorld() {
|
|
|
|
return hasType(MagicType.World);
|
2013-04-12 19:32:25 -07:00
|
|
|
}
|
2013-06-23 18:33:35 -07:00
|
|
|
|
2016-01-06 01:24:01 -08:00
|
|
|
public boolean isAura() {
|
|
|
|
return isEnchantment() && hasSubType(MagicSubType.Aura);
|
2013-04-12 19:32:25 -07:00
|
|
|
}
|
2013-06-23 18:33:35 -07:00
|
|
|
|
2013-04-12 19:32:25 -07:00
|
|
|
public boolean isSpell() {
|
|
|
|
return isInstant()||isSorcery();
|
|
|
|
}
|
2014-05-01 00:16:14 -07:00
|
|
|
|
2014-04-05 23:11:37 -07:00
|
|
|
public boolean isPermanent() {
|
2016-07-18 09:43:17 -07:00
|
|
|
return !isSpell();
|
2014-04-05 23:11:37 -07:00
|
|
|
}
|
2015-06-16 11:38:33 -07:00
|
|
|
|
2017-06-16 20:19:03 -07:00
|
|
|
@Override
|
2014-08-05 11:43:05 -07:00
|
|
|
public boolean isFlipCard() {
|
2014-08-17 13:54:38 -07:00
|
|
|
return flipCardName != null;
|
2014-08-05 11:43:05 -07:00
|
|
|
}
|
2015-06-16 11:38:33 -07:00
|
|
|
|
2017-06-16 20:19:03 -07:00
|
|
|
@Override
|
2014-08-06 08:29:43 -07:00
|
|
|
public boolean isDoubleFaced() {
|
2014-08-17 13:31:48 -07:00
|
|
|
return transformCardName != null;
|
2014-08-06 08:29:43 -07:00
|
|
|
}
|
2013-06-23 18:33:35 -07:00
|
|
|
|
2017-06-16 20:19:03 -07:00
|
|
|
@Override
|
2016-01-31 07:06:24 -08:00
|
|
|
public boolean isSplitCard() {
|
|
|
|
return splitCardName != null;
|
|
|
|
}
|
|
|
|
|
2014-09-10 01:58:35 -07:00
|
|
|
public boolean hasMultipleAspects() {
|
|
|
|
return isFlipCard() || isDoubleFaced();
|
|
|
|
}
|
|
|
|
|
2013-04-12 19:32:25 -07:00
|
|
|
public String getLongTypeString() {
|
|
|
|
if (isBasic()) {
|
2016-07-18 09:43:17 -07:00
|
|
|
return (isSnow() ? "Basic Snow " : "Basic ") + getTypeString();
|
2013-04-12 19:32:25 -07:00
|
|
|
}
|
|
|
|
if (isLegendary()) {
|
2016-07-18 09:43:17 -07:00
|
|
|
return (isSnow() ? "Legendary Snow " : "Legendary ") + getTypeString();
|
2013-04-12 19:32:25 -07:00
|
|
|
}
|
2015-06-16 11:38:33 -07:00
|
|
|
if (isSnow()) {
|
|
|
|
return "Snow " + getTypeString();
|
|
|
|
}
|
|
|
|
if (isWorld()) {
|
|
|
|
return "World " + getTypeString();
|
|
|
|
}
|
2013-06-23 18:33:35 -07:00
|
|
|
return getTypeString();
|
2013-04-12 19:32:25 -07:00
|
|
|
}
|
2013-06-23 18:33:35 -07:00
|
|
|
|
2013-04-12 19:32:25 -07:00
|
|
|
public String getTypeString() {
|
|
|
|
final StringBuilder sb = new StringBuilder();
|
2016-01-05 19:26:16 -08:00
|
|
|
MagicType.TYPE_ORDER.stream().filter(this::hasType).forEach(type -> sb.append(type).append(' '));
|
2016-01-05 12:39:43 -08:00
|
|
|
return sb.toString().trim();
|
2016-01-05 19:26:16 -08:00
|
|
|
|
2013-04-12 19:32:25 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
public boolean usesStack() {
|
|
|
|
return !isLand();
|
|
|
|
}
|
2013-06-23 18:33:35 -07:00
|
|
|
|
2013-04-12 19:32:25 -07:00
|
|
|
public void setSubTypes(final String[] subTypeNames) {
|
|
|
|
subTypeFlags = MagicSubType.getSubTypes(subTypeNames);
|
|
|
|
}
|
|
|
|
|
2016-06-17 19:07:16 -07:00
|
|
|
private void setSubTypes(final EnumSet<MagicSubType> stf) {
|
|
|
|
subTypeFlags = stf;
|
|
|
|
}
|
|
|
|
|
2014-07-27 22:05:25 -07:00
|
|
|
public void addSubType(final MagicSubType subType) {
|
|
|
|
subTypeFlags.add(subType);
|
|
|
|
}
|
|
|
|
|
2015-12-24 16:51:03 -08:00
|
|
|
EnumSet<MagicSubType> genSubTypes() {
|
2013-04-12 19:32:25 -07:00
|
|
|
return subTypeFlags.clone();
|
|
|
|
}
|
2013-06-23 18:33:35 -07:00
|
|
|
|
2017-06-16 20:19:03 -07:00
|
|
|
@Override
|
2015-12-24 16:51:03 -08:00
|
|
|
public EnumSet<MagicSubType> getSubTypes() {
|
|
|
|
final EnumSet<MagicSubType> subTypes = genSubTypes();
|
2013-04-12 19:32:25 -07:00
|
|
|
applyCDASubType(null, null, subTypes);
|
|
|
|
return subTypes;
|
|
|
|
}
|
2013-06-23 18:33:35 -07:00
|
|
|
|
2013-10-13 03:27:37 -07:00
|
|
|
public void applyCDASubType(final MagicGame game, final MagicPlayer player, final Set<MagicSubType> flags) {
|
2013-04-12 19:32:25 -07:00
|
|
|
for (final MagicCDA lv : CDAs) {
|
|
|
|
lv.getSubTypeFlags(game, player, flags);
|
|
|
|
}
|
|
|
|
}
|
2013-06-23 18:33:35 -07:00
|
|
|
|
2013-04-12 19:32:25 -07:00
|
|
|
public String getSubTypeString() {
|
2015-12-24 16:51:03 -08:00
|
|
|
final String brackets = getSubTypes().toString(); // [...,...]
|
2013-04-12 19:32:25 -07:00
|
|
|
if (brackets.length() <= 2) {
|
|
|
|
return "";
|
|
|
|
}
|
|
|
|
return brackets.substring(1, brackets.length() - 1);
|
|
|
|
}
|
2013-06-23 18:33:35 -07:00
|
|
|
|
2017-06-16 20:19:03 -07:00
|
|
|
@Override
|
2013-04-12 19:32:25 -07:00
|
|
|
public boolean hasSubType(final MagicSubType subType) {
|
2015-12-24 16:51:03 -08:00
|
|
|
return getSubTypes().contains(subType);
|
2013-04-12 19:32:25 -07:00
|
|
|
}
|
2013-06-23 18:33:35 -07:00
|
|
|
|
2016-06-17 19:07:16 -07:00
|
|
|
private void setColorFlags(final int cf) {
|
|
|
|
colorFlags = cf;
|
|
|
|
}
|
|
|
|
|
2013-04-12 19:32:25 -07:00
|
|
|
public void setColors(final String colors) {
|
2013-06-23 19:31:32 -07:00
|
|
|
colorFlags = MagicColor.getFlags(colors);
|
2016-07-18 09:43:17 -07:00
|
|
|
assert !hasCost() || colorFlags != cost.getColorFlags() : "redundant color declaration: " + colorFlags;
|
2013-04-12 19:32:25 -07:00
|
|
|
}
|
2013-06-23 18:33:35 -07:00
|
|
|
|
2017-06-16 20:19:03 -07:00
|
|
|
@Override
|
2013-04-12 19:32:25 -07:00
|
|
|
public boolean hasColor(final MagicColor color) {
|
2015-04-22 22:23:36 -07:00
|
|
|
return (colorFlags&color.getMask())!=0;
|
2013-04-12 19:32:25 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
public boolean isColorless() {
|
|
|
|
return colorFlags == 0;
|
|
|
|
}
|
2013-06-23 18:33:35 -07:00
|
|
|
|
2017-06-16 20:19:03 -07:00
|
|
|
@Override
|
2013-04-12 19:32:25 -07:00
|
|
|
public int getColorFlags() {
|
|
|
|
return colorFlags;
|
|
|
|
}
|
2015-11-21 05:01:25 -08:00
|
|
|
|
2015-08-27 19:22:32 -07:00
|
|
|
public int applyCDAColor(final MagicGame game, final MagicPlayer player, final int initColor) {
|
|
|
|
int color = initColor;
|
|
|
|
for (final MagicCDA lv : CDAs) {
|
|
|
|
color =lv.getColorFlags(game, player, color);
|
|
|
|
}
|
|
|
|
return color;
|
|
|
|
}
|
2013-06-23 18:33:35 -07:00
|
|
|
|
2013-04-12 19:32:25 -07:00
|
|
|
public int getConvertedCost() {
|
|
|
|
return cost.getConvertedCost();
|
|
|
|
}
|
2013-06-23 18:33:35 -07:00
|
|
|
|
2015-12-31 06:31:51 -08:00
|
|
|
public int getConvertedCost(final int x) {
|
|
|
|
return cost.getConvertedCost(x);
|
|
|
|
}
|
|
|
|
|
2013-04-12 19:32:25 -07:00
|
|
|
public boolean hasConvertedCost(final int c) {
|
|
|
|
return getConvertedCost() == c;
|
|
|
|
}
|
2013-06-23 18:33:35 -07:00
|
|
|
|
2013-04-12 19:32:25 -07:00
|
|
|
public int getCostBucket() {
|
|
|
|
switch (getConvertedCost()) {
|
|
|
|
case 0:
|
|
|
|
case 1:
|
|
|
|
case 2:
|
|
|
|
return 0;
|
|
|
|
case 3:
|
|
|
|
case 4:
|
|
|
|
return 1;
|
2013-06-23 18:33:35 -07:00
|
|
|
default:
|
2013-04-12 19:32:25 -07:00
|
|
|
return 2;
|
|
|
|
}
|
|
|
|
}
|
2013-06-23 18:33:35 -07:00
|
|
|
|
2013-04-12 19:32:25 -07:00
|
|
|
public boolean hasX() {
|
|
|
|
return cost.hasX();
|
|
|
|
}
|
|
|
|
|
|
|
|
public void setCost(final MagicManaCost aCost) {
|
|
|
|
cost = aCost;
|
2013-06-23 06:19:01 -07:00
|
|
|
if (colorFlags == -1) {
|
2013-06-23 19:31:32 -07:00
|
|
|
// color defaults to follow mana cost
|
2013-06-23 06:19:01 -07:00
|
|
|
colorFlags = cost.getColorFlags();
|
2013-06-23 19:31:32 -07:00
|
|
|
} else {
|
2014-05-01 00:16:14 -07:00
|
|
|
assert colorFlags != cost.getColorFlags() : "redundant color declaration: " + colorFlags;
|
2013-06-23 06:19:01 -07:00
|
|
|
}
|
2013-04-12 19:32:25 -07:00
|
|
|
}
|
|
|
|
|
2013-06-23 18:33:35 -07:00
|
|
|
public void validate() {
|
|
|
|
//every card should have a timing hint
|
2013-04-12 19:32:25 -07:00
|
|
|
if (!isToken() && getTiming() == MagicTiming.None) {
|
|
|
|
throw new RuntimeException(
|
|
|
|
getName() + " does not have a timing hint"
|
|
|
|
);
|
|
|
|
}
|
2013-06-23 18:33:35 -07:00
|
|
|
|
2013-06-23 06:34:53 -07:00
|
|
|
//check colorFlags is set
|
|
|
|
if (colorFlags == -1) {
|
|
|
|
throw new RuntimeException(name + "'s color is not set");
|
|
|
|
}
|
2015-06-05 17:29:24 -07:00
|
|
|
|
|
|
|
//every Aura should have an MagicPlayAuraEvent
|
2016-07-18 20:46:40 -07:00
|
|
|
if (isAura() && cardEvent == MagicPlayCardEvent.create()) {
|
2015-06-05 17:29:24 -07:00
|
|
|
throw new RuntimeException(name + " does not have the enchant property");
|
|
|
|
}
|
2013-04-12 19:32:25 -07:00
|
|
|
}
|
|
|
|
|
2017-06-16 20:19:03 -07:00
|
|
|
@Override
|
2013-04-12 19:32:25 -07:00
|
|
|
public MagicManaCost getCost() {
|
|
|
|
return cost;
|
|
|
|
}
|
2013-06-23 18:33:35 -07:00
|
|
|
|
2016-01-05 17:43:19 -08:00
|
|
|
public boolean hasCost() {
|
2016-07-18 20:46:40 -07:00
|
|
|
return cost != MagicManaCost.NONE;
|
2016-01-05 17:43:19 -08:00
|
|
|
}
|
|
|
|
|
2015-06-26 21:24:24 -07:00
|
|
|
public List<MagicEvent> getCostEvent(final MagicCard source) {
|
2017-08-07 07:42:46 -07:00
|
|
|
return getCostEvent(source, cost);
|
|
|
|
}
|
|
|
|
|
|
|
|
public List<MagicEvent> getWithoutManaCostEvent(final MagicCard source) {
|
|
|
|
return getCostEvent(source, MagicManaCost.ZERO);
|
|
|
|
}
|
|
|
|
|
|
|
|
private List<MagicEvent> getCostEvent(final MagicCard source, final MagicManaCost manaCost) {
|
2018-04-07 17:59:14 -07:00
|
|
|
final List<MagicEvent> costEvent = new ArrayList<>();
|
2017-08-07 07:42:46 -07:00
|
|
|
if (manaCost != MagicManaCost.NONE) {
|
2016-01-06 17:25:35 -08:00
|
|
|
costEvent.add(MagicPayManaCostEvent.Cast(
|
|
|
|
source,
|
2017-08-07 07:42:46 -07:00
|
|
|
manaCost
|
2016-01-06 17:25:35 -08:00
|
|
|
));
|
|
|
|
}
|
2017-08-07 07:42:46 -07:00
|
|
|
for (final MagicEventSource eventSource : costEventSources) {
|
|
|
|
costEvent.add(eventSource.getEvent(source));
|
|
|
|
}
|
2015-06-26 21:24:24 -07:00
|
|
|
return costEvent;
|
|
|
|
}
|
2015-11-21 05:01:25 -08:00
|
|
|
|
2014-03-13 03:24:17 -07:00
|
|
|
public boolean isPlayable(final MagicDeckProfile profile) {
|
2013-04-12 19:32:25 -07:00
|
|
|
if (isLand()) {
|
|
|
|
int source = 0;
|
|
|
|
for (final MagicColor color : profile.getColors()) {
|
|
|
|
source += getManaSource(color);
|
|
|
|
}
|
|
|
|
return source > 4;
|
|
|
|
} else {
|
|
|
|
return cost.getCostScore(profile) > 0;
|
|
|
|
}
|
|
|
|
}
|
2013-06-23 18:33:35 -07:00
|
|
|
|
2013-04-12 19:32:25 -07:00
|
|
|
public void setManaSourceText(final String sourceText) {
|
|
|
|
manaSourceText=sourceText;
|
|
|
|
for (int index=0;index<sourceText.length();index+=2) {
|
|
|
|
final char symbol=sourceText.charAt(index);
|
|
|
|
final int source=sourceText.charAt(index+1)-'0';
|
|
|
|
final MagicColor color=MagicColor.getColor(symbol);
|
|
|
|
manaSource[color.ordinal()]=source;
|
|
|
|
}
|
|
|
|
}
|
2013-06-23 18:33:35 -07:00
|
|
|
|
2013-04-12 19:32:25 -07:00
|
|
|
public int getManaSource(final MagicColor color) {
|
|
|
|
return manaSource[color.ordinal()];
|
|
|
|
}
|
2015-11-21 05:01:25 -08:00
|
|
|
|
2015-06-20 20:10:13 -07:00
|
|
|
public void setStartingLoyalty(final int aLoyalty) {
|
|
|
|
startingLoyalty = aLoyalty;
|
|
|
|
}
|
|
|
|
|
2017-06-16 20:19:03 -07:00
|
|
|
@Override
|
2015-06-20 20:10:13 -07:00
|
|
|
public int getStartingLoyalty() {
|
|
|
|
return startingLoyalty;
|
|
|
|
}
|
2013-06-23 18:33:35 -07:00
|
|
|
|
2013-04-12 19:32:25 -07:00
|
|
|
public void setPowerToughness(final int aPower, final int aToughness) {
|
|
|
|
power = aPower;
|
|
|
|
toughness = aToughness;
|
|
|
|
}
|
2013-06-23 18:33:35 -07:00
|
|
|
|
2013-04-12 19:32:25 -07:00
|
|
|
public int getCardPower() {
|
|
|
|
return power;
|
|
|
|
}
|
2013-06-23 18:33:35 -07:00
|
|
|
|
2013-04-12 19:32:25 -07:00
|
|
|
public int getCardToughness() {
|
|
|
|
return toughness;
|
|
|
|
}
|
|
|
|
|
|
|
|
public MagicPowerToughness genPowerToughness() {
|
|
|
|
return new MagicPowerToughness(power, toughness);
|
|
|
|
}
|
2013-06-23 18:33:35 -07:00
|
|
|
|
2015-05-15 18:39:50 -07:00
|
|
|
public void applyCDAPowerToughness(final MagicGame game, final MagicPlayer player, final MagicPermanent perm, final MagicPowerToughness pt) {
|
2013-04-12 19:32:25 -07:00
|
|
|
for (final MagicCDA lv : CDAs) {
|
|
|
|
lv.modPowerToughness(game, player, perm, pt);
|
|
|
|
}
|
|
|
|
}
|
2013-06-23 18:33:35 -07:00
|
|
|
|
2017-06-16 20:19:03 -07:00
|
|
|
@Override
|
2013-04-12 19:32:25 -07:00
|
|
|
public void addAbility(final MagicAbility ability) {
|
|
|
|
abilityFlags.add(ability);
|
|
|
|
}
|
|
|
|
|
|
|
|
public Set<MagicAbility> genAbilityFlags() {
|
|
|
|
return abilityFlags.clone();
|
|
|
|
}
|
2013-06-23 18:33:35 -07:00
|
|
|
|
2017-06-16 20:19:03 -07:00
|
|
|
@Override
|
2013-04-12 19:32:25 -07:00
|
|
|
public boolean hasAbility(final MagicAbility ability) {
|
|
|
|
return abilityFlags.contains(ability);
|
|
|
|
}
|
2013-06-23 18:33:35 -07:00
|
|
|
|
2013-04-12 19:32:25 -07:00
|
|
|
public void setText(final String text) {
|
|
|
|
this.text = text;
|
|
|
|
}
|
2013-06-23 18:33:35 -07:00
|
|
|
|
2017-06-16 20:19:03 -07:00
|
|
|
@Override
|
2013-04-12 19:32:25 -07:00
|
|
|
public String getText() {
|
2016-07-18 09:43:17 -07:00
|
|
|
return text;
|
2013-04-12 19:32:25 -07:00
|
|
|
}
|
2015-06-16 11:38:33 -07:00
|
|
|
|
2015-04-22 23:35:17 -07:00
|
|
|
public String getFlattenedText() {
|
2016-07-18 09:43:17 -07:00
|
|
|
return text.replace("\n", " ");
|
2015-04-22 23:35:17 -07:00
|
|
|
}
|
2013-06-23 18:33:35 -07:00
|
|
|
|
2013-04-12 19:32:25 -07:00
|
|
|
public void setStaticType(final MagicStaticType staticType) {
|
|
|
|
this.staticType=staticType;
|
|
|
|
}
|
2013-06-23 18:33:35 -07:00
|
|
|
|
2013-04-12 19:32:25 -07:00
|
|
|
MagicStaticType getStaticType() {
|
|
|
|
return staticType;
|
|
|
|
}
|
2013-06-23 18:33:35 -07:00
|
|
|
|
2013-04-12 19:32:25 -07:00
|
|
|
public void setTiming(final MagicTiming timing) {
|
|
|
|
this.timing=timing;
|
|
|
|
}
|
2013-06-23 18:33:35 -07:00
|
|
|
|
2013-04-12 19:32:25 -07:00
|
|
|
public MagicTiming getTiming() {
|
|
|
|
return timing;
|
|
|
|
}
|
|
|
|
|
2017-06-16 20:19:03 -07:00
|
|
|
@Override
|
2013-04-12 19:32:25 -07:00
|
|
|
public void add(final MagicChangeCardDefinition mod) {
|
|
|
|
mod.change(this);
|
|
|
|
}
|
2013-06-23 18:33:35 -07:00
|
|
|
|
2013-04-12 19:32:25 -07:00
|
|
|
public void setEvent(final MagicCardEvent aCardEvent) {
|
2016-07-18 20:46:40 -07:00
|
|
|
assert cardEvent == MagicPlayCardEvent.create() : "Attempting to set two MagicCardEvents for " + this;
|
2013-04-12 19:32:25 -07:00
|
|
|
cardEvent = aCardEvent;
|
|
|
|
}
|
2013-06-23 18:33:35 -07:00
|
|
|
|
2013-04-12 19:32:25 -07:00
|
|
|
public MagicCardEvent getCardEvent() {
|
|
|
|
return cardEvent;
|
|
|
|
}
|
|
|
|
|
|
|
|
public MagicActivationHints getActivationHints() {
|
|
|
|
return new MagicActivationHints(timing,true);
|
|
|
|
}
|
2013-06-23 18:33:35 -07:00
|
|
|
|
2015-05-26 20:56:29 -07:00
|
|
|
// cast card activation is the first element of handActivations
|
2013-09-08 23:04:29 -07:00
|
|
|
public MagicActivation<MagicCard> getCastActivation() {
|
2015-05-26 20:56:29 -07:00
|
|
|
assert handActivations.size() >= 1 : this + " has no card activations";
|
|
|
|
return handActivations.getFirst();
|
2013-04-12 19:32:25 -07:00
|
|
|
}
|
2013-06-23 18:33:35 -07:00
|
|
|
|
2015-05-26 20:56:29 -07:00
|
|
|
public Collection<MagicActivation<MagicCard>> getHandActivations() {
|
|
|
|
return handActivations;
|
2013-04-12 19:32:25 -07:00
|
|
|
}
|
2014-05-01 00:16:14 -07:00
|
|
|
|
2014-04-17 05:10:06 -07:00
|
|
|
public Collection<MagicActivation<MagicCard>> getGraveyardActivations() {
|
|
|
|
return graveyardActivations;
|
|
|
|
}
|
2013-06-23 18:33:35 -07:00
|
|
|
|
2013-04-12 19:32:25 -07:00
|
|
|
public void addCDA(final MagicCDA cda) {
|
|
|
|
CDAs.add(cda);
|
|
|
|
}
|
2013-06-23 18:33:35 -07:00
|
|
|
|
2013-06-15 20:16:56 -07:00
|
|
|
public void addCostEvent(final MagicEventSource eventSource) {
|
|
|
|
costEventSources.add(eventSource);
|
|
|
|
}
|
2013-04-12 19:32:25 -07:00
|
|
|
|
2015-11-24 06:42:52 -08:00
|
|
|
public void addTrigger(final ThisSpellIsCastTrigger trigger) {
|
2013-04-12 19:32:25 -07:00
|
|
|
spellIsCastTriggers.add(trigger);
|
|
|
|
}
|
2015-06-16 11:38:33 -07:00
|
|
|
|
2015-11-26 04:52:41 -08:00
|
|
|
public void addTrigger(final ThisCycleTrigger trigger) {
|
2014-08-25 06:13:33 -07:00
|
|
|
cycleTriggers.add(trigger);
|
|
|
|
}
|
2013-04-12 19:32:25 -07:00
|
|
|
|
2015-11-22 07:33:59 -08:00
|
|
|
public void addTrigger(final EntersBattlefieldTrigger trigger) {
|
2013-04-12 19:32:25 -07:00
|
|
|
if (trigger.usesStack()) {
|
2016-01-10 10:14:09 -08:00
|
|
|
etbTriggers.add(trigger);
|
2013-04-12 19:32:25 -07:00
|
|
|
} else {
|
2016-01-10 10:14:09 -08:00
|
|
|
etbTriggers.addFirst(trigger);
|
2013-04-12 19:32:25 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-11-24 07:24:48 -08:00
|
|
|
public void addTrigger(final ThisPutIntoGraveyardTrigger trigger) {
|
2013-04-12 19:32:25 -07:00
|
|
|
putIntoGraveyardTriggers.add(trigger);
|
|
|
|
}
|
|
|
|
|
2015-11-26 04:55:01 -08:00
|
|
|
public void addTrigger(final ThisDrawnTrigger trigger) {
|
2013-04-12 19:32:25 -07:00
|
|
|
drawnTriggers.add(trigger);
|
|
|
|
}
|
2013-06-23 18:33:35 -07:00
|
|
|
|
2013-04-12 19:32:25 -07:00
|
|
|
public void addTrigger(final MagicTrigger<?> trigger) {
|
|
|
|
triggers.add(trigger);
|
|
|
|
}
|
2013-06-23 18:33:35 -07:00
|
|
|
|
2013-04-12 19:32:25 -07:00
|
|
|
public void addStatic(final MagicStatic mstatic) {
|
|
|
|
statics.add(mstatic);
|
|
|
|
}
|
2013-06-23 18:33:35 -07:00
|
|
|
|
2013-04-12 19:32:25 -07:00
|
|
|
public Collection<MagicTrigger<?>> getTriggers() {
|
|
|
|
return triggers;
|
|
|
|
}
|
2013-06-23 18:33:35 -07:00
|
|
|
|
2013-04-12 19:32:25 -07:00
|
|
|
public Collection<MagicStatic> getStatics() {
|
|
|
|
return statics;
|
|
|
|
}
|
2013-06-23 18:33:35 -07:00
|
|
|
|
2015-11-24 06:42:52 -08:00
|
|
|
public Collection<ThisSpellIsCastTrigger> getSpellIsCastTriggers() {
|
2013-04-12 19:32:25 -07:00
|
|
|
return spellIsCastTriggers;
|
|
|
|
}
|
2015-06-16 11:38:33 -07:00
|
|
|
|
2015-11-26 04:52:41 -08:00
|
|
|
public Collection<ThisCycleTrigger> getCycleTriggers() {
|
2014-08-25 06:13:33 -07:00
|
|
|
return cycleTriggers;
|
|
|
|
}
|
2013-06-23 18:33:35 -07:00
|
|
|
|
2016-01-10 10:14:09 -08:00
|
|
|
public Collection<EntersBattlefieldTrigger> getETBTriggers() {
|
|
|
|
return etbTriggers;
|
2013-04-12 19:32:25 -07:00
|
|
|
}
|
2013-06-23 18:33:35 -07:00
|
|
|
|
2015-11-24 07:24:48 -08:00
|
|
|
public Collection<ThisPutIntoGraveyardTrigger> getPutIntoGraveyardTriggers() {
|
2013-04-12 19:32:25 -07:00
|
|
|
return putIntoGraveyardTriggers;
|
|
|
|
}
|
2013-06-23 18:33:35 -07:00
|
|
|
|
2015-11-26 04:55:01 -08:00
|
|
|
public Collection<ThisDrawnTrigger> getDrawnTriggers() {
|
2013-04-12 19:32:25 -07:00
|
|
|
return drawnTriggers;
|
|
|
|
}
|
2013-06-23 18:33:35 -07:00
|
|
|
|
2013-04-12 19:32:25 -07:00
|
|
|
public void addAct(final MagicPermanentActivation activation) {
|
2013-07-07 06:16:11 -07:00
|
|
|
permActivations.add(activation);
|
2013-04-12 19:32:25 -07:00
|
|
|
}
|
2015-06-16 11:38:33 -07:00
|
|
|
|
2014-07-31 20:55:26 -07:00
|
|
|
public void addMorphAct(final MagicPermanentActivation activation) {
|
|
|
|
morphActivations.add(activation);
|
|
|
|
}
|
2013-06-23 18:33:35 -07:00
|
|
|
|
2015-05-26 20:56:29 -07:00
|
|
|
public void addHandAct(final MagicHandCastActivation activation) {
|
|
|
|
handActivations.add(activation);
|
2013-04-12 19:32:25 -07:00
|
|
|
}
|
2014-05-01 00:16:14 -07:00
|
|
|
|
2015-05-26 20:40:41 -07:00
|
|
|
public void addGraveyardAct(final MagicHandCastActivation activation) {
|
2014-04-17 05:10:06 -07:00
|
|
|
graveyardActivations.add(activation);
|
|
|
|
}
|
2014-05-01 00:16:14 -07:00
|
|
|
|
2015-05-26 20:56:29 -07:00
|
|
|
public void setHandAct(final MagicHandCastActivation activation) {
|
|
|
|
assert handActivations.size() == 1 : "removing multiple (" + handActivations.size() + ") card activations";
|
|
|
|
handActivations.clear();
|
|
|
|
handActivations.add(activation);
|
2014-02-17 21:29:41 -08:00
|
|
|
}
|
2013-06-23 18:33:35 -07:00
|
|
|
|
2013-07-07 06:16:11 -07:00
|
|
|
public Collection<MagicActivation<MagicPermanent>> getActivations() {
|
|
|
|
return permActivations;
|
2013-04-12 19:32:25 -07:00
|
|
|
}
|
2015-06-16 11:38:33 -07:00
|
|
|
|
2014-07-31 20:55:26 -07:00
|
|
|
public Collection<MagicActivation<MagicPermanent>> getMorphActivations() {
|
|
|
|
return morphActivations;
|
|
|
|
}
|
2013-06-23 18:33:35 -07:00
|
|
|
|
2013-04-12 19:32:25 -07:00
|
|
|
public void addManaAct(final MagicManaActivation activation) {
|
|
|
|
manaActivations.add(activation);
|
|
|
|
}
|
2013-06-23 18:33:35 -07:00
|
|
|
|
2017-06-16 20:19:03 -07:00
|
|
|
@Override
|
2013-04-12 19:32:25 -07:00
|
|
|
public Collection<MagicManaActivation> getManaActivations() {
|
|
|
|
return manaActivations;
|
|
|
|
}
|
2013-06-23 18:33:35 -07:00
|
|
|
|
2013-04-12 19:32:25 -07:00
|
|
|
public void setExcludeManaOrCombat() {
|
|
|
|
excludeManaOrCombat=true;
|
|
|
|
}
|
2013-06-23 18:33:35 -07:00
|
|
|
|
2013-04-12 19:32:25 -07:00
|
|
|
public boolean hasExcludeManaOrCombat() {
|
|
|
|
return excludeManaOrCombat;
|
|
|
|
}
|
2013-06-23 18:33:35 -07:00
|
|
|
|
2013-04-12 19:32:25 -07:00
|
|
|
private boolean subTypeHasText(final String s) {
|
|
|
|
final MagicSubType[] subTypeValues = MagicSubType.values();
|
|
|
|
for (final MagicSubType subtype : subTypeValues) {
|
2016-12-27 16:53:29 -08:00
|
|
|
if (subTypeFlags.contains(subtype) && subtype.toString().toLowerCase(Locale.ENGLISH).contains(s)) {
|
2013-04-12 19:32:25 -07:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
2013-06-23 18:33:35 -07:00
|
|
|
|
2013-04-12 19:32:25 -07:00
|
|
|
private boolean abilityHasText(final String s) {
|
2013-07-22 23:00:54 -07:00
|
|
|
for (final MagicAbility ability : MagicAbility.values()) {
|
2016-12-27 16:53:29 -08:00
|
|
|
if (hasAbility(ability) && ability.getName().toLowerCase(Locale.ENGLISH).contains(s)) {
|
2013-04-12 19:32:25 -07:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
2013-06-23 18:33:35 -07:00
|
|
|
|
2013-04-12 19:32:25 -07:00
|
|
|
public boolean hasText(String s) {
|
2016-12-27 16:53:29 -08:00
|
|
|
s = s.toLowerCase(Locale.ENGLISH);
|
2016-07-18 20:46:40 -07:00
|
|
|
return
|
2016-12-27 16:53:29 -08:00
|
|
|
CardDefinitions.getASCII(distinctName).toLowerCase(Locale.ENGLISH).contains(s) ||
|
|
|
|
CardDefinitions.getASCII(name).toLowerCase(Locale.ENGLISH).contains(s) ||
|
2016-07-18 20:46:40 -07:00
|
|
|
subTypeHasText(s) ||
|
|
|
|
abilityHasText(s) ||
|
2016-12-27 16:53:29 -08:00
|
|
|
CardDefinitions.getASCII(getText()).toLowerCase(Locale.ENGLISH).contains(s);
|
2013-04-12 19:32:25 -07:00
|
|
|
}
|
2013-06-23 18:33:35 -07:00
|
|
|
|
2013-04-12 19:32:25 -07:00
|
|
|
@Override
|
|
|
|
public String toString() {
|
|
|
|
return getName();
|
|
|
|
}
|
|
|
|
|
2017-02-04 06:01:15 -08:00
|
|
|
public static final Comparator<MagicCardDefinition> NAME_COMPARATOR_ASC =
|
2018-04-07 17:59:14 -07:00
|
|
|
Comparator.comparing(MagicCardDefinition::getName);
|
2013-04-12 19:32:25 -07:00
|
|
|
|
2017-02-04 06:01:15 -08:00
|
|
|
public static final Comparator<MagicCardDefinition> NAME_COMPARATOR_DESC =
|
|
|
|
(cd1, cd2) -> cd2.getName().compareTo(cd1.getName());
|
2013-06-23 18:33:35 -07:00
|
|
|
|
2016-07-18 20:46:40 -07:00
|
|
|
public static final Comparator<MagicCardDefinition> CONVERTED_COMPARATOR_DESC = (cd1, cd2) -> {
|
|
|
|
final int cdif=cd1.getConvertedCost()-cd2.getConvertedCost();
|
|
|
|
return cdif != 0 ? cdif : cd1.getName().compareTo(cd2.getName());
|
2013-04-12 19:32:25 -07:00
|
|
|
};
|
2013-06-23 18:33:35 -07:00
|
|
|
|
2016-07-18 20:46:40 -07:00
|
|
|
public static final Comparator<MagicCardDefinition> CONVERTED_COMPARATOR_ASC = (cd1, cd2) -> CONVERTED_COMPARATOR_DESC.compare(cd2, cd1);
|
2013-04-12 19:32:25 -07:00
|
|
|
|
2016-07-18 20:46:40 -07:00
|
|
|
public static final Comparator<MagicCardDefinition> TYPE_COMPARATOR_DESC = (cd1, cd2) -> {
|
|
|
|
final int c = cd1.getTypeString().compareTo(cd2.getTypeString());
|
|
|
|
return c != 0 ? c : cd1.getLongTypeString().compareTo(cd2.getLongTypeString());
|
2013-04-12 19:32:25 -07:00
|
|
|
};
|
|
|
|
|
2016-07-18 20:46:40 -07:00
|
|
|
public static final Comparator<MagicCardDefinition> TYPE_COMPARATOR_ASC = (cd1, cd2) -> TYPE_COMPARATOR_DESC.compare(cd2, cd1);
|
2016-02-23 18:04:14 -08:00
|
|
|
|
2018-04-07 17:59:14 -07:00
|
|
|
public static final Comparator<MagicCardDefinition> SUBTYPE_COMPARATOR_DESC = Comparator.comparing(MagicCardDefinition::getSubTypeString);
|
2013-04-12 19:32:25 -07:00
|
|
|
|
2016-07-18 20:46:40 -07:00
|
|
|
public static final Comparator<MagicCardDefinition> SUBTYPE_COMPARATOR_ASC = (cd1, cd2) -> SUBTYPE_COMPARATOR_DESC.compare(cd2, cd1);
|
2013-04-12 19:32:25 -07:00
|
|
|
|
2018-04-07 17:59:14 -07:00
|
|
|
public static final Comparator<MagicCardDefinition> RARITY_COMPARATOR_DESC = Comparator.comparingInt(MagicCardDefinition::getRarity);
|
2013-04-12 19:32:25 -07:00
|
|
|
|
2016-07-18 20:46:40 -07:00
|
|
|
public static final Comparator<MagicCardDefinition> RARITY_COMPARATOR_ASC = (cd1, cd2) -> RARITY_COMPARATOR_DESC.compare(cd2, cd1);
|
2013-06-23 18:33:35 -07:00
|
|
|
|
2016-07-18 20:46:40 -07:00
|
|
|
public static final Comparator<MagicCardDefinition> POWER_COMPARATOR_DESC = (cd1, cd2) -> {
|
|
|
|
final int p1 = cd1.isCreature() ? cd1.getCardPower() : -100;
|
|
|
|
final int p2 = cd2.isCreature() ? cd2.getCardPower() : -100;
|
|
|
|
return p1 != p2 ? p1 - p2 : cd1.getName().compareTo(cd2.getName());
|
2013-04-12 19:32:25 -07:00
|
|
|
};
|
|
|
|
|
2016-07-18 20:46:40 -07:00
|
|
|
public static final Comparator<MagicCardDefinition> POWER_COMPARATOR_ASC= (cd1, cd2) -> POWER_COMPARATOR_DESC.compare(cd2, cd1);
|
2013-04-12 19:32:25 -07:00
|
|
|
|
2016-07-18 20:46:40 -07:00
|
|
|
public static final Comparator<MagicCardDefinition> TOUGHNESS_COMPARATOR_DESC= (cd1, cd2) -> {
|
|
|
|
final int t1 = cd1.isCreature() ? cd1.getCardToughness() : -100;
|
|
|
|
final int t2 = cd2.isCreature() ? cd2.getCardToughness() : -100;
|
|
|
|
return t1 != t2 ? t1 - t2 : cd1.getName().compareTo(cd2.getName());
|
2013-04-12 19:32:25 -07:00
|
|
|
};
|
|
|
|
|
2016-07-18 20:46:40 -07:00
|
|
|
public static final Comparator<MagicCardDefinition> TOUGHNESS_COMPARATOR_ASC= (cd1, cd2) -> TOUGHNESS_COMPARATOR_DESC.compare(cd2, cd1);
|
2015-11-16 08:09:38 -08:00
|
|
|
|
|
|
|
public boolean isImageFileMissing() {
|
2017-01-21 07:46:54 -08:00
|
|
|
return MagicCardImages.isCardImageMissing(this);
|
2015-11-16 08:09:38 -08:00
|
|
|
}
|
2015-12-19 08:27:28 -08:00
|
|
|
|
|
|
|
public void setPowerToughnessText(String string) {
|
|
|
|
powerToughnessText = string;
|
|
|
|
}
|
|
|
|
|
2017-06-16 20:19:03 -07:00
|
|
|
@Override
|
2015-12-19 08:27:28 -08:00
|
|
|
public String getPowerToughnessText() {
|
|
|
|
return powerToughnessText;
|
|
|
|
}
|
|
|
|
|
2017-01-31 05:47:24 -08:00
|
|
|
public void setSubTypeText(String string) {
|
2016-07-18 09:43:17 -07:00
|
|
|
subTypeText = string.replaceAll("(\\w),(\\w)", "$1, $2");// Not automatically adding space unless space is there
|
2015-12-19 08:27:28 -08:00
|
|
|
}
|
|
|
|
|
2017-06-16 20:19:03 -07:00
|
|
|
@Override
|
2015-12-19 08:27:28 -08:00
|
|
|
public String getSubTypeText() {
|
|
|
|
return subTypeText;
|
|
|
|
}
|
|
|
|
|
|
|
|
public String getPowerLabel() {
|
2016-07-18 09:43:17 -07:00
|
|
|
return isCreature() && powerToughnessText != null && !powerToughnessText.isEmpty() ? powerToughnessText.split("/")[0] : "";
|
2015-12-19 08:27:28 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
public String getToughnessLabel() {
|
2016-07-18 09:43:17 -07:00
|
|
|
return isCreature() && powerToughnessText != null && !powerToughnessText.isEmpty() ? powerToughnessText.split("/")[1] : "";
|
2015-12-19 08:27:28 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public boolean hasText() {
|
2016-07-18 09:43:17 -07:00
|
|
|
return !(getText().contains("NONE") || getText().length() <= 1);
|
2016-02-23 18:04:14 -08:00
|
|
|
}
|
2016-08-29 03:39:59 -07:00
|
|
|
|
|
|
|
public String getStatus() {
|
|
|
|
return status;
|
|
|
|
}
|
|
|
|
|
|
|
|
public boolean hasStatus() {
|
|
|
|
return status != null;
|
|
|
|
}
|
|
|
|
|
|
|
|
public boolean hasStatus(String aStatus) {
|
|
|
|
return aStatus.equals(status);
|
|
|
|
}
|
|
|
|
|
|
|
|
public void setStatus(final String value) {
|
|
|
|
int statusInt = unsupportedStatuses.indexOf(value);
|
|
|
|
if (statusInt == -1) {
|
|
|
|
unsupportedStatuses.add(value);
|
|
|
|
status = value;
|
|
|
|
} else {
|
|
|
|
status = unsupportedStatuses.get(statusInt);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-09-02 12:42:02 -07:00
|
|
|
public static String[] getUnsupportedStatuses() {
|
2016-08-29 03:39:59 -07:00
|
|
|
if (!isSorted) {
|
|
|
|
Collections.sort(unsupportedStatuses);
|
|
|
|
isSorted = true;
|
|
|
|
}
|
2016-09-02 12:42:02 -07:00
|
|
|
return unsupportedStatuses.toArray(new String[0]);
|
2016-08-29 03:39:59 -07:00
|
|
|
}
|
|
|
|
|
2013-04-12 19:32:25 -07:00
|
|
|
}
|