Refactoring: replace custom creature tokens with basic class (11 cards)

This commit is contained in:
Oleg Agafonov 2018-05-06 19:08:56 +04:00
parent 72314a9512
commit f7a4e75909
11 changed files with 32 additions and 252 deletions

View file

@ -43,6 +43,7 @@ import mage.constants.Outcome;
import mage.constants.Zone;
import mage.game.permanent.token.TokenImpl;
import mage.game.permanent.token.Token;
import mage.game.permanent.token.custom.CreatureToken;
import mage.target.TargetPermanent;
import mage.target.common.TargetArtifactPermanent;
@ -66,7 +67,7 @@ public class EnsoulArtifact extends CardImpl {
// Enchanted artifact is a creature with base power and toughness 5/5 in addition to its other types.
this.addAbility(new SimpleStaticAbility(Zone.BATTLEFIELD,
new BecomesCreatureAttachedEffect(new EnsoulArtifactToken(), "Enchanted artifact is a creature with base power and toughness 5/5 in addition to its other types", Duration.WhileOnBattlefield)
new BecomesCreatureAttachedEffect(new CreatureToken(5, 5), "Enchanted artifact is a creature with base power and toughness 5/5 in addition to its other types", Duration.WhileOnBattlefield)
));
}
@ -79,21 +80,4 @@ public class EnsoulArtifact extends CardImpl {
public EnsoulArtifact copy() {
return new EnsoulArtifact(this);
}
}
class EnsoulArtifactToken extends TokenImpl {
EnsoulArtifactToken() {
super("", "5/5");
cardType.add(CardType.CREATURE);
power = new MageInt(5);
toughness = new MageInt(5);
}
public EnsoulArtifactToken(final EnsoulArtifactToken token) {
super(token);
}
public EnsoulArtifactToken copy() {
return new EnsoulArtifactToken(this);
}
}

View file

@ -34,6 +34,7 @@ import mage.abilities.common.SimpleStaticAbility;
import mage.abilities.effects.common.AttachEffect;
import mage.abilities.effects.common.continuous.BecomesCreatureAttachedEffect;
import mage.constants.Outcome;
import mage.game.permanent.token.custom.CreatureToken;
import mage.target.TargetPermanent;
import mage.abilities.keyword.EnchantAbility;
import mage.cards.CardImpl;
@ -43,7 +44,6 @@ import mage.constants.Duration;
import mage.constants.SubType;
import mage.constants.Zone;
import mage.game.permanent.token.TokenImpl;
import mage.game.permanent.token.Token;
import mage.target.common.TargetCreaturePermanent;
/**
@ -66,9 +66,9 @@ public class FowlPlay extends CardImpl {
// Enchanted creature is a Chicken with base power and toughness 1/1 and loses all abilities.
this.addAbility(new SimpleStaticAbility(Zone.BATTLEFIELD,
new BecomesCreatureAttachedEffect(new FowlPlayToken(),
new BecomesCreatureAttachedEffect(new CreatureToken(1, 1, "1/1 Chicken creature", SubType.CHICKEN),
"Enchanted creature is a Chicken with base power and toughness 1/1 and loses all abilities",
Duration.WhileOnBattlefield, BecomesCreatureAttachedEffect.LoseType.ABILITIES_SUBTYPE_AND_PT)));
Duration.WhileOnBattlefield, BecomesCreatureAttachedEffect.LoseType.ABILITIES_SUBTYPE)));
}
public FowlPlay(final FowlPlay card) {
@ -80,21 +80,3 @@ public class FowlPlay extends CardImpl {
return new FowlPlay(this);
}
}
class FowlPlayToken extends TokenImpl {
public FowlPlayToken() {
super("Chicken", "a Chicken with base power and toughness 1/1 with no abilities");
cardType.add(CardType.CREATURE);
subtype.add(SubType.CHICKEN);
power = new MageInt(1);
toughness = new MageInt(1);
}
public FowlPlayToken(final FowlPlayToken token) {
super(token);
}
public FowlPlayToken copy() {
return new FowlPlayToken(this);
}
}

View file

@ -45,6 +45,7 @@ import mage.filter.common.FilterControlledLandPermanent;
import mage.game.Game;
import mage.game.permanent.token.TokenImpl;
import mage.game.permanent.token.Token;
import mage.game.permanent.token.custom.CreatureToken;
import mage.players.Player;
import mage.target.Target;
import mage.target.common.TargetCardInYourGraveyard;
@ -60,7 +61,7 @@ public class LifeDeath extends SplitCard {
// Life
// All lands you control become 1/1 creatures until end of turn. They're still lands.
getLeftHalfCard().getSpellAbility().addEffect(new BecomesCreatureAllEffect(new LifeLandToken(), "lands",
getLeftHalfCard().getSpellAbility().addEffect(new BecomesCreatureAllEffect(new CreatureToken(1, 1), "lands",
new FilterControlledLandPermanent("lands you control"), Duration.EndOfTurn));
// Death
@ -81,24 +82,6 @@ public class LifeDeath extends SplitCard {
}
}
class LifeLandToken extends TokenImpl {
public LifeLandToken() {
super("", "1/1 creatures");
cardType.add(CardType.CREATURE);
power = new MageInt(1);
toughness = new MageInt(1);
}
public LifeLandToken(final LifeLandToken token) {
super(token);
}
public LifeLandToken copy() {
return new LifeLandToken(this);
}
}
class DeathEffect extends OneShotEffect {
public DeathEffect() {

View file

@ -42,7 +42,7 @@ import mage.constants.Duration;
import mage.constants.Outcome;
import mage.constants.Zone;
import mage.game.permanent.token.TokenImpl;
import mage.game.permanent.token.Token;
import mage.game.permanent.token.custom.CreatureToken;
import mage.target.TargetPermanent;
import mage.target.common.TargetCreaturePermanent;
@ -66,9 +66,9 @@ public class Lignify extends CardImpl {
// Enchanted creature is a Treefolk with base power and toughness 0/4 and loses all abilities.
this.addAbility(new SimpleStaticAbility(Zone.BATTLEFIELD,
new BecomesCreatureAttachedEffect(new LignifyTreefolkToken(),
new BecomesCreatureAttachedEffect(new CreatureToken(0, 4, "0/4 Treefolk creature", SubType.TREEFOLK),
"Enchanted creature is a Treefolk with base power and toughness 0/4 and loses all abilities",
Duration.WhileOnBattlefield, BecomesCreatureAttachedEffect.LoseType.ABILITIES_SUBTYPE_AND_PT)));
Duration.WhileOnBattlefield, BecomesCreatureAttachedEffect.LoseType.ABILITIES_SUBTYPE)));
}
@ -81,22 +81,3 @@ public class Lignify extends CardImpl {
return new Lignify(this);
}
}
class LignifyTreefolkToken extends TokenImpl {
public LignifyTreefolkToken() {
super("Treefolk", "a Treefolk with base power and toughness 0/4 with no abilities");
cardType.add(CardType.CREATURE);
subtype.add(SubType.TREEFOLK);
power = new MageInt(0);
toughness = new MageInt(4);
}
public LignifyTreefolkToken(final LignifyTreefolkToken token) {
super(token);
}
public LignifyTreefolkToken copy() {
return new LignifyTreefolkToken(this);
}
}

View file

@ -38,6 +38,7 @@ import mage.filter.common.FilterLandPermanent;
import mage.filter.predicate.mageobject.SubtypePredicate;
import mage.game.permanent.token.TokenImpl;
import mage.game.permanent.token.Token;
import mage.game.permanent.token.custom.CreatureToken;
import java.util.UUID;
@ -57,7 +58,7 @@ public class LivingLands extends CardImpl {
super(ownerId, setInfo, new CardType[]{CardType.ENCHANTMENT}, "{3}{G}");
// All Forests are 1/1 creatures that are still lands.
ContinuousEffect effect = new BecomesCreatureAllEffect(new LivingLandsToken(), "lands", filter, Duration.WhileOnBattlefield);
ContinuousEffect effect = new BecomesCreatureAllEffect(new CreatureToken(1, 1), "lands", filter, Duration.WhileOnBattlefield);
effect.getDependencyTypes().add(DependencyType.BecomeForest);
this.addAbility(new SimpleStaticAbility(Zone.BATTLEFIELD, effect));
}
@ -71,20 +72,3 @@ public class LivingLands extends CardImpl {
return new LivingLands(this);
}
}
class LivingLandsToken extends TokenImpl {
public LivingLandsToken() {
super("", "1/1 creatures");
cardType.add(CardType.CREATURE);
power = new MageInt(1);
toughness = new MageInt(1);
}
public LivingLandsToken(final LivingLandsToken token) {
super(token);
}
public LivingLandsToken copy() {
return new LivingLandsToken(this);
}
}

View file

@ -40,6 +40,7 @@ import mage.constants.Zone;
import mage.filter.StaticFilters;
import mage.game.permanent.token.TokenImpl;
import mage.game.permanent.token.Token;
import mage.game.permanent.token.custom.CreatureToken;
/**
*
@ -52,7 +53,7 @@ public class LivingPlane extends CardImpl {
this.addSuperType(SuperType.WORLD);
// All lands are 1/1 creatures that are still lands.
this.addAbility(new SimpleStaticAbility(Zone.BATTLEFIELD, new BecomesCreatureAllEffect(new LivingPlaneToken(), "lands", StaticFilters.FILTER_LANDS, Duration.WhileOnBattlefield)));
this.addAbility(new SimpleStaticAbility(Zone.BATTLEFIELD, new BecomesCreatureAllEffect(new CreatureToken(1, 1), "lands", StaticFilters.FILTER_LANDS, Duration.WhileOnBattlefield)));
}
public LivingPlane(final LivingPlane card) {
@ -64,20 +65,3 @@ public class LivingPlane extends CardImpl {
return new LivingPlane(this);
}
}
class LivingPlaneToken extends TokenImpl {
public LivingPlaneToken() {
super("Land", "1/1 creatures");
cardType.add(CardType.CREATURE);
power = new MageInt(1);
toughness = new MageInt(1);
}
public LivingPlaneToken(final LivingPlaneToken token) {
super(token);
}
public LivingPlaneToken copy() {
return new LivingPlaneToken(this);
}
}

View file

@ -31,17 +31,17 @@ import java.util.Iterator;
import java.util.UUID;
import mage.MageObjectReference;
import mage.abilities.Ability;
import mage.abilities.common.SimpleStaticAbility;
import mage.abilities.effects.ContinuousEffectImpl;
import mage.abilities.effects.common.continuous.BecomesCreatureAllEffect;
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.*;
import mage.filter.StaticFilters;
import mage.filter.common.FilterLandPermanent;
import mage.game.Game;
import mage.game.permanent.Permanent;
import mage.game.permanent.token.custom.CreatureToken;
/**
*
@ -53,7 +53,7 @@ public class NaturalAffinity extends CardImpl {
super(ownerId,setInfo,new CardType[]{CardType.INSTANT},"{2}{G}");
// All lands become 2/2 creatures until end of turn. They're still lands.
this.getSpellAbility().addEffect(new BecomesCreatureAllEffect());
this.getSpellAbility().addEffect(new BecomesCreatureAllEffect(new CreatureToken(2, 2), "lands", StaticFilters.FILTER_LANDS, Duration.EndOfTurn));
}
public NaturalAffinity(final NaturalAffinity card) {
@ -64,73 +64,4 @@ public class NaturalAffinity extends CardImpl {
public NaturalAffinity copy() {
return new NaturalAffinity(this);
}
}
class BecomesCreatureAllEffect extends ContinuousEffectImpl {
public BecomesCreatureAllEffect() {
super(Duration.EndOfTurn, Outcome.BecomeCreature);
staticText = "All lands become 2/2 creatures until end of turn. They're still lands";
}
public BecomesCreatureAllEffect(final BecomesCreatureAllEffect effect) {
super(effect);
}
@Override
public BecomesCreatureAllEffect copy() {
return new BecomesCreatureAllEffect(this);
}
@Override
public void init(Ability source, Game game) {
super.init(source, game);
this.affectedObjectsSet = true;
for (Permanent perm : game.getBattlefield().getActivePermanents(new FilterLandPermanent(), source.getControllerId(), source.getSourceId(), game)) {
affectedObjectList.add(new MageObjectReference(perm, game));
}
}
@Override
public boolean apply(Layer layer, SubLayer sublayer, Ability source, Game game) {
switch (layer) {
case TypeChangingEffects_4:
if (sublayer == SubLayer.NA) {
for (Iterator<MageObjectReference> it = affectedObjectList.iterator(); it.hasNext();) {
Permanent permanent = it.next().getPermanent(game);
if (permanent != null) {
permanent.addCardType(CardType.CREATURE);
} else {
it.remove();
}
}
}
break;
case PTChangingEffects_7:
if (sublayer == SubLayer.SetPT_7b) {
for (Iterator<MageObjectReference> it = affectedObjectList.iterator(); it.hasNext();) {
Permanent permanent = it.next().getPermanent(game);
if (permanent != null) {
permanent.getPower().setValue(2);
permanent.getToughness().setValue(2);
} else {
it.remove();
}
}
}
}
return true;
}
@Override
public boolean apply(Game game, Ability source) {
return false;
}
@Override
public boolean hasLayer(Layer layer) {
return layer == Layer.PTChangingEffects_7 || layer == Layer.AbilityAddingRemovingEffects_6 || layer == Layer.ColorChangingEffects_5 || layer == Layer.TypeChangingEffects_4;
}
}
}

View file

@ -39,6 +39,7 @@ import mage.constants.Zone;
import mage.filter.common.FilterLandPermanent;
import mage.game.permanent.token.TokenImpl;
import mage.game.permanent.token.Token;
import mage.game.permanent.token.custom.CreatureToken;
/**
*
@ -51,7 +52,7 @@ public class NaturesRevolt extends CardImpl {
super(ownerId, setInfo, new CardType[]{CardType.ENCHANTMENT}, "{3}{G}{G}");
// All lands are 2/2 creatures that are still lands.
this.addAbility(new SimpleStaticAbility(Zone.BATTLEFIELD, new BecomesCreatureAllEffect(new NaturesRevoltToken(),
this.addAbility(new SimpleStaticAbility(Zone.BATTLEFIELD, new BecomesCreatureAllEffect(new CreatureToken(2, 2),
"lands", new FilterLandPermanent(), Duration.WhileOnBattlefield)));
}
@ -63,21 +64,4 @@ public class NaturesRevolt extends CardImpl {
public NaturesRevolt copy() {
return new NaturesRevolt(this);
}
}
class NaturesRevoltToken extends TokenImpl {
public NaturesRevoltToken() {
super("Land", "2/2 creatures");
cardType.add(CardType.CREATURE);
power = new MageInt(2);
toughness = new MageInt(2);
}
public NaturesRevoltToken(final NaturesRevoltToken token) {
super(token);
}
public NaturesRevoltToken copy() {
return new NaturesRevoltToken(this);
}
}
}

View file

@ -40,6 +40,7 @@ import mage.constants.Duration;
import mage.filter.common.FilterControlledLandPermanent;
import mage.game.permanent.token.TokenImpl;
import mage.game.permanent.token.Token;
import mage.game.permanent.token.custom.CreatureToken;
/**
*
@ -57,7 +58,7 @@ public class RudeAwakening extends CardImpl {
this.getSpellAbility().addEffect(new UntapAllLandsControllerEffect());
// or until end of turn, lands you control become 2/2 creatures that are still lands.
Mode mode = new Mode();
mode.getEffects().add(new BecomesCreatureAllEffect(new RudeAwakeningToken(), "lands", new FilterControlledLandPermanent("lands you control"), Duration.EndOfTurn));
mode.getEffects().add(new BecomesCreatureAllEffect(new CreatureToken(2, 2), "lands", new FilterControlledLandPermanent("lands you control"), Duration.EndOfTurn));
this.getSpellAbility().getModes().addMode(mode);
// Entwine {2}{G}
@ -72,22 +73,4 @@ public class RudeAwakening extends CardImpl {
public RudeAwakening copy() {
return new RudeAwakening(this);
}
}
class RudeAwakeningToken extends TokenImpl {
public RudeAwakeningToken() {
super("", "2/2 creatures");
cardType.add(CardType.CREATURE);
power = new MageInt(2);
toughness = new MageInt(2);
}
public RudeAwakeningToken(final RudeAwakeningToken token) {
super(token);
}
public RudeAwakeningToken copy() {
return new RudeAwakeningToken(this);
}
}
}

View file

@ -45,6 +45,7 @@ import mage.constants.Outcome;
import mage.constants.Zone;
import mage.game.permanent.token.TokenImpl;
import mage.game.permanent.token.Token;
import mage.game.permanent.token.custom.CreatureToken;
import mage.target.TargetPermanent;
import mage.target.common.TargetArtifactPermanent;
@ -67,9 +68,8 @@ public class TezzeretsTouch extends CardImpl {
this.addAbility(ability);
// Enchanted artifact is a creature with base power and toughness 5/5 in addition to its other types.
this.addAbility(new SimpleStaticAbility(Zone.BATTLEFIELD,
new BecomesCreatureAttachedEffect(new TezzeretsTouchToken(),
"Enchanted artifact is a creature with base power and toughness 5/5 in addition to its other types", Duration.WhileOnBattlefield)));
this.addAbility(new SimpleStaticAbility(Zone.BATTLEFIELD, new BecomesCreatureAttachedEffect(
new CreatureToken(5, 5, "5/5 creature"),"Enchanted artifact is a creature with base power and toughness 5/5 in addition to its other types", Duration.WhileOnBattlefield)));
// When enchanted artifact is put into a graveyard, return that card to its owner's hand.
this.addAbility(new DiesAttachedTriggeredAbility(new ReturnToHandAttachedEffect(), "enchanted artifact", false, false));
@ -83,21 +83,4 @@ public class TezzeretsTouch extends CardImpl {
public TezzeretsTouch copy() {
return new TezzeretsTouch(this);
}
}
class TezzeretsTouchToken extends TokenImpl {
TezzeretsTouchToken() {
super("", "5/5");
cardType.add(CardType.CREATURE);
power = new MageInt(5);
toughness = new MageInt(5);
}
public TezzeretsTouchToken(final TezzeretsTouchToken token) {
super(token);
}
public TezzeretsTouchToken copy() {
return new TezzeretsTouchToken(this);
}
}

View file

@ -44,6 +44,7 @@ import mage.filter.common.FilterControlledLandPermanent;
import mage.filter.predicate.mageobject.SubtypePredicate;
import mage.game.permanent.token.TokenImpl;
import mage.game.permanent.token.Token;
import mage.game.permanent.token.custom.CreatureToken;
import mage.target.common.TargetControlledCreaturePermanent;
/**
@ -67,7 +68,7 @@ public class TheloniteDruid extends CardImpl {
this.toughness = new MageInt(1);
// {1}{G}, {tap}, Sacrifice a creature: Forests you control become 2/3 creatures until end of turn. They're still lands.
ContinuousEffect effect = new BecomesCreatureAllEffect(new TheloniteDruidLandToken(), "Forests", filter, Duration.EndOfTurn);
ContinuousEffect effect = new BecomesCreatureAllEffect(new CreatureToken(2, 3), "Forests", filter, Duration.EndOfTurn);
effect.getDependencyTypes().add(DependencyType.BecomeForest);
Ability ability = new SimpleActivatedAbility(Zone.BATTLEFIELD,
effect,