added addCardType to MageObject

This commit is contained in:
ingmargoudt 2017-04-05 15:36:07 +02:00
parent cf6fe27f7d
commit 8b90f87af6
52 changed files with 72 additions and 72 deletions

View file

@ -107,7 +107,7 @@ class AnimateArtifactContinuousEffect extends ContinuousEffectImpl {
Permanent permanent = game.getPermanent(enchantment.getAttachedTo());
if (permanent != null && !permanent.isCreature()) {
if (sublayer == SubLayer.NA) {
permanent.getCardType().add(CardType.CREATURE);
permanent.addCardType(CardType.CREATURE);
permanent.getPower().setValue(permanent.getConvertedManaCost());
permanent.getToughness().setValue(permanent.getConvertedManaCost());
}

View file

@ -90,7 +90,7 @@ class ChimericCoilsEffect extends ContinuousEffectImpl {
switch (layer) {
case TypeChangingEffects_4:
if (sublayer == SubLayer.NA) {
permanent.getCardType().add(CardType.CREATURE);
permanent.addCardType(CardType.CREATURE);
permanent.getSubtype(game).add("Construct");
}
break;

View file

@ -85,7 +85,7 @@ class ChimericStaffEffect extends ContinuousEffectImpl {
switch (layer) {
case TypeChangingEffects_4:
if (sublayer == SubLayer.NA) {
permanent.getCardType().add(CardType.CREATURE);
permanent.addCardType(CardType.CREATURE);
permanent.getSubtype(game).add("Construct");
}
break;

View file

@ -88,7 +88,7 @@ public class EnchantedEvening extends CardImpl {
public boolean apply(Game game, Ability source) {
for (Permanent permanent : game.getBattlefield().getAllActivePermanents(filter, game)) {
if (permanent != null && !permanent.getCardType().contains(addedCardType)) {
permanent.getCardType().add(addedCardType);
permanent.addCardType(addedCardType);
}
}
return true;

View file

@ -85,6 +85,6 @@ class CamaridToken extends Token {
this.getToughness().modifyBaseValue(1);
this.color.setBlue(true);
this.getSubtype(null).add("Camarid");
this.getCardType().add(CardType.CREATURE);
this.addCardType(CardType.CREATURE);
}
}

View file

@ -130,7 +130,7 @@ class BecomesColorlessLandEffect extends ContinuousEffectImpl {
case TypeChangingEffects_4:
boolean isLand = permanent.isLand();
permanent.getCardType().clear();
permanent.getCardType().add(CardType.LAND);
permanent.addCardType(CardType.LAND);
if (!isLand) {
permanent.getSubtype(game).clear();
}

View file

@ -80,7 +80,7 @@ class CatWarriorToken extends Token {
this.color.setGreen(true);
this.getSubtype(null).add("Cat");
this.getSubtype(null).add("Warrior");
this.getCardType().add(CardType.CREATURE);
this.addCardType(CardType.CREATURE);
this.addAbility(new ForestwalkAbility());
}
}

View file

@ -117,6 +117,6 @@ class RagavanToken extends Token {
this.getToughness().modifyBaseValue(1);
this.color.setRed(true);
this.getSubtype(null).add("Monkey");
this.getCardType().add(CardType.CREATURE);
this.addCardType(CardType.CREATURE);
}
}

View file

@ -110,7 +110,7 @@ class KarnSilverGolemEffect extends ContinuousEffectImpl {
case TypeChangingEffects_4:
if (sublayer == SubLayer.NA) {
if (!artifact.isCreature()) {
artifact.getCardType().add(CardType.CREATURE);
artifact.addCardType(CardType.CREATURE);
}
}
break;

View file

@ -28,8 +28,6 @@
package mage.cards.l;
import java.util.Iterator;
import java.util.UUID;
import mage.MageInt;
import mage.MageObjectReference;
import mage.abilities.Ability;
@ -39,12 +37,7 @@ import mage.abilities.effects.common.counter.AddCountersTargetEffect;
import mage.abilities.keyword.TrampleAbility;
import mage.cards.CardImpl;
import mage.cards.CardSetInfo;
import mage.constants.CardType;
import mage.constants.Duration;
import mage.constants.Layer;
import mage.constants.Outcome;
import mage.constants.SubLayer;
import mage.constants.Zone;
import mage.constants.*;
import mage.counters.CounterType;
import mage.filter.common.FilterLandPermanent;
import mage.game.Game;
@ -56,6 +49,9 @@ import mage.game.permanent.token.Token;
import mage.target.Target;
import mage.target.common.TargetLandPermanent;
import java.util.Iterator;
import java.util.UUID;
/**
*
* @author Loki
@ -138,7 +134,7 @@ class LiegeOfTheTangleEffect extends ContinuousEffectImpl {
switch (layer) {
case TypeChangingEffects_4:
if (sublayer == SubLayer.NA) {
perm.getCardType().addAll(token.getCardType());
perm.addCardTypes(token.getCardType());
perm.getSubtype(game).addAll(token.getSubtype(game));
}
break;

View file

@ -100,13 +100,13 @@ class LifeAndLimbEffect extends ContinuousEffectImpl {
switch (layer) {
case TypeChangingEffects_4:
if (!permanent.isCreature()) {
permanent.getCardType().add(CardType.CREATURE);
permanent.addCardType(CardType.CREATURE);
}
if (!permanent.getSubtype(game).contains("Saproling")) {
permanent.getSubtype(game).add("Saproling");
}
if (!permanent.isLand()) {
permanent.getCardType().add(CardType.LAND);
permanent.addCardType(CardType.LAND);
}
if (!permanent.getSubtype(game).contains("Forest")) {
permanent.getSubtype(game).add("Forest");

View file

@ -97,7 +97,7 @@ class MarchOfTheMachinesEffect extends ContinuousEffectImpl {
for(Permanent permanent : game.getBattlefield().getAllActivePermanents(filter, game)){
if(permanent != null){
affectedObjectList.add(new MageObjectReference(permanent, game));
permanent.getCardType().add(CardType.CREATURE);
permanent.addCardType(CardType.CREATURE);
}
}
}

View file

@ -83,7 +83,7 @@ class PermanentsAreArtifactsEffect extends ContinuousEffectImpl {
@Override
public boolean apply(Game game, Ability source) {
for (Permanent perm : game.getBattlefield().getActivePermanents(source.getControllerId(), game)) {
perm.getCardType().add(CardType.ARTIFACT);
perm.addCardType(CardType.ARTIFACT);
}
return true;
}

View file

@ -99,7 +99,7 @@ class BecomesCreatureAllEffect extends ContinuousEffectImpl {
for (Iterator<MageObjectReference> it = affectedObjectList.iterator(); it.hasNext();) {
Permanent permanent = it.next().getPermanent(game);
if (permanent != null) {
permanent.getCardType().add(CardType.CREATURE);
permanent.addCardType(CardType.CREATURE);
} else {
it.remove();
}

View file

@ -132,7 +132,7 @@ class NissaSageAnimistToken extends Token {
this.getToughness().modifyBaseValue(4);
this.color.setGreen(true);
this.getSubtype(null).add("Elemental");
this.getCardType().add(CardType.CREATURE);
this.addCardType(CardType.CREATURE);
}
}
@ -160,7 +160,7 @@ class NissaSageAnimistMinusSevenEffect extends ContinuousEffectImpl {
switch (layer) {
case TypeChangingEffects_4:
if (!permanent.isCreature()) {
permanent.getCardType().add(CardType.CREATURE);
permanent.addCardType(CardType.CREATURE);
}
if (!permanent.getSubtype(game).contains("Elemental")) {
permanent.getSubtype(game).add("Elemental");

View file

@ -109,7 +109,7 @@ class OpalescenceEffect extends ContinuousEffectImpl {
case TypeChangingEffects_4:
if (sublayer == SubLayer.NA) {
if (!permanent.isCreature()) {
permanent.getCardType().add(CardType.CREATURE);
permanent.addCardType(CardType.CREATURE);
}
}
break;

View file

@ -76,7 +76,7 @@ public class PhyrexianMetamorph extends CardImpl {
@Override
public boolean apply(Game game, MageObject mageObject) {
if (!mageObject.isArtifact()) {
mageObject.getCardType().add(CardType.ARTIFACT);
mageObject.addCardType(CardType.ARTIFACT);
}
return true;
}

View file

@ -118,7 +118,7 @@ class SarkhanTheDragonspeakerEffect extends ContinuousEffectImpl {
case TypeChangingEffects_4:
if (sublayer == SubLayer.NA) {
permanent.getCardType().clear();
permanent.getCardType().add(CardType.CREATURE);
permanent.addCardType(CardType.CREATURE);
permanent.getSubtype(game).clear();
permanent.getSubtype(game).add("Dragon");
permanent.getSuperType().clear();

View file

@ -98,7 +98,7 @@ public class SlumberingTora extends CardImpl {
switch (layer) {
case TypeChangingEffects_4:
if (sublayer == SubLayer.NA) {
permanent.getCardType().add(CardType.CREATURE);
permanent.addCardType(CardType.CREATURE);
permanent.getSubtype(game).add("Cat");
}
break;

View file

@ -119,7 +119,7 @@ class BecomesColorlessForestLandEffect extends ContinuousEffectImpl {
break;
case TypeChangingEffects_4:
permanent.getCardType().clear();
permanent.getCardType().add(CardType.LAND);
permanent.addCardType(CardType.LAND);
permanent.getSubtype(game).clear();
permanent.getSubtype(game).add("Forest");
break;

View file

@ -133,7 +133,7 @@ class StarfieldOfNyxEffect extends ContinuousEffectImpl {
case TypeChangingEffects_4:
if (sublayer == SubLayer.NA) {
if (!permanent.isCreature()) {
permanent.getCardType().add(CardType.CREATURE);
permanent.addCardType(CardType.CREATURE);
}
}
break;

View file

@ -91,8 +91,8 @@ class StartYourEnginesEffect extends ContinuousEffectImpl {
for (Permanent permanent : game.getBattlefield().getAllActivePermanents(source.getControllerId())) {
if (permanent != null && permanent.getSubtype(game).contains("Vehicle")) {
if (sublayer == SubLayer.NA) {
permanent.getCardType().add(CardType.ARTIFACT);
permanent.getCardType().add(CardType.CREATURE);// TODO: Chcek if giving CREATURE Type is correct
permanent.addCardType(CardType.ARTIFACT);
permanent.addCardType(CardType.CREATURE);// TODO: Chcek if giving CREATURE Type is correct
}
}
}

View file

@ -121,7 +121,7 @@ class SydriGalvanicGeniusEffect extends ContinuousEffectImpl {
case TypeChangingEffects_4:
if (sublayer == SubLayer.NA) {
if (!artifact.isCreature()) {
artifact.getCardType().add(CardType.CREATURE);
artifact.addCardType(CardType.CREATURE);
}
}
break;

View file

@ -112,7 +112,7 @@ class TestamentOfFaithBecomesCreatureSourceEffect extends ContinuousEffectImpl i
if (!token.getCardType().isEmpty()) {
for (CardType t : token.getCardType()) {
if (!permanent.getCardType().contains(t)) {
permanent.getCardType().add(t);
permanent.addCardType(t);
}
}
}

View file

@ -160,10 +160,10 @@ class TezzeretTheSeekerEffect3 extends ContinuousEffectImpl {
case TypeChangingEffects_4:
if (sublayer == SubLayer.NA) {
if (!permanent.isArtifact()) {
permanent.getCardType().add(CardType.ARTIFACT);
permanent.addCardType(CardType.ARTIFACT);
}
if (!permanent.isCreature()) {
permanent.getCardType().add(CardType.CREATURE);
permanent.addCardType(CardType.CREATURE);
}
permanent.getSubtype(game).clear();
}

View file

@ -100,7 +100,7 @@ class TitaniasSongEffect extends ContinuousEffectImpl {
for(Permanent permanent : game.getBattlefield().getAllActivePermanents(filter, game)){
if(permanent != null){
affectedObjectList.add(new MageObjectReference(permanent, game));
permanent.getCardType().add(CardType.CREATURE);
permanent.addCardType(CardType.CREATURE);
}
}
}

View file

@ -104,7 +104,7 @@ class VolrathsShapeshifterEffect extends ContinuousEffectImpl {
permanent.setName(card.getName());
for (CardType type : card.getCardType()) {
permanent.getCardType().add(type);
permanent.addCardType(type);
}
permanent.getSubtype(game).clear();

View file

@ -79,7 +79,7 @@ class WireflyToken extends Token {
this.getPower().modifyBaseValue(2);
this.getToughness().modifyBaseValue(2);
this.getSubtype(null).add("Insect");
this.getCardType().add(CardType.ARTIFACT);
this.getCardType().add(CardType.CREATURE);
this.addCardType(CardType.ARTIFACT);
this.addCardType(CardType.CREATURE);
}
}

View file

@ -145,7 +145,7 @@ class XenicPoltergeistEffect extends ContinuousEffectImpl {
UUID permanentId = targetPointer.getFirst(game, source);
Permanent permanent = game.getPermanentOrLKIBattlefield(permanentId);
if(permanent != null){
permanent.getCardType().add(CardType.CREATURE);
permanent.addCardType(CardType.CREATURE);
}
}
break;

View file

@ -27,8 +27,6 @@
*/
package mage.sets;
import java.util.ArrayList;
import java.util.List;
import mage.cards.CardGraphicInfo;
import mage.cards.ExpansionSet;
import mage.cards.repository.CardCriteria;
@ -37,6 +35,9 @@ import mage.cards.repository.CardRepository;
import mage.constants.Rarity;
import mage.constants.SetType;
import java.util.ArrayList;
import java.util.List;
/**
*
* @author fireshoes
@ -105,7 +106,7 @@ public class Amonkhet extends ExpansionSet {
cards.add(new SetCardInfo("Island", 258, Rarity.LAND, mage.cards.basiclands.Island.class, new CardGraphicInfo(null, true)));
cards.add(new SetCardInfo("Island", 259, Rarity.LAND, mage.cards.basiclands.Island.class, new CardGraphicInfo(null, true)));
cards.add(new SetCardInfo("Island", 260, Rarity.LAND, mage.cards.basiclands.Island.class, new CardGraphicInfo(null, true)));
cards.add(new SetCardInfo("Kefnet the Mindful", 59, Rarity.MYTHIC, mage.cards.k.KefnetTheMindful.class));
// cards.add(new SetCardInfo("Kefnet the Mindful", 59, Rarity.MYTHIC, mage.cards.k.KefnetTheMindful.class));
cards.add(new SetCardInfo("Kefnet's Monument", 231, Rarity.UNCOMMON, mage.cards.k.KefnetsMonument.class));
cards.add(new SetCardInfo("Lay Bare the Heart", 96, Rarity.UNCOMMON, mage.cards.l.LayBareTheHeart.class));
cards.add(new SetCardInfo("Liliana, Death Wielder", 274, Rarity.MYTHIC, mage.cards.l.LilianaDeathWielder.class));

View file

@ -138,7 +138,7 @@ public interface MageObject extends MageItem, Serializable {
}
default void addCardType(CardType cardType) {
getCardType().add(cardType);
addCardType(cardType);
}
/**
@ -186,4 +186,7 @@ public interface MageObject extends MageItem, Serializable {
return false;
}
default void addCardTypes(EnumSet<CardType> cardType){
getCardType().addAll(cardType);
}
}

View file

@ -139,7 +139,7 @@ class LicidContinuousEffect extends ContinuousEffectImpl {
switch (layer) {
case TypeChangingEffects_4:
licid.getCardType().clear();
licid.getCardType().add(CardType.ENCHANTMENT);
licid.addCardType(CardType.ENCHANTMENT);
licid.getSubtype(game).clear();
licid.getSubtype(game).add("Aura");
break;

View file

@ -122,7 +122,7 @@ public class CopyEffect extends ContinuousEffectImpl {
permanent.getManaCost().add(copyFromObject.getManaCost());
permanent.getCardType().clear();
for (CardType type : copyFromObject.getCardType()) {
permanent.getCardType().add(type);
permanent.addCardType(type);
}
permanent.getSubtype(game).clear();
for (String type : copyFromObject.getSubtype(game)) {

View file

@ -28,7 +28,7 @@ public class CopyTokenEffect extends ContinuousEffectImpl {
permanent.getColor(game).setColor(token.getColor(game));
permanent.getCardType().clear();
for (CardType type: token.getCardType()) {
permanent.getCardType().add(type);
permanent.addCardType(type);
}
permanent.getSubtype(game).clear();
for (String type: token.getSubtype(game)) {

View file

@ -190,10 +190,10 @@ public class PutTokenOntoBattlefieldCopyTargetEffect extends OneShotEffect {
CardUtil.copyTo(token).from(copyFrom); // needed so that entersBattlefied triggered abilities see the attributes (e.g. Master Biomancer)
applier.apply(game, token);
if (becomesArtifact) {
token.getCardType().add(CardType.ARTIFACT);
token.addCardType(CardType.ARTIFACT);
}
if (additionalCardType != null && !token.getCardType().contains(additionalCardType)) {
token.getCardType().add(additionalCardType);
token.addCardType(additionalCardType);
}
if (gainsHaste) {
token.addAbility(HasteAbility.getInstance());

View file

@ -60,7 +60,7 @@ public class AddCardTypeAttachedEffect extends ContinuousEffectImpl {
if (equipment != null && equipment.getAttachedTo() != null) {
Permanent target = game.getPermanent(equipment.getAttachedTo());
if (target != null && !target.getCardType().contains(addedCardType))
target.getCardType().add(addedCardType);
target.addCardType(addedCardType);
}
return true;
}

View file

@ -66,7 +66,7 @@ public class AddCardTypeSourceEffect extends ContinuousEffectImpl {
Permanent permanent = game.getPermanent(source.getSourceId());
if (permanent != null && affectedObjectList.contains(new MageObjectReference(permanent, game))) {
if (!permanent.getCardType().contains(addedCardType)) {
permanent.getCardType().add(addedCardType);
permanent.addCardType(addedCardType);
}
return true;
} else if (this.getDuration() == Duration.Custom) {

View file

@ -69,7 +69,7 @@ public class AddCardTypeTargetEffect extends ContinuousEffectImpl {
Permanent target = game.getPermanent(targetId);
if (target != null) {
if (!target.getCardType().contains(addedCardType)) {
target.getCardType().add(addedCardType);
target.addCardType(addedCardType);
}
result = true;
}

View file

@ -145,7 +145,7 @@ public class BecomesBasicLandTargetEffect extends ContinuousEffectImpl {
case TypeChangingEffects_4:
// Attention: Cards like Unstable Frontier that use this class do not give the "Basic" supertype to the target
if (!land.isLand()) {
land.getCardType().add(CardType.LAND);
land.addCardType(CardType.LAND);
}
if (loseOther) {
// 305.7 Note that this doesn't remove any abilities that were granted to the land by other effects

View file

@ -79,7 +79,7 @@ public class BecomesCreatureAllEffect extends ContinuousEffectImpl {
if (!token.getCardType().isEmpty()) {
for (CardType t : token.getCardType()) {
if (!permanent.getCardType().contains(t)) {
permanent.getCardType().add(t);
permanent.addCardType(t);
}
}
}

View file

@ -93,7 +93,7 @@ public class BecomesCreatureAttachedEffect extends ContinuousEffectImpl {
break;
}
for (CardType t : token.getCardType()) {
permanent.getCardType().add(t);
permanent.addCardType(t);
}
// sub type

View file

@ -109,7 +109,7 @@ public class BecomesCreatureAttachedWithActivatedAbilityOrSpellEffect extends Co
break;
}
for (CardType cardType : token.getCardType()) {
permanentAttachedTo.getCardType().add(cardType);
permanentAttachedTo.addCardType(cardType);
}
// sub type

View file

@ -116,7 +116,7 @@ public class BecomesCreatureSourceEffect extends ContinuousEffectImpl implements
if (!token.getCardType().isEmpty()) {
for (CardType t : token.getCardType()) {
if (!permanent.getCardType().contains(t)) {
permanent.getCardType().add(t);
permanent.addCardType(t);
}
}
}

View file

@ -103,7 +103,7 @@ public class BecomesCreatureTargetEffect extends ContinuousEffectImpl {
if (!token.getCardType().isEmpty()) {
for (CardType t : token.getCardType()) {
if (!permanent.getCardType().contains(t)) {
permanent.getCardType().add(t);
permanent.addCardType(t);
}
}
}

View file

@ -109,7 +109,7 @@ public class BecomesFaceDownCreatureAllEffect extends ContinuousEffectImpl imple
permanent.setName("");
permanent.getSuperType().clear();
permanent.getCardType().clear();
permanent.getCardType().add(CardType.CREATURE);
permanent.addCardType(CardType.CREATURE);
permanent.getSubtype(game).clear();
permanent.getManaCost().clear();
break;

View file

@ -165,7 +165,7 @@ public class BecomesFaceDownCreatureEffect extends ContinuousEffectImpl implemen
permanent.setName("");
permanent.getSuperType().clear();
permanent.getCardType().clear();
permanent.getCardType().add(CardType.CREATURE);
permanent.addCardType(CardType.CREATURE);
permanent.getSubtype(game).clear();
break;
case ColorChangingEffects_5:

View file

@ -151,12 +151,12 @@ public class BestowAbility extends SpellAbility {
if (basicObject != null) {
basicObject.getSubtype(null).remove("Aura");
if (!basicObject.isCreature()) {
basicObject.getCardType().add(CardType.CREATURE);
basicObject.addCardType(CardType.CREATURE);
}
}
permanent.getSubtype(null).remove("Aura");
if (!permanent.isCreature()) {
permanent.getCardType().add(CardType.CREATURE);
permanent.addCardType(CardType.CREATURE);
}
}

View file

@ -299,7 +299,7 @@ public class MorphAbility extends StaticAbility implements AlternativeSourceCost
mageObject.getColor(null).setColor(new ObjectColor());
mageObject.setName("");
mageObject.getCardType().clear();
mageObject.getCardType().add(CardType.CREATURE);
mageObject.addCardType(CardType.CREATURE);
mageObject.getSubtype(null).clear();
mageObject.getSuperType().clear();
mageObject.getManaCost().clear();

View file

@ -77,7 +77,7 @@ public class TransformAbility extends SimpleStaticAbility {
permanent.getManaCost().add(sourceCard.getManaCost());
permanent.getCardType().clear();
for (CardType type : sourceCard.getCardType()) {
permanent.getCardType().add(type);
permanent.addCardType(type);
}
permanent.getSubtype(game).clear();
for (String type : sourceCard.getSubtype(game)) {

View file

@ -253,14 +253,14 @@ public class Spell extends StackObjImpl implements Card {
Permanent permanent = game.getPermanent(card.getId());
if (permanent != null && permanent instanceof PermanentCard) {
permanent.setSpellAbility(ability); // otherwise spell ability without bestow will be set
card.getCardType().add(CardType.CREATURE);
card.addCardType(CardType.CREATURE);
card.getSubtype(game).remove("Aura");
}
}
return ability.resolve(game);
}
if (bestow) {
card.getCardType().add(CardType.CREATURE);
card.addCardType(CardType.CREATURE);
}
return false;
}
@ -270,7 +270,7 @@ public class Spell extends StackObjImpl implements Card {
if (controller.moveCards(card, Zone.BATTLEFIELD, ability, game, false, faceDown, false, null)) {
Permanent permanent = game.getPermanent(card.getId());
if (permanent != null && permanent instanceof PermanentCard) {
((PermanentCard) permanent).getCard().getCardType().add(CardType.CREATURE);
((PermanentCard) permanent).getCard().addCardType(CardType.CREATURE);
((PermanentCard) permanent).getCard().getSubtype(game).remove("Aura");
return true;
}

View file

@ -47,7 +47,7 @@ public class CardTypeApplier extends ApplyToPermanent {
@Override
public boolean apply(Game game, Permanent permanent) {
if (!permanent.getCardType().contains(cardType)) {
permanent.getCardType().add(cardType);
permanent.addCardType(cardType);
}
return true;
}
@ -55,7 +55,7 @@ public class CardTypeApplier extends ApplyToPermanent {
@Override
public boolean apply(Game game, MageObject mageObject) {
if (!mageObject.getCardType().contains(cardType)) {
mageObject.getCardType().add(cardType);
mageObject.addCardType(cardType);
}
return true;
}

View file

@ -93,7 +93,7 @@ public class CopyTokenFunction implements Function<Token, Card> {
target.getManaCost().add(sourceObj.getManaCost());
target.getCardType().clear();
for (CardType type : sourceObj.getCardType()) {
target.getCardType().add(type);
target.addCardType(type);
}
target.getSubtype(null).clear();
for (String type : sourceObj.getSubtype(null)) {