diff --git a/Mage.Sets/src/mage/cards/d/DackFayden.java b/Mage.Sets/src/mage/cards/d/DackFayden.java index b140eff403..7a83a7618e 100644 --- a/Mage.Sets/src/mage/cards/d/DackFayden.java +++ b/Mage.Sets/src/mage/cards/d/DackFayden.java @@ -27,12 +27,8 @@ */ package mage.cards.d; -import mage.abilities.Ability; import mage.abilities.LoyaltyAbility; -import mage.abilities.SpellAbility; -import mage.abilities.TriggeredAbilityImpl; import mage.abilities.common.PlanswalkerEntersWithLoyalityCountersAbility; -import mage.abilities.effects.ContinuousEffectImpl; import mage.abilities.effects.Effect; import mage.abilities.effects.common.DrawCardTargetEffect; import mage.abilities.effects.common.GetEmblemEffect; @@ -41,20 +37,9 @@ import mage.abilities.effects.common.discard.DiscardTargetEffect; import mage.cards.CardImpl; import mage.cards.CardSetInfo; import mage.constants.*; -import mage.game.Game; -import mage.game.command.Emblem; -import mage.game.events.GameEvent; -import mage.game.events.GameEvent.EventType; -import mage.game.permanent.Permanent; -import mage.game.stack.Spell; -import mage.players.Player; -import mage.target.Target; +import mage.game.command.emblems.DackFaydenEmblem; import mage.target.TargetPlayer; import mage.target.common.TargetArtifactPermanent; -import mage.target.targetpointer.FixedTargets; - -import java.util.ArrayList; -import java.util.List; import java.util.UUID; /** @@ -100,120 +85,3 @@ public class DackFayden extends CardImpl { return new DackFayden(this); } } - -class DackFaydenEmblem extends Emblem { - - DackFaydenEmblem() { - this.setName("Emblem Dack"); - this.getAbilities().add(new DackFaydenEmblemTriggeredAbility()); - } -} - -class DackFaydenEmblemTriggeredAbility extends TriggeredAbilityImpl { - - DackFaydenEmblemTriggeredAbility() { - super(Zone.COMMAND, new DackFaydenEmblemEffect(), false); - } - - DackFaydenEmblemTriggeredAbility(final DackFaydenEmblemTriggeredAbility ability) { - super(ability); - } - - @Override - public DackFaydenEmblemTriggeredAbility copy() { - return new DackFaydenEmblemTriggeredAbility(this); - } - - @Override - public boolean checkEventType(GameEvent event, Game game) { - return event.getType() == EventType.SPELL_CAST; - } - - @Override - public boolean checkTrigger(GameEvent event, Game game) { - boolean returnValue = false; - List targetedPermanentIds = new ArrayList<>(0); - Player player = game.getPlayer(this.getControllerId()); - if (player != null) { - if (event.getPlayerId().equals(this.getControllerId())) { - Spell spell = game.getStack().getSpell(event.getTargetId()); - if (spell != null) { - SpellAbility spellAbility = spell.getSpellAbility(); - for (Target target : spellAbility.getTargets()) { - if (!target.isNotTarget()) { - for (UUID targetId : target.getTargets()) { - if (game.getBattlefield().containsPermanent(targetId)) { - returnValue = true; - targetedPermanentIds.add(targetId); - } - } - } - } - for (Effect effect : spellAbility.getEffects()) { - for (UUID targetId : effect.getTargetPointer().getTargets(game, spellAbility)) { - if (game.getBattlefield().containsPermanent(targetId)) { - returnValue = true; - targetedPermanentIds.add(targetId); - } - } - } - } - } - } - for (Effect effect : this.getEffects()) { - if (effect instanceof DackFaydenEmblemEffect) { - DackFaydenEmblemEffect dackEffect = (DackFaydenEmblemEffect) effect; - List permanents = new ArrayList<>(); - for(UUID permanentId : targetedPermanentIds) { - Permanent permanent = game.getPermanent(permanentId); - if(permanent != null) { - permanents.add(permanent); - } - } - - dackEffect.setTargets(permanents, game); - } - } - return returnValue; - } - - @Override - public String getRule() { - return "Whenever you cast a spell that targets one or more permanents, gain control of those permanents."; - } -} - -class DackFaydenEmblemEffect extends ContinuousEffectImpl { - - protected FixedTargets fixedTargets; - - DackFaydenEmblemEffect() { - super(Duration.EndOfGame, Layer.ControlChangingEffects_2, SubLayer.NA, Outcome.GainControl); - this.staticText = "gain control of those permanents"; - } - - DackFaydenEmblemEffect(final DackFaydenEmblemEffect effect) { - super(effect); - this.fixedTargets = effect.fixedTargets; - } - - @Override - public DackFaydenEmblemEffect copy() { - return new DackFaydenEmblemEffect(this); - } - - @Override - public boolean apply(Game game, Ability source) { - for (UUID permanentId : fixedTargets.getTargets(game, source)) { - Permanent permanent = game.getPermanent(permanentId); - if (permanent != null) { - permanent.changeControllerId(source.getControllerId(), game); - } - } - return true; - } - - public void setTargets(List targetedPermanents, Game game) { - this.fixedTargets = new FixedTargets(targetedPermanents, game); - } -} diff --git a/Mage.Sets/src/mage/cards/g/GideonOfTheTrials.java b/Mage.Sets/src/mage/cards/g/GideonOfTheTrials.java index 84bb2d89bf..166b9f92d7 100644 --- a/Mage.Sets/src/mage/cards/g/GideonOfTheTrials.java +++ b/Mage.Sets/src/mage/cards/g/GideonOfTheTrials.java @@ -28,12 +28,11 @@ package mage.cards.g; import java.util.UUID; - import mage.MageInt; + import mage.abilities.Ability; import mage.abilities.LoyaltyAbility; import mage.abilities.common.PlanswalkerEntersWithLoyalityCountersAbility; -import mage.abilities.common.SimpleStaticAbility; import mage.abilities.effects.ContinuousRuleModifyingEffectImpl; import mage.abilities.effects.Effect; import mage.abilities.effects.common.GetEmblemEffect; @@ -47,8 +46,8 @@ import mage.constants.*; import mage.filter.common.FilterPlaneswalkerPermanent; import mage.filter.predicate.mageobject.SubtypePredicate; import mage.game.Game; -import mage.game.command.Emblem; import mage.game.events.GameEvent; +import mage.game.command.emblems.GideonOfTheTrialsEmblem; import mage.game.permanent.token.Token; import mage.target.TargetPermanent; @@ -119,8 +118,8 @@ class GideonOfTheTrialsCantLoseEffect extends ContinuousRuleModifyingEffectImpl @Override public boolean applies(GameEvent event, Ability source, Game game) { - if ((event.getType() == GameEvent.EventType.WINS && game.getOpponents(source.getControllerId()).contains(event.getPlayerId())) || - (event.getType() == GameEvent.EventType.LOSES && event.getPlayerId().equals(source.getControllerId()))) { + if ((event.getType() == GameEvent.EventType.WINS && game.getOpponents(source.getControllerId()).contains(event.getPlayerId())) + || (event.getType() == GameEvent.EventType.LOSES && event.getPlayerId().equals(source.getControllerId()))) { if (game.getBattlefield().contains(filter, source.getControllerId(), 1, game)) { return true; } @@ -134,15 +133,8 @@ class GideonOfTheTrialsCantLoseEffect extends ContinuousRuleModifyingEffectImpl } } -class GideonOfTheTrialsEmblem extends Emblem { - public GideonOfTheTrialsEmblem() { - this.setName("Emblem - Gideon of the Trials"); - Ability ability = new SimpleStaticAbility(Zone.COMMAND, new GideonOfTheTrialsCantLoseEffect()); - this.getAbilities().add(ability); - } -} - class GideonOfTheTrialsToken extends Token { + public GideonOfTheTrialsToken() { super("", "a 4/4 Human Soldier creature with indestructible"); cardType.add(CardType.CREATURE);