From 2d70e86e017d03decc495002e71dc7e85c6a21ac Mon Sep 17 00:00:00 2001 From: LevelX2 Date: Tue, 11 Oct 2016 17:18:08 +0200 Subject: [PATCH] Some minor cleanup. --- .../src/mage/cards/p/PrototypePortal.java | 45 +++++++++---------- .../main/java/mage/filter/StaticFilters.java | 4 +- 2 files changed, 25 insertions(+), 24 deletions(-) diff --git a/Mage.Sets/src/mage/cards/p/PrototypePortal.java b/Mage.Sets/src/mage/cards/p/PrototypePortal.java index 568631d2535..f01c31aac84 100644 --- a/Mage.Sets/src/mage/cards/p/PrototypePortal.java +++ b/Mage.Sets/src/mage/cards/p/PrototypePortal.java @@ -28,9 +28,7 @@ package mage.cards.p; import java.util.UUID; -import mage.constants.CardType; -import mage.constants.Outcome; -import mage.constants.Zone; +import mage.MageObject; import mage.abilities.Ability; import mage.abilities.common.EntersBattlefieldTriggeredAbility; import mage.abilities.common.SimpleActivatedAbility; @@ -43,23 +41,24 @@ import mage.abilities.effects.OneShotEffect; import mage.cards.Card; import mage.cards.CardImpl; import mage.cards.CardSetInfo; -import mage.filter.FilterCard; -import mage.filter.common.FilterArtifactCard; +import mage.constants.CardType; +import mage.constants.Outcome; +import mage.constants.Zone; +import mage.filter.StaticFilters; import mage.game.Game; import mage.game.permanent.Permanent; -import mage.players.Player; import mage.game.permanent.token.EmptyToken; +import mage.players.Player; import mage.target.TargetCard; import mage.util.CardUtil; - /** * @author nantuko */ public class PrototypePortal extends CardImpl { public PrototypePortal(UUID ownerId, CardSetInfo setInfo) { - super(ownerId,setInfo,new CardType[]{CardType.ARTIFACT},"{4}"); + super(ownerId, setInfo, new CardType[]{CardType.ARTIFACT}, "{4}"); // Imprint - When Prototype Portal enters the battlefield, you may exile an artifact card from your hand. this.addAbility(new EntersBattlefieldTriggeredAbility(new PrototypePortalEffect(), true)); @@ -102,8 +101,6 @@ public class PrototypePortal extends CardImpl { class PrototypePortalEffect extends OneShotEffect { - private static final FilterCard filter = new FilterArtifactCard(); - public PrototypePortalEffect() { super(Outcome.Benefit); staticText = "exile an artifact card from your hand"; @@ -115,21 +112,24 @@ class PrototypePortalEffect extends OneShotEffect { @Override public boolean apply(Game game, Ability source) { - Player player = game.getPlayer(source.getControllerId()); - if (player.getHand().size() > 0) { - TargetCard target = new TargetCard(Zone.HAND, filter); - player.choose(Outcome.Benefit, player.getHand(), target, game); - Card card = player.getHand().get(target.getFirstTarget(), game); - if (card != null) { - card.moveToExile(getId(), "Prototype Portal (Imprint)", source.getSourceId(), game); - Permanent permanent = game.getPermanent(source.getSourceId()); - if (permanent != null) { - permanent.imprint(card.getId(), game); + Player controller = game.getPlayer(source.getControllerId()); + MageObject sourceObject = game.getObject(source.getSourceId()); + if (controller != null && sourceObject != null) { + if (controller.getHand().size() > 0) { + TargetCard target = new TargetCard(Zone.HAND, StaticFilters.FILTER_CARD_ARTIFACT); + controller.choose(Outcome.Benefit, controller.getHand(), target, game); + Card card = controller.getHand().get(target.getFirstTarget(), game); + if (card != null) { + controller.moveCardsToExile(card, source, game, true, source.getSourceId(), sourceObject.getIdName() + " (Imprint)"); + Permanent permanent = game.getPermanent(source.getSourceId()); + if (permanent != null) { + permanent.imprint(card.getId(), game); + } } - return true; } + return true; } - return true; + return false; } @Override @@ -176,4 +176,3 @@ class PrototypePortalCreateTokenEffect extends OneShotEffect { } } - diff --git a/Mage/src/main/java/mage/filter/StaticFilters.java b/Mage/src/main/java/mage/filter/StaticFilters.java index 6a1d00ac0d1..74e93934b45 100644 --- a/Mage/src/main/java/mage/filter/StaticFilters.java +++ b/Mage/src/main/java/mage/filter/StaticFilters.java @@ -6,6 +6,7 @@ package mage.filter; import mage.constants.CardType; +import mage.filter.common.FilterArtifactCard; import mage.filter.common.FilterArtifactCreaturePermanent; import mage.filter.common.FilterControlledArtifactPermanent; import mage.filter.common.FilterControlledPermanent; @@ -18,11 +19,12 @@ import mage.filter.predicate.mageobject.CardTypePredicate; */ public class StaticFilters { + public static final FilterArtifactCreaturePermanent FILTER_ARTIFACT_CREATURE_PERMANENT = new FilterArtifactCreaturePermanent(); public static final FilterPermanent FILTER_PERMANENT_ARTIFACT_OR_CREATURE = new FilterPermanent("artifact or creature"); public static final FilterControlledPermanent FILTER_CONTROLLED_PERMANENT_ARTIFACT_OR_CREATURE = new FilterControlledPermanent("artifact or creature you control"); public static final FilterControlledPermanent FILTER_CONTROLLED_PERMANENT_ARTIFACT = new FilterControlledArtifactPermanent(); + public static final FilterArtifactCard FILTER_CARD_ARTIFACT = new FilterArtifactCard(); public static final FilterCard FILTER_CARD_ARTIFACT_OR_CREATURE = new FilterCard("artifact or creature card"); - public static final FilterArtifactCreaturePermanent FILTER_ARTIFACT_CREATURE_PERMANENT = new FilterArtifactCreaturePermanent(); static { FILTER_PERMANENT_ARTIFACT_OR_CREATURE.add(Predicates.or(