Refactored more subtypes usages to enum

This commit is contained in:
Evan Kranzler 2017-09-08 09:57:51 -04:00
parent 80b61ccbd6
commit 252c941b4f
21 changed files with 63 additions and 46 deletions

View file

@ -602,7 +602,7 @@ public class ModernCardRenderer extends CardRenderer {
int partWidth = (int) Math.max(30, 0.20f * cardWidth);
// Is it a creature?
boolean isVehicle = cardView.getSubTypes().contains("Vehicle");
boolean isVehicle = cardView.getSubTypes().contains(SubType.VEHICLE);
if (cardView.isCreature() || isVehicle) {
int x = cardWidth - borderWidth - partWidth;

View file

@ -8,6 +8,7 @@ import mage.interfaces.rate.RateCallback;
import mage.util.RandomUtil;
import java.util.*;
import mage.constants.SubType;
/**
* Builds deck from provided card pool.
@ -114,7 +115,7 @@ public final class DeckBuilder {
* @param count
*/
private static void addCardsToDeck(final Collection<MageScoredCard> remainingCards, final int minCost, final int maxCost,
final int count) {
final int count) {
for (int c = count; c > 0; c--) {
@ -140,7 +141,8 @@ public final class DeckBuilder {
}
/**
* Adds lands from non basic land (if provided), adds basic lands getting them from provided {@link RateCallback}}.
* Adds lands from non basic land (if provided), adds basic lands getting
* them from provided {@link RateCallback}}.
*
* @param allowedColors
* @param landCardPool
@ -241,9 +243,9 @@ public final class DeckBuilder {
int type;
if (card.isCreature()) {
type = 10;
} else if (card.getSubtype(null).contains("Equipment")) {
} else if (card.getSubtype(null).contains(SubType.EQUIPMENT)) {
type = 8;
} else if (card.getSubtype(null).contains("Aura")) {
} else if (card.getSubtype(null).contains(SubType.AURA)) {
type = 5;
} else if (card.isInstant()) {
type = 7;
@ -251,11 +253,11 @@ public final class DeckBuilder {
type = 6;
}
this.score =
// 5*card.getValue() + // not possible now
3 * cardRater.rateCard(card) +
// 3*card.getRemoval() + // not possible now
type + getManaCostScore(card, allowedColors);
this.score
= // 5*card.getValue() + // not possible now
3 * cardRater.rateCard(card)
+ // 3*card.getRemoval() + // not possible now
type + getManaCostScore(card, allowedColors);
}
private int getManaCostScore(Card card, List<ColoredManaSymbol> allowedColors) {

View file

@ -11,6 +11,7 @@ import mage.game.Game;
import mage.game.permanent.Permanent;
import java.util.UUID;
import mage.constants.SubType;
/**
* @author ubeefx, nantuko
@ -56,7 +57,7 @@ public final class ArtificialScoringSystem {
//score + =cardDefinition.getActivations().size()*50;
//score += cardDefinition.getManaActivations().size()*80;
} else {
if (permanent.getSubtype(game).contains("Equipment")) {
if (permanent.getSubtype(game).contains(SubType.EQUIPMENT)) {
score += 100;
}
}

View file

@ -13,6 +13,7 @@ import org.apache.log4j.Logger;
import java.io.InputStream;
import java.util.*;
import mage.constants.SubType;
/**
* Class responsible for reading ratings from resources and rating given cards.
@ -60,9 +61,9 @@ public final class RateCard {
type = 15;
} else if (card.isCreature()) {
type = 10;
} else if (card.getSubtype(null).contains("Equipment")) {
} else if (card.getSubtype(null).contains(SubType.EQUIPMENT)) {
type = 8;
} else if (card.getSubtype(null).contains("Aura")) {
} else if (card.getSubtype(null).contains(SubType.AURA)) {
type = 5;
} else if (card.isInstant()) {
type = 7;
@ -77,7 +78,7 @@ public final class RateCard {
}
private static int isRemoval(Card card) {
if (card.getSubtype(null).contains("Aura") || card.isInstant() || card.isSorcery()) {
if (card.getSubtype(null).contains(SubType.AURA) || card.isInstant() || card.isSorcery()) {
for (Ability ability : card.getAbilities()) {
for (Effect effect : ability.getEffects()) {

View file

@ -59,7 +59,7 @@ public class SakashimasStudent extends CardImpl {
this.addAbility(new NinjutsuAbility(new ManaCostsImpl("{1}{U}")));
// You may have Sakashima's Student enter the battlefield as a copy of any creature on the battlefield, except it's still a Ninja in addition to its other creature types.
Effect effect = new CopyPermanentEffect(StaticFilters.FILTER_PERMANENT_CREATURE, new AddSubtypeApplier("Ninja"));
Effect effect = new CopyPermanentEffect(StaticFilters.FILTER_PERMANENT_CREATURE, new AddSubtypeApplier(SubType.NINJA));
effect.setText("as a copy of any creature on the battlefield, except it's a Ninja in addition to its other creature types");
this.addAbility(new EntersBattlefieldAbility(effect, true));

View file

@ -40,6 +40,7 @@ import mage.cards.CardImpl;
import mage.cards.CardSetInfo;
import mage.constants.CardType;
import mage.constants.Outcome;
import mage.constants.SubType;
import mage.constants.TargetController;
import mage.constants.Zone;
import mage.filter.common.FilterCreatureCard;
@ -98,7 +99,7 @@ class SeanceEffect extends OneShotEffect {
controller.moveCards(card, Zone.EXILED, source, game); // Also if the move to exile is replaced, the copy takes place
CreateTokenCopyTargetEffect effect = new CreateTokenCopyTargetEffect(source.getControllerId(), null, false);
effect.setTargetPointer(new FixedTarget(card.getId(), card.getZoneChangeCounter(game)));
effect.setAdditionalSubType("Spirit");
effect.setAdditionalSubType(SubType.SPIRIT);
effect.apply(game, source);
ExileTargetEffect exileEffect = new ExileTargetEffect();
exileEffect.setTargetPointer(new FixedTargets(effect.getAddedPermanent(), game));

View file

@ -40,6 +40,7 @@ import mage.cards.CardImpl;
import mage.cards.CardSetInfo;
import mage.constants.CardType;
import mage.constants.Outcome;
import mage.constants.SubType;
import mage.constants.Zone;
import mage.filter.common.FilterCreatureCard;
import mage.game.Game;
@ -60,7 +61,7 @@ public class SoulSeparator extends CardImpl {
// Create a token that's a copy of that card except it's 1/1, it's a Spirit in addition to its other types, and it has flying.
// Create a black Zombie creature token with power equal to that card's power and toughness equal that card's toughness.
CreateTokenCopyTargetEffect copyEffect = new CreateTokenCopyTargetEffect(null, null, false, 1, false, false, null, 1, 1, true);
copyEffect.setAdditionalSubType("Spirit");
copyEffect.setAdditionalSubType(SubType.SPIRIT);
copyEffect.setText("Create a token that's a copy of that card except it's 1/1, it's a Spirit in addition to its other types, and it has flying.");
Ability ability = new SimpleActivatedAbility(Zone.BATTLEFIELD, copyEffect, new ManaCostsImpl("{5}"));
ability.addCost(new TapSourceCost());

View file

@ -163,7 +163,7 @@ class TheScarabGodEffect2 extends OneShotEffect {
controller.moveCards(card, Zone.EXILED, source, game); // Also if the move to exile is replaced, the copy takes place
CreateTokenCopyTargetEffect effect = new CreateTokenCopyTargetEffect(source.getControllerId(), null, false, 1, false, false, null, 4, 4, false);
effect.setTargetPointer(new FixedTarget(card.getId(), card.getZoneChangeCounter(game)));
effect.setOnlySubType("Zombie");
effect.setOnlySubType(SubType.ZOMBIE);
effect.setOnlyColor(ObjectColor.BLACK);
effect.apply(game, source);
return true;

View file

@ -47,6 +47,7 @@ import mage.constants.Duration;
import mage.constants.Layer;
import mage.constants.Outcome;
import mage.constants.SubLayer;
import mage.constants.SubType;
import mage.constants.Zone;
import mage.game.Game;
import mage.game.permanent.Permanent;
@ -142,7 +143,7 @@ class LicidContinuousEffect extends ContinuousEffectImpl {
licid.getCardType().clear();
licid.addCardType(CardType.ENCHANTMENT);
licid.getSubtype(game).clear();
licid.getSubtype(game).add("Aura");
licid.getSubtype(game).add(SubType.AURA);
break;
case AbilityAddingRemovingEffects_6:
ArrayList<Ability> toRemove = new ArrayList<>();

View file

@ -41,6 +41,7 @@ import mage.abilities.keyword.HasteAbility;
import mage.cards.Card;
import mage.constants.CardType;
import mage.constants.Outcome;
import mage.constants.SubType;
import mage.constants.SuperType;
import mage.game.Game;
import mage.game.permanent.Permanent;
@ -61,8 +62,8 @@ public class CreateTokenCopyTargetEffect extends OneShotEffect {
private boolean gainsHaste;
private final int number;
private List<Permanent> addedTokenPermanents;
private String additionalSubType;
private String onlySubType;
private SubType additionalSubType;
private SubType onlySubType;
private boolean tapped;
private boolean attacking;
private UUID attackedPlayer;
@ -296,11 +297,11 @@ public class CreateTokenCopyTargetEffect extends OneShotEffect {
return addedTokenPermanents;
}
public void setAdditionalSubType(String additionalSubType) {
public void setAdditionalSubType(SubType additionalSubType) {
this.additionalSubType = additionalSubType;
}
public void setOnlySubType(String onlySubType) {
public void setOnlySubType(SubType onlySubType) {
this.onlySubType = onlySubType;
}

View file

@ -36,6 +36,7 @@ import mage.constants.Duration;
import mage.constants.Layer;
import mage.constants.Outcome;
import mage.constants.SubLayer;
import mage.constants.SubType;
import mage.game.Game;
import mage.game.permanent.Permanent;
import mage.target.Target;
@ -83,8 +84,8 @@ public class BecomesAuraSourceEffect extends ContinuousEffectImpl implements Sou
switch (layer) {
case TypeChangingEffects_4:
if (sublayer == SubLayer.NA) {
if (!permanent.getSubtype(game).contains("Aura")) {
permanent.getSubtype(game).add("Aura");
if (!permanent.getSubtype(game).contains(SubType.AURA)) {
permanent.getSubtype(game).add(SubType.AURA);
}
}
break;

View file

@ -43,6 +43,7 @@ import mage.constants.CardType;
import mage.constants.Duration;
import mage.constants.Outcome;
import mage.constants.SpellAbilityType;
import mage.constants.SubType;
import mage.constants.Zone;
import mage.counters.CounterType;
import mage.filter.common.FilterControlledLandPermanent;
@ -163,7 +164,7 @@ class AwakenElementalToken extends Token {
super("", "0/0 Elemental creature with haste");
this.cardType.add(CardType.CREATURE);
this.subtype.add("Elemental");
this.subtype.add(SubType.ELEMENTAL);
this.power = new MageInt(0);
this.toughness = new MageInt(0);

View file

@ -39,6 +39,7 @@ import mage.constants.CardType;
import mage.constants.Duration;
import mage.constants.Outcome;
import mage.constants.SpellAbilityType;
import mage.constants.SubType;
import mage.constants.TimingRule;
import mage.constants.Zone;
import mage.game.Game;
@ -149,12 +150,12 @@ public class BestowAbility extends SpellAbility {
if (permanent != null) {
MageObject basicObject = permanent.getBasicMageObject(game);
if (basicObject != null) {
basicObject.getSubtype(null).remove("Aura");
basicObject.getSubtype(null).remove(SubType.AURA);
if (!basicObject.isCreature()) {
basicObject.addCardType(CardType.CREATURE);
}
}
permanent.getSubtype(null).remove("Aura");
permanent.getSubtype(null).remove(SubType.AURA);
if (!permanent.isCreature()) {
permanent.addCardType(CardType.CREATURE);
}
@ -187,9 +188,9 @@ class BestowEntersBattlefieldEffect extends ReplacementEffectImpl {
public boolean replaceEvent(GameEvent event, Ability source, Game game) {
Permanent bestowPermanent = game.getPermanentEntering(source.getSourceId());
if (bestowPermanent != null) {
if (bestowPermanent.getSubtype(game).contains("Aura")) {
if (bestowPermanent.getSubtype(game).contains(SubType.AURA)) {
MageObject basicObject = bestowPermanent.getBasicMageObject(game);
basicObject.getSubtype(null).add("Aura");
basicObject.getSubtype(null).add(SubType.AURA);
basicObject.getCardType().remove(CardType.CREATURE);
}
}

View file

@ -24,8 +24,7 @@
* 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.cards.basiclands;
import java.util.UUID;
@ -34,6 +33,7 @@ import mage.cards.CardSetInfo;
import mage.constants.CardType;
import mage.abilities.mana.ActivatedManaAbilityImpl;
import mage.cards.CardImpl;
import mage.constants.SubType;
import mage.constants.SuperType;
/**
@ -44,7 +44,7 @@ public abstract class BasicLand extends CardImpl {
public BasicLand(UUID ownerId, CardSetInfo setInfo, ActivatedManaAbilityImpl mana) {
super(ownerId, setInfo, new CardType[]{CardType.LAND}, null);
addSuperType(SuperType.BASIC);
this.subtype.add(name);
this.subtype.add(SubType.byDescription(name));
this.addAbility(mana);
}

View file

@ -25,9 +25,10 @@
* authors and should not be interpreted as representing official policies, either expressed
* or implied, of BetaSteward_at_googlemail.com.
*/
package mage.game.permanent.token;
import mage.constants.CardType;
import mage.constants.SubType;
/**
*
@ -41,7 +42,7 @@ public class CamaridToken extends Token {
this.getPower().modifyBaseValue(1);
this.getToughness().modifyBaseValue(1);
this.color.setBlue(true);
this.getSubtype(null).add("Camarid");
this.getSubtype(null).add(SubType.CAMARID);
this.addCardType(CardType.CREATURE);
}
}

View file

@ -29,6 +29,7 @@
package mage.game.permanent.token;
import mage.constants.CardType;
import mage.abilities.keyword.ForestwalkAbility;
import mage.constants.SubType;
/**
*
@ -42,8 +43,8 @@ public class CatWarriorToken extends Token {
this.getPower().modifyBaseValue(2);
this.getToughness().modifyBaseValue(2);
this.color.setGreen(true);
this.getSubtype(null).add("Cat");
this.getSubtype(null).add("Warrior");
this.getSubtype(null).add(SubType.CAT);
this.getSubtype(null).add(SubType.WARRIOR);
this.addCardType(CardType.CREATURE);
this.addAbility(new ForestwalkAbility());
}

View file

@ -25,9 +25,10 @@
* authors and should not be interpreted as representing official policies, either expressed
* or implied, of BetaSteward_at_googlemail.com.
*/
package mage.game.permanent.token;
import mage.constants.CardType;
import mage.constants.SubType;
import mage.constants.SuperType;
/**
@ -43,7 +44,7 @@ public class NissaSageAnimistToken extends Token {
this.getPower().modifyBaseValue(4);
this.getToughness().modifyBaseValue(4);
this.color.setGreen(true);
this.getSubtype(null).add("Elemental");
this.getSubtype(null).add(SubType.ELEMENTAL);
this.addCardType(CardType.CREATURE);
}
}

View file

@ -28,6 +28,7 @@
package mage.game.permanent.token;
import mage.constants.CardType;
import mage.constants.SubType;
import mage.constants.SuperType;
/**
@ -43,7 +44,7 @@ public class RagavanToken extends Token {
this.getPower().modifyBaseValue(2);
this.getToughness().modifyBaseValue(1);
this.color.setRed(true);
this.getSubtype(null).add("Monkey");
this.getSubtype(null).add(SubType.MONKEY);
this.addCardType(CardType.CREATURE);
}
}

View file

@ -29,6 +29,7 @@ package mage.game.permanent.token;
import mage.constants.CardType;
import mage.abilities.keyword.FlyingAbility;
import mage.constants.SubType;
/**
*
@ -41,7 +42,7 @@ public class WireflyToken extends Token {
this.setOriginalExpansionSetCode("DST");
this.getPower().modifyBaseValue(2);
this.getToughness().modifyBaseValue(2);
this.getSubtype(null).add("Insect");
this.getSubtype(null).add(SubType.INSECT);
this.addCardType(CardType.ARTIFACT);
this.addCardType(CardType.CREATURE);
this.addAbility(FlyingAbility.getInstance());

View file

@ -253,7 +253,7 @@ public class Spell extends StackObjImpl implements Card {
// Must be removed first time, after that will be removed by continous effect
// Otherwise effects like evolve trigger from creature comes into play event
card.getCardType().remove(CardType.CREATURE);
card.getSubtype(game).add("Aura");
card.getSubtype(game).add(SubType.AURA);
}
if (controller.moveCards(card, Zone.BATTLEFIELD, ability, game, false, faceDown, false, null)) {
if (bestow) {
@ -482,7 +482,7 @@ public class Spell extends StackObjImpl implements Card {
public SubTypeList getSubtype(Game game) {
if (this.getSpellAbility() instanceof BestowAbility) {
SubTypeList subtypes = card.getSubtype(game);
subtypes.add("Aura");
subtypes.add(SubType.AURA);
return subtypes;
}
return card.getSubtype(game);
@ -492,7 +492,7 @@ public class Spell extends StackObjImpl implements Card {
public boolean hasSubtype(SubType subtype, Game game) {
if (this.getSpellAbility() instanceof BestowAbility) { // workaround for Bestow (don't like it)
SubTypeList subtypes = card.getSubtype(game);
subtypes.add("Aura");
subtypes.add(SubType.AURA);
if (subtypes.contains(subtype)) {
return true;
}

View file

@ -8,6 +8,7 @@ package mage.util.functions;
import java.util.UUID;
import mage.MageObject;
import mage.abilities.Ability;
import mage.constants.SubType;
import mage.game.Game;
import mage.game.permanent.Permanent;
@ -17,9 +18,9 @@ import mage.game.permanent.Permanent;
*/
public class AddSubtypeApplier extends ApplyToPermanent {
private final String subtype;
private final SubType subtype;
public AddSubtypeApplier(String subtype) {
public AddSubtypeApplier(SubType subtype) {
this.subtype = subtype;
}