From 06a280dd1882c4c22d1f6e2914ff442decad4352 Mon Sep 17 00:00:00 2001 From: Noah Gleason Date: Wed, 20 Jun 2018 14:25:24 -0400 Subject: [PATCH 1/3] Implement Mirror Golem --- Mage.Sets/src/mage/cards/m/MirrorGolem.java | 156 ++++++++++++++++++++ Mage.Sets/src/mage/sets/Mirrodin.java | 1 + 2 files changed, 157 insertions(+) create mode 100644 Mage.Sets/src/mage/cards/m/MirrorGolem.java diff --git a/Mage.Sets/src/mage/cards/m/MirrorGolem.java b/Mage.Sets/src/mage/cards/m/MirrorGolem.java new file mode 100644 index 0000000000..df65286c7d --- /dev/null +++ b/Mage.Sets/src/mage/cards/m/MirrorGolem.java @@ -0,0 +1,156 @@ +package mage.cards.m; + +import java.util.UUID; +import mage.MageInt; +import mage.abilities.Ability; +import mage.abilities.common.EntersBattlefieldTriggeredAbility; +import mage.abilities.common.SimpleStaticAbility; +import mage.abilities.effects.ContinuousEffectImpl; +import mage.abilities.effects.OneShotEffect; +import mage.abilities.keyword.ProtectionAbility; +import mage.cards.Card; +import mage.constants.*; +import mage.cards.CardImpl; +import mage.cards.CardSetInfo; +import mage.filter.FilterCard; +import mage.filter.common.FilterCreatureCard; +import mage.filter.predicate.mageobject.CardTypePredicate; +import mage.game.Game; +import mage.game.permanent.Permanent; +import mage.players.Player; +import mage.target.common.TargetCardInGraveyard; +import mage.util.CardUtil; + +/** + * + * @author noahg + */ +public final class MirrorGolem extends CardImpl { + + public MirrorGolem(UUID ownerId, CardSetInfo setInfo) { + super(ownerId, setInfo, new CardType[]{CardType.ARTIFACT, CardType.CREATURE}, "{6}"); + + this.subtype.add(SubType.GOLEM); + this.power = new MageInt(3); + this.toughness = new MageInt(4); + + // Imprint - When Mirror Golem enters the battlefield, you may exile target card from a graveyard. + Ability ability = new EntersBattlefieldTriggeredAbility(new MirrorGolemImprintEffect(), true, "Imprint — "); + ability.addTarget(new TargetCardInGraveyard()); + this.addAbility(ability); + + // Mirror Golem has protection from each of the exiled card's card types. + this.addAbility(new SimpleStaticAbility(Zone.BATTLEFIELD, new MirrorGolemEffect())); + } + + public MirrorGolem(final MirrorGolem card) { + super(card); + } + + @Override + public MirrorGolem copy() { + return new MirrorGolem(this); + } +} + +class MirrorGolemImprintEffect extends OneShotEffect { + + MirrorGolemImprintEffect() { + super(Outcome.Exile); + this.staticText = "you may exile target card from a graveyard"; + } + + MirrorGolemImprintEffect(final MirrorGolemImprintEffect effect) { + super(effect); + } + + @Override + public MirrorGolemImprintEffect copy() { + return new MirrorGolemImprintEffect(this); + } + + @Override + public boolean apply(Game game, Ability source) { + Player controller = game.getPlayer(source.getControllerId()); + if (controller != null) { + Permanent sourcePermanent = game.getPermanent(source.getSourceId()); + Card card = game.getCard(this.getTargetPointer().getFirst(game, source)); + if (card != null) { + controller.moveCardsToExile(card, source, game, true, CardUtil.getExileZoneId(game, source.getSourceId(), source.getSourceObjectZoneChangeCounter()), source.getSourceObject(game).getIdName()); + if (sourcePermanent != null) { + sourcePermanent.imprint(this.getTargetPointer().getFirst(game, source), game); + } + } + return true; + } + return false; + } +} + +class MirrorGolemEffect extends ContinuousEffectImpl { + + public MirrorGolemEffect() { + super(Duration.WhileOnBattlefield, Layer.AbilityAddingRemovingEffects_6, SubLayer.NA, Outcome.AddAbility); + this.addDependedToType(DependencyType.AddingAbility); + staticText = "{this} has protection from each of the exiled card's card types."; + } + + public MirrorGolemEffect(final MirrorGolemEffect effect) { + super(effect); + } + + @Override + public boolean apply(Game game, Ability source) { + Permanent sourceObject = game.getPermanent(source.getSourceId()); + + if (sourceObject == null || sourceObject.getImprinted() == null) { + return false; + } + + for (UUID imprinted : sourceObject.getImprinted()){ + if (imprinted != null){ + Card card = game.getCard(imprinted); + if (card != null) { + for (CardType cardType : card.getCardType()){ + FilterCard filterCard; + if (cardType.equals(CardType.SORCERY)){ + filterCard = new FilterCard("sorceries"); + } else if (cardType.equals(CardType.TRIBAL)){ + filterCard = new FilterCard("tribal"); + } else { + filterCard = new FilterCard(cardType.toString()+"s"); + } + filterCard.add(new CardTypePredicate(cardType)); + sourceObject.addAbility(new ProtectionAbility(filterCard)); + } + } + } + } + +// for (UUID playerId : game.getState().getPlayersInRange(source.getControllerId(), game)) { +// Player player = game.getPlayer(playerId); +// if (player != null) { +// UUID exileId = CardUtil.getExileZoneId(game, source.getSourceId(), sourceObject.getZoneChangeCounter(game)); +// if (exileId != null) { +// for (UUID cardId : game.getState().getExile().getExileZone(exileId)) { +// Card card = game.getCard(cardId); +// if (card != null) { +// for (CardType cardType : card.getCardType()){ +// FilterCard filterCard = new FilterCard(); +// filterCard.add(new CardTypePredicate(cardType)); +// sourceObject.addAbility(new ProtectionAbility(filterCard)); +// } +// } +// } +// } +// } +// } + + return true; + } + + @Override + public MirrorGolemEffect copy() { + return new MirrorGolemEffect(this); + } +} \ No newline at end of file diff --git a/Mage.Sets/src/mage/sets/Mirrodin.java b/Mage.Sets/src/mage/sets/Mirrodin.java index a494c80176..a32f95c35b 100644 --- a/Mage.Sets/src/mage/sets/Mirrodin.java +++ b/Mage.Sets/src/mage/sets/Mirrodin.java @@ -169,6 +169,7 @@ public final class Mirrodin extends ExpansionSet { cards.add(new SetCardInfo("Mind's Eye", 205, Rarity.RARE, mage.cards.m.MindsEye.class)); cards.add(new SetCardInfo("Mindslaver", 206, Rarity.RARE, mage.cards.m.Mindslaver.class)); cards.add(new SetCardInfo("Mindstorm Crown", 207, Rarity.UNCOMMON, mage.cards.m.MindstormCrown.class)); + cards.add(new SetCardInfo("Mirror Golem", 208, Rarity.UNCOMMON, mage.cards.m.MirrorGolem.class)); cards.add(new SetCardInfo("Molder Slug", 125, Rarity.RARE, mage.cards.m.MolderSlug.class)); cards.add(new SetCardInfo("Molten Rain", 101, Rarity.COMMON, mage.cards.m.MoltenRain.class)); cards.add(new SetCardInfo("Moriok Scavenger", 68, Rarity.COMMON, mage.cards.m.MoriokScavenger.class)); From ec8a25f2e1bb86a0465684428ba3e1bd975c4c77 Mon Sep 17 00:00:00 2001 From: Noah Gleason Date: Wed, 20 Jun 2018 23:03:46 -0400 Subject: [PATCH 2/3] Fix Riftsweeper issue --- Mage.Sets/src/mage/cards/m/MirrorGolem.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/Mage.Sets/src/mage/cards/m/MirrorGolem.java b/Mage.Sets/src/mage/cards/m/MirrorGolem.java index df65286c7d..f5f9349ef9 100644 --- a/Mage.Sets/src/mage/cards/m/MirrorGolem.java +++ b/Mage.Sets/src/mage/cards/m/MirrorGolem.java @@ -15,6 +15,7 @@ import mage.cards.CardSetInfo; import mage.filter.FilterCard; import mage.filter.common.FilterCreatureCard; import mage.filter.predicate.mageobject.CardTypePredicate; +import mage.game.ExileZone; import mage.game.Game; import mage.game.permanent.Permanent; import mage.players.Player; @@ -102,13 +103,14 @@ class MirrorGolemEffect extends ContinuousEffectImpl { @Override public boolean apply(Game game, Ability source) { Permanent sourceObject = game.getPermanent(source.getSourceId()); + ExileZone exileZone = game.getExile().getExileZone(CardUtil.getCardExileZoneId(game, source.getSourceId())); if (sourceObject == null || sourceObject.getImprinted() == null) { return false; } for (UUID imprinted : sourceObject.getImprinted()){ - if (imprinted != null){ + if (imprinted != null && exileZone.contains(imprinted)){ Card card = game.getCard(imprinted); if (card != null) { for (CardType cardType : card.getCardType()){ From defed69b70ca3759c880317f688dc2e38aa216f3 Mon Sep 17 00:00:00 2001 From: Noah Gleason Date: Wed, 20 Jun 2018 23:09:28 -0400 Subject: [PATCH 3/3] Remove commented code --- Mage.Sets/src/mage/cards/m/MirrorGolem.java | 20 -------------------- 1 file changed, 20 deletions(-) diff --git a/Mage.Sets/src/mage/cards/m/MirrorGolem.java b/Mage.Sets/src/mage/cards/m/MirrorGolem.java index f5f9349ef9..96aa5fb00e 100644 --- a/Mage.Sets/src/mage/cards/m/MirrorGolem.java +++ b/Mage.Sets/src/mage/cards/m/MirrorGolem.java @@ -128,26 +128,6 @@ class MirrorGolemEffect extends ContinuousEffectImpl { } } } - -// for (UUID playerId : game.getState().getPlayersInRange(source.getControllerId(), game)) { -// Player player = game.getPlayer(playerId); -// if (player != null) { -// UUID exileId = CardUtil.getExileZoneId(game, source.getSourceId(), sourceObject.getZoneChangeCounter(game)); -// if (exileId != null) { -// for (UUID cardId : game.getState().getExile().getExileZone(exileId)) { -// Card card = game.getCard(cardId); -// if (card != null) { -// for (CardType cardType : card.getCardType()){ -// FilterCard filterCard = new FilterCard(); -// filterCard.add(new CardTypePredicate(cardType)); -// sourceObject.addAbility(new ProtectionAbility(filterCard)); -// } -// } -// } -// } -// } -// } - return true; }