diff --git a/Mage.Sets/src/mage/cards/m/Mordenkainen.java b/Mage.Sets/src/mage/cards/m/Mordenkainen.java new file mode 100644 index 00000000000..e55f74548f2 --- /dev/null +++ b/Mage.Sets/src/mage/cards/m/Mordenkainen.java @@ -0,0 +1,117 @@ +package mage.cards.m; + +import java.util.UUID; + +import mage.abilities.Ability; +import mage.abilities.LoyaltyAbility; +import mage.abilities.common.PlaneswalkerEntersWithLoyaltyCountersAbility; +import mage.abilities.effects.OneShotEffect; +import mage.abilities.effects.common.CreateTokenEffect; +import mage.abilities.effects.common.GetEmblemEffect; +import mage.cards.*; +import mage.constants.*; +import mage.game.Game; +import mage.game.command.emblems.MordenkainenEmblem; +import mage.game.permanent.token.DogIllusionToken; +import mage.players.Player; +import mage.target.common.TargetCardInHand; + +/** + * + * @author weirddan455 + */ +public final class Mordenkainen extends CardImpl { + + public Mordenkainen(UUID ownerId, CardSetInfo setInfo) { + super(ownerId, setInfo, new CardType[]{CardType.PLANESWALKER}, "{4}{U}{U}"); + + this.addSuperType(SuperType.LEGENDARY); + this.subtype.add(SubType.MORDENKAINEN); + this.addAbility(new PlaneswalkerEntersWithLoyaltyCountersAbility(5)); + + // +2: Draw two cards, then put a card from your hand on the bottom of your library. + this.addAbility(new LoyaltyAbility(new MordenkainenDrawEffect(), 2)); + + // −2: Create a blue Dog Illusion creature token with "This creature's power and toughness are each equal to twice the number of cards in your hand." + this.addAbility(new LoyaltyAbility(new CreateTokenEffect(new DogIllusionToken()), -2)); + + // −10: Exchange your hand and library, then shuffle. You get an emblem with "You have no maximum hand size." + Ability ability = new LoyaltyAbility(new MordenkainenExchangeEffect(), -10); + ability.addEffect(new GetEmblemEffect(new MordenkainenEmblem())); + this.addAbility(ability); + } + + private Mordenkainen(final Mordenkainen card) { + super(card); + } + + @Override + public Mordenkainen copy() { + return new Mordenkainen(this); + } +} + +class MordenkainenDrawEffect extends OneShotEffect { + + public MordenkainenDrawEffect() { + super(Outcome.DrawCard); + this.staticText = "Draw two cards, then put a card from your hand on the bottom of your library"; + } + + private MordenkainenDrawEffect(final MordenkainenDrawEffect effect) { + super(effect); + } + + @Override + public MordenkainenDrawEffect copy() { + return new MordenkainenDrawEffect(this); + } + + @Override + public boolean apply(Game game, Ability source) { + Player controller = game.getPlayer(source.getControllerId()); + if (controller == null) { + return false; + } + controller.drawCards(2, source, game); + TargetCardInHand target = new TargetCardInHand(); + if (controller.chooseTarget(Outcome.Discard, target, source, game)) { + Card card = game.getCard(target.getFirstTarget()); + if (card != null) { + controller.moveCardToLibraryWithInfo(card, source, game, Zone.HAND, false, false); + } + } + return true; + } +} + +class MordenkainenExchangeEffect extends OneShotEffect { + + public MordenkainenExchangeEffect() { + super(Outcome.Benefit); + this.staticText = "Exchange your hand and library, then shuffle"; + } + + private MordenkainenExchangeEffect(final MordenkainenExchangeEffect effect) { + super(effect); + } + + @Override + public MordenkainenExchangeEffect copy() { + return new MordenkainenExchangeEffect(this); + } + + @Override + public boolean apply(Game game, Ability source) { + Player controller = game.getPlayer(source.getControllerId()); + if (controller == null) { + return false; + } + Cards hand = new CardsImpl(controller.getHand()); + Cards library = new CardsImpl(controller.getLibrary().getCardList()); + controller.putCardsOnTopOfLibrary(hand, game, source, false); + controller.moveCards(library, Zone.HAND, source, game); + controller.shuffleLibrary(source, game); + return true; + } +} diff --git a/Mage.Sets/src/mage/sets/AdventuresInTheForgottenRealms.java b/Mage.Sets/src/mage/sets/AdventuresInTheForgottenRealms.java index ed5224ea3d6..66319f3bce6 100644 --- a/Mage.Sets/src/mage/sets/AdventuresInTheForgottenRealms.java +++ b/Mage.Sets/src/mage/sets/AdventuresInTheForgottenRealms.java @@ -156,6 +156,7 @@ public final class AdventuresInTheForgottenRealms extends ExpansionSet { cards.add(new SetCardInfo("Minsc, Beloved Ranger", 227, Rarity.MYTHIC, mage.cards.m.MinscBelovedRanger.class)); cards.add(new SetCardInfo("Monk of the Open Hand", 25, Rarity.UNCOMMON, mage.cards.m.MonkOfTheOpenHand.class)); cards.add(new SetCardInfo("Moon-Blessed Cleric", 26, Rarity.UNCOMMON, mage.cards.m.MoonBlessedCleric.class)); + cards.add(new SetCardInfo("Mordenkainen", 64, Rarity.MYTHIC, mage.cards.m.Mordenkainen.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)); diff --git a/Mage/src/main/java/mage/constants/SubType.java b/Mage/src/main/java/mage/constants/SubType.java index 5b2cc8833e8..90d22d437af 100644 --- a/Mage/src/main/java/mage/constants/SubType.java +++ b/Mage/src/main/java/mage/constants/SubType.java @@ -432,6 +432,7 @@ public enum SubType { LILIANA("Liliana", SubTypeSet.PlaneswalkerType), LUKKA("Lukka", SubTypeSet.PlaneswalkerType), LOLTH("Lolth", SubTypeSet.PlaneswalkerType), + MORDENKAINEN("Mordenkainen", SubTypeSet.PlaneswalkerType), NAHIRI("Nahiri", SubTypeSet.PlaneswalkerType), NARSET("Narset", SubTypeSet.PlaneswalkerType), NIKO("Niko", SubTypeSet.PlaneswalkerType), diff --git a/Mage/src/main/java/mage/game/command/emblems/MordenkainenEmblem.java b/Mage/src/main/java/mage/game/command/emblems/MordenkainenEmblem.java new file mode 100644 index 00000000000..34bcf85d58f --- /dev/null +++ b/Mage/src/main/java/mage/game/command/emblems/MordenkainenEmblem.java @@ -0,0 +1,22 @@ +package mage.game.command.emblems; + +import mage.abilities.common.SimpleStaticAbility; +import mage.abilities.effects.common.continuous.MaximumHandSizeControllerEffect; +import mage.constants.Duration; +import mage.constants.Zone; +import mage.game.command.Emblem; + +/** + * + * @author weirddan455 + */ +public final class MordenkainenEmblem extends Emblem { + + // You get an emblem with "You have no maximum hand size." + public MordenkainenEmblem() { + this.setName("Emblem Mordenkainen"); + this.getAbilities().add(new SimpleStaticAbility(Zone.COMMAND, new MaximumHandSizeControllerEffect( + Integer.MAX_VALUE, Duration.WhileOnBattlefield, MaximumHandSizeControllerEffect.HandSizeModification.SET + ))); + } +} diff --git a/Mage/src/main/java/mage/game/permanent/token/DogIllusionToken.java b/Mage/src/main/java/mage/game/permanent/token/DogIllusionToken.java new file mode 100644 index 00000000000..8bbb5f561af --- /dev/null +++ b/Mage/src/main/java/mage/game/permanent/token/DogIllusionToken.java @@ -0,0 +1,67 @@ +package mage.game.permanent.token; + +import mage.MageInt; +import mage.abilities.Ability; +import mage.abilities.common.SimpleStaticAbility; +import mage.abilities.dynamicvalue.DynamicValue; +import mage.abilities.effects.Effect; +import mage.abilities.effects.common.continuous.SetPowerToughnessSourceEffect; +import mage.constants.CardType; +import mage.constants.Duration; +import mage.constants.SubType; +import mage.constants.Zone; +import mage.game.Game; +import mage.players.Player; + +/** + * + * @author weirddan455 + */ +public final class DogIllusionToken extends TokenImpl { + + public DogIllusionToken() { + super("Dog Illusion", "blue Dog Illusion creature token with \"This creature's power and toughness are each equal to twice the number of cards in your hand.\""); + cardType.add(CardType.CREATURE); + color.setBlue(true); + subtype.add(SubType.DOG); + subtype.add(SubType.ILLUSION); + power = new MageInt(0); + toughness = new MageInt(0); + addAbility(new SimpleStaticAbility(Zone.ALL, new SetPowerToughnessSourceEffect( + DogIllusionValue.instance, Duration.EndOfGame) + .setText("{this}'s power and toughness are each equal to twice the number of cards in your hand") + )); + } + + private DogIllusionToken(final DogIllusionToken token) { + super(token); + } + + @Override + public DogIllusionToken copy() { + return new DogIllusionToken(this); + } +} + +enum DogIllusionValue implements DynamicValue { + instance; + + @Override + public int calculate(Game game, Ability sourceAbility, Effect effect) { + Player controller = game.getPlayer(sourceAbility.getControllerId()); + if (controller == null) { + return 0; + } + return controller.getHand().size() * 2; + } + + @Override + public DogIllusionValue copy() { + return instance; + } + + @Override + public String getMessage() { + return "twice the number of cards in your hand"; + } +}