[AFR] Implemented Mordenkainen's Polymorph

This commit is contained in:
Evan Kranzler 2021-07-01 18:39:43 -04:00
parent c43aa201f8
commit 9c95aaec60
2 changed files with 85 additions and 0 deletions

View file

@ -0,0 +1,84 @@
package mage.cards.m;
import mage.abilities.Ability;
import mage.abilities.effects.ContinuousEffectImpl;
import mage.abilities.keyword.FlyingAbility;
import mage.cards.CardImpl;
import mage.cards.CardSetInfo;
import mage.constants.*;
import mage.game.Game;
import mage.game.permanent.Permanent;
import mage.target.common.TargetCreaturePermanent;
import java.util.UUID;
/**
* @author TheElk801
*/
public final class MordenkainensPolymorph extends CardImpl {
public MordenkainensPolymorph(UUID ownerId, CardSetInfo setInfo) {
super(ownerId, setInfo, new CardType[]{CardType.INSTANT}, "{1}{U}");
// Until end of turn, target creature becomes a Dragon with base power and toughness 4/4 and gains flying.
this.getSpellAbility().addEffect(new MordenkainensPolymorphEffect());
this.getSpellAbility().addTarget(new TargetCreaturePermanent());
}
private MordenkainensPolymorph(final MordenkainensPolymorph card) {
super(card);
}
@Override
public MordenkainensPolymorph copy() {
return new MordenkainensPolymorph(this);
}
}
class MordenkainensPolymorphEffect extends ContinuousEffectImpl {
MordenkainensPolymorphEffect() {
super(Duration.EndOfTurn, Outcome.Benefit);
staticText = "until end of turn, target creature becomes " +
"a Dragon with base power and toughness 4/4 and gains flying";
}
private MordenkainensPolymorphEffect(final MordenkainensPolymorphEffect effect) {
super(effect);
}
@Override
public MordenkainensPolymorphEffect copy() {
return new MordenkainensPolymorphEffect(this);
}
@Override
public boolean apply(Layer layer, SubLayer sublayer, Ability source, Game game) {
Permanent permanent = game.getPermanent(getTargetPointer().getFirst(game, source));
if (permanent == null) {
discard();
return false;
}
switch (layer) {
case TypeChangingEffects_4:
permanent.removeAllCreatureTypes(game);
permanent.addSubType(game, SubType.DRAGON);
return true;
case AbilityAddingRemovingEffects_6:
permanent.addAbility(FlyingAbility.getInstance(), source.getSourceId(), game);
return true;
case PTChangingEffects_7:
if (sublayer == SubLayer.ModifyPT_7c) {
permanent.getPower().setValue(4);
permanent.getToughness().setValue(4);
return true;
}
}
return false;
}
@Override
public boolean apply(Game game, Ability source) {
return false;
}
}

View file

@ -83,6 +83,7 @@ public final class AdventuresInTheForgottenRealms extends ExpansionSet {
cards.add(new SetCardInfo("Manticore", 113, Rarity.COMMON, mage.cards.m.Manticore.class));
cards.add(new SetCardInfo("Mimic", 249, Rarity.COMMON, mage.cards.m.Mimic.class));
cards.add(new SetCardInfo("Minion of the Mighty", 156, Rarity.RARE, mage.cards.m.MinionOfTheMighty.class));
cards.add(new SetCardInfo("Mordenkainen's Polymorph", 65, Rarity.COMMON, mage.cards.m.MordenkainensPolymorph.class));
cards.add(new SetCardInfo("Mountain", 274, Rarity.LAND, mage.cards.basiclands.Mountain.class, NON_FULL_USE_VARIOUS));
cards.add(new SetCardInfo("Nadaar, Selfless Paladin", 27, Rarity.RARE, mage.cards.n.NadaarSelflessPaladin.class));
cards.add(new SetCardInfo("Plains", 262, Rarity.LAND, mage.cards.basiclands.Plains.class, NON_FULL_USE_VARIOUS));