diff --git a/Mage.Sets/src/mage/cards/x/XenicPoltergeist.java b/Mage.Sets/src/mage/cards/x/XenicPoltergeist.java index 2568dac419b..a2d7ed67f77 100644 --- a/Mage.Sets/src/mage/cards/x/XenicPoltergeist.java +++ b/Mage.Sets/src/mage/cards/x/XenicPoltergeist.java @@ -56,24 +56,22 @@ import mage.target.common.TargetArtifactPermanent; public class XenicPoltergeist extends CardImpl { private static final FilterArtifactPermanent filter = new FilterArtifactPermanent(); + static { filter.add(Predicates.not(new CardTypePredicate(CardType.CREATURE))); } - + public XenicPoltergeist(UUID ownerId, CardSetInfo setInfo) { - super(ownerId,setInfo,new CardType[]{CardType.CREATURE},"{1}{B}{B}"); + super(ownerId, setInfo, new CardType[]{CardType.CREATURE}, "{1}{B}{B}"); this.subtype.add("Spirit"); this.power = new MageInt(1); this.toughness = new MageInt(1); // {tap}: Until your next upkeep, target noncreature artifact becomes an artifact creature with power and toughness each equal to its converted mana cost. - XenicPoltergeistEffect effect = new XenicPoltergeistEffect(Duration.Custom); - effect.setDurationToPhase(PhaseStep.UPKEEP); - - Ability ability = new SimpleActivatedAbility(Zone.BATTLEFIELD, effect, new TapSourceCost()); + Ability ability = new SimpleActivatedAbility(Zone.BATTLEFIELD, new XenicPoltergeistEffect(), new TapSourceCost()); ability.addTarget(new TargetArtifactPermanent(filter)); this.addAbility(ability); - + } public XenicPoltergeist(final XenicPoltergeist card) { @@ -85,19 +83,18 @@ public class XenicPoltergeist extends CardImpl { return new XenicPoltergeist(this); } } + class XenicPoltergeistEffect extends ContinuousEffectImpl { - private PhaseStep durationPhaseStep = null; - private UUID durationPlayerId; - private boolean sameStep; - private static final FilterArtifactPermanent filter = new FilterArtifactPermanent(); + static { filter.add(Predicates.not(new CardTypePredicate(CardType.CREATURE))); } - public XenicPoltergeistEffect(Duration duration) { - super(duration, Outcome.BecomeCreature); - staticText = "Each noncreature artifact loses its abilities and is an artifact creature with power and toughness each equal to its converted mana cost"; + + public XenicPoltergeistEffect() { + super(Duration.Custom, Outcome.BecomeCreature); + staticText = "Until your next upkeep, target noncreature artifact becomes an artifact creature with power and toughness each equal to its converted mana cost"; } public XenicPoltergeistEffect(final XenicPoltergeistEffect effect) { @@ -108,35 +105,17 @@ class XenicPoltergeistEffect extends ContinuousEffectImpl { public XenicPoltergeistEffect copy() { return new XenicPoltergeistEffect(this); } - - public void setDurationToPhase(PhaseStep phaseStep) { - durationPhaseStep = phaseStep; - } - @Override - public void init(Ability source, Game game) { - super.init(source, game); - if (durationPhaseStep != null) { - durationPlayerId = source.getControllerId(); - sameStep = true; - } - } - @Override public boolean isInactive(Ability source, Game game) { - if (super.isInactive(source, game)) { - return true; - } - if (durationPhaseStep != null && durationPhaseStep == game.getPhase().getStep().getType()) { - if (!sameStep && game.getActivePlayerId().equals(durationPlayerId) || game.getPlayer(durationPlayerId).hasReachedNextTurnAfterLeaving()) { + if (game.getPhase().getStep().getType() == PhaseStep.UPKEEP) { + if (game.getActivePlayerId().equals(source.getControllerId())) { return true; } - } else { - sameStep = false; } return false; } - + @Override public boolean apply(Layer layer, SubLayer sublayer, Ability source, Game game) { switch (layer) { @@ -144,22 +123,22 @@ class XenicPoltergeistEffect extends ContinuousEffectImpl { if (sublayer == SubLayer.NA) { UUID permanentId = targetPointer.getFirst(game, source); Permanent permanent = game.getPermanentOrLKIBattlefield(permanentId); - if(permanent != null){ + if (permanent != null) { permanent.addCardType(CardType.CREATURE); - } + } } break; - + case PTChangingEffects_7: if (sublayer == SubLayer.SetPT_7b) { UUID permanentId = targetPointer.getFirst(game, source); Permanent permanent = game.getPermanentOrLKIBattlefield(permanentId); - if (permanent != null){ + if (permanent != null) { int manaCost = permanent.getConvertedManaCost(); permanent.getPower().setValue(manaCost); permanent.getToughness().setValue(manaCost); } - } + } } return true; } @@ -169,10 +148,10 @@ class XenicPoltergeistEffect extends ContinuousEffectImpl { return false; } - @Override public boolean hasLayer(Layer layer) { - return layer == Layer.PTChangingEffects_7 || layer == Layer.TypeChangingEffects_4; + return layer == Layer.PTChangingEffects_7 + || layer == Layer.TypeChangingEffects_4; } }