From 78b5b8bdefe70dd37616cacd2e2dfa8e3d89b8d6 Mon Sep 17 00:00:00 2001 From: xenohedron Date: Sat, 30 Sep 2023 01:29:32 -0400 Subject: [PATCH] simplify LKI check using common method --- Mage.Sets/src/mage/cards/c/CreatureBond.java | 8 +---- Mage.Sets/src/mage/cards/c/CurseOfBounty.java | 8 +---- .../src/mage/cards/c/CurseOfDisturbance.java | 8 +---- .../src/mage/cards/c/CurseOfOpulence.java | 8 +---- .../src/mage/cards/c/CurseOfVerbosity.java | 8 +---- .../src/mage/cards/c/CurseOfVitality.java | 8 +---- Mage.Sets/src/mage/cards/e/EndlessEvil.java | 10 ++---- .../src/mage/cards/f/FollowedFootsteps.java | 8 +---- .../src/mage/cards/f/FracturedLoyalty.java | 7 +--- Mage.Sets/src/mage/cards/f/FrayingSanity.java | 14 ++------ Mage.Sets/src/mage/cards/i/IronclawCurse.java | 7 +--- Mage.Sets/src/mage/cards/m/MirrorMockery.java | 8 +---- .../mage/cards/o/OverwhelmingSplendor.java | 16 +++------ Mage.Sets/src/mage/cards/s/Seizures.java | 8 +---- Mage.Sets/src/mage/cards/s/SerraBestiary.java | 7 +--- .../src/mage/cards/t/TreacherousLink.java | 7 +--- .../src/mage/cards/v/VisionsOfBrutality.java | 34 +++++++------------ .../DamageAttachedControllerEffect.java | 9 +---- .../effects/common/DamageAttachedEffect.java | 9 +---- .../effects/common/ExileAttachedEffect.java | 8 +---- .../common/PhaseOutAttachedEffect.java | 8 +---- 21 files changed, 39 insertions(+), 169 deletions(-) diff --git a/Mage.Sets/src/mage/cards/c/CreatureBond.java b/Mage.Sets/src/mage/cards/c/CreatureBond.java index bbbffff4248..74c51c35783 100644 --- a/Mage.Sets/src/mage/cards/c/CreatureBond.java +++ b/Mage.Sets/src/mage/cards/c/CreatureBond.java @@ -13,7 +13,6 @@ import mage.cards.CardSetInfo; import mage.constants.CardType; import mage.constants.SubType; import mage.constants.Outcome; -import mage.constants.Zone; import mage.game.Game; import mage.game.permanent.Permanent; import mage.target.TargetPermanent; @@ -57,12 +56,7 @@ enum CreatureBondValue implements DynamicValue { @Override public int calculate(Game game, Ability sourceAbility, Effect effect) { - // In the case that the enchantment is blinked - Permanent enchantment = (Permanent) game.getLastKnownInformation(sourceAbility.getSourceId(), Zone.BATTLEFIELD); - if (enchantment == null) { - // It was not blinked, use the standard method - enchantment = game.getPermanentOrLKIBattlefield(sourceAbility.getSourceId()); - } + Permanent enchantment = sourceAbility.getSourcePermanentOrLKI(game); if (enchantment == null) { return 0; } diff --git a/Mage.Sets/src/mage/cards/c/CurseOfBounty.java b/Mage.Sets/src/mage/cards/c/CurseOfBounty.java index 0809bc9368b..006f6836826 100644 --- a/Mage.Sets/src/mage/cards/c/CurseOfBounty.java +++ b/Mage.Sets/src/mage/cards/c/CurseOfBounty.java @@ -18,7 +18,6 @@ import mage.target.targetpointer.FixedTarget; import java.util.UUID; import mage.abilities.common.EnchantedPlayerAttackedTriggeredAbility; import mage.abilities.effects.OneShotEffect; -import mage.constants.Zone; import mage.filter.StaticFilters; import mage.players.Player; @@ -71,12 +70,7 @@ class CurseOfBountyEffect extends OneShotEffect { @Override public boolean apply(Game game, Ability source) { - // In the case that the enchantment is blinked - Permanent enchantment = (Permanent) game.getLastKnownInformation(source.getSourceId(), Zone.BATTLEFIELD); - if (enchantment == null) { - // It was not blinked, use the standard method - enchantment = game.getPermanentOrLKIBattlefield(source.getSourceId()); - } + Permanent enchantment = source.getSourcePermanentOrLKI(game); if (enchantment != null) { Player enchantedPlayer = game.getPlayer(enchantment.getAttachedTo()); if (enchantedPlayer != null) { diff --git a/Mage.Sets/src/mage/cards/c/CurseOfDisturbance.java b/Mage.Sets/src/mage/cards/c/CurseOfDisturbance.java index c00f23f0a68..72e2a0eecf2 100644 --- a/Mage.Sets/src/mage/cards/c/CurseOfDisturbance.java +++ b/Mage.Sets/src/mage/cards/c/CurseOfDisturbance.java @@ -15,7 +15,6 @@ import mage.cards.CardSetInfo; import mage.constants.CardType; import mage.constants.Outcome; import mage.constants.SubType; -import mage.constants.Zone; import mage.game.Game; import mage.game.permanent.Permanent; import mage.game.permanent.token.ZombieToken; @@ -72,12 +71,7 @@ class CurseOfDisturbanceEffect extends OneShotEffect { @Override public boolean apply(Game game, Ability source) { - // In the case that the enchantment is blinked - Permanent enchantment = (Permanent) game.getLastKnownInformation(source.getSourceId(), Zone.BATTLEFIELD); - if (enchantment == null) { - // It was not blinked, use the standard method - enchantment = game.getPermanentOrLKIBattlefield(source.getSourceId()); - } + Permanent enchantment = source.getSourcePermanentOrLKI(game); if (enchantment != null) { Player enchantedPlayer = game.getPlayer(enchantment.getAttachedTo()); if (enchantedPlayer != null) { diff --git a/Mage.Sets/src/mage/cards/c/CurseOfOpulence.java b/Mage.Sets/src/mage/cards/c/CurseOfOpulence.java index 2694e0f6778..786ce7db5f3 100644 --- a/Mage.Sets/src/mage/cards/c/CurseOfOpulence.java +++ b/Mage.Sets/src/mage/cards/c/CurseOfOpulence.java @@ -22,7 +22,6 @@ import mage.target.targetpointer.FixedTarget; import java.util.HashSet; import java.util.Set; import java.util.UUID; -import mage.constants.Zone; /** * @author Saga @@ -72,12 +71,7 @@ class CurseOfOpulenceEffect extends OneShotEffect { @Override public boolean apply(Game game, Ability source) { - // In the case that the enchantment is blinked - Permanent enchantment = (Permanent) game.getLastKnownInformation(source.getSourceId(), Zone.BATTLEFIELD); - if (enchantment == null) { - // It was not blinked, use the standard method - enchantment = game.getPermanentOrLKIBattlefield(source.getSourceId()); - } + Permanent enchantment = source.getSourcePermanentOrLKI(game); if (enchantment == null) { return false; } diff --git a/Mage.Sets/src/mage/cards/c/CurseOfVerbosity.java b/Mage.Sets/src/mage/cards/c/CurseOfVerbosity.java index f0b42b14d11..cca22b63173 100644 --- a/Mage.Sets/src/mage/cards/c/CurseOfVerbosity.java +++ b/Mage.Sets/src/mage/cards/c/CurseOfVerbosity.java @@ -15,7 +15,6 @@ import mage.cards.CardSetInfo; import mage.constants.CardType; import mage.constants.Outcome; import mage.constants.SubType; -import mage.constants.Zone; import mage.game.Game; import mage.game.permanent.Permanent; import mage.players.Player; @@ -70,12 +69,7 @@ class CurseOfVerbosityEffect extends OneShotEffect { @Override public boolean apply(Game game, Ability source) { - // In the case that the enchantment is blinked - Permanent enchantment = (Permanent) game.getLastKnownInformation(source.getSourceId(), Zone.BATTLEFIELD); - if (enchantment == null) { - // It was not blinked, use the standard method - enchantment = game.getPermanentOrLKIBattlefield(source.getSourceId()); - } + Permanent enchantment = source.getSourcePermanentOrLKI(game); if (enchantment != null) { Player enchantedPlayer = game.getPlayer(enchantment.getAttachedTo()); if (enchantedPlayer != null) { diff --git a/Mage.Sets/src/mage/cards/c/CurseOfVitality.java b/Mage.Sets/src/mage/cards/c/CurseOfVitality.java index 095acb8d9c5..f172e205f86 100644 --- a/Mage.Sets/src/mage/cards/c/CurseOfVitality.java +++ b/Mage.Sets/src/mage/cards/c/CurseOfVitality.java @@ -19,7 +19,6 @@ import mage.abilities.Ability; import mage.abilities.common.EnchantedPlayerAttackedTriggeredAbility; import mage.abilities.effects.OneShotEffect; import mage.abilities.effects.common.GainLifeTargetEffect; -import mage.constants.Zone; import mage.players.Player; /** @@ -70,12 +69,7 @@ class CurseOfVitalityEffect extends OneShotEffect { @Override public boolean apply(Game game, Ability source) { - // In the case that the enchantment is blinked - Permanent enchantment = (Permanent) game.getLastKnownInformation(source.getSourceId(), Zone.BATTLEFIELD); - if (enchantment == null) { - // It was not blinked, use the standard method - enchantment = game.getPermanentOrLKIBattlefield(source.getSourceId()); - } + Permanent enchantment = source.getSourcePermanentOrLKI(game); if (enchantment != null) { Player enchantedPlayer = game.getPlayer(enchantment.getAttachedTo()); if (enchantedPlayer != null) { diff --git a/Mage.Sets/src/mage/cards/e/EndlessEvil.java b/Mage.Sets/src/mage/cards/e/EndlessEvil.java index ca810e80490..a90ada8fa81 100644 --- a/Mage.Sets/src/mage/cards/e/EndlessEvil.java +++ b/Mage.Sets/src/mage/cards/e/EndlessEvil.java @@ -42,12 +42,12 @@ public final class EndlessEvil extends CardImpl { this.addAbility(ability); // At the beginning of your upkeep, create a token that’s a copy of enchanted creature, except the token is 1/1. - TriggeredAbility CloneAbility = new BeginningOfUpkeepTriggeredAbility( + TriggeredAbility cloneAbility = new BeginningOfUpkeepTriggeredAbility( new EndlessEvilCloneEffect(), TargetController.YOU, false ); - this.addAbility(CloneAbility); + this.addAbility(cloneAbility); // When enchanted creature dies, if that creature was a Horror, return Endless Evil to its owner’s hand. this.addAbility(new EndlessEvilBounceAbility()); @@ -81,11 +81,7 @@ class EndlessEvilCloneEffect extends OneShotEffect { @Override public boolean apply (Game game, Ability source) { - Permanent enchantment = (Permanent) game.getLastKnownInformation(source.getSourceId(), Zone.BATTLEFIELD); - if (enchantment == null) { - // In the case that Endless Evil is blinked - enchantment = game.getPermanentOrLKIBattlefield(source.getSourceId()); - } + Permanent enchantment = source.getSourcePermanentOrLKI(game); if (enchantment != null) { Permanent target = game.getPermanentOrLKIBattlefield(enchantment.getAttachedTo()); if (target != null) { diff --git a/Mage.Sets/src/mage/cards/f/FollowedFootsteps.java b/Mage.Sets/src/mage/cards/f/FollowedFootsteps.java index 22272087872..e453cd8474b 100644 --- a/Mage.Sets/src/mage/cards/f/FollowedFootsteps.java +++ b/Mage.Sets/src/mage/cards/f/FollowedFootsteps.java @@ -13,7 +13,6 @@ import mage.cards.CardSetInfo; import mage.constants.CardType; import mage.constants.SubType; import mage.constants.Outcome; -import mage.constants.Zone; import mage.game.Game; import mage.game.events.GameEvent; import mage.game.permanent.Permanent; @@ -71,12 +70,7 @@ class FollowedFootstepsEffect extends OneShotEffect { @Override public boolean apply(Game game, Ability source) { - // In the case that Followed Footsteps is blinked - Permanent enchantment = (Permanent) game.getLastKnownInformation(source.getSourceId(), Zone.BATTLEFIELD); - if (enchantment == null) { - // It was not blinked, use the standard method - enchantment = game.getPermanentOrLKIBattlefield(source.getSourceId()); - } + Permanent enchantment = source.getSourcePermanentOrLKI(game); if (enchantment != null) { Permanent target = game.getPermanentOrLKIBattlefield(enchantment.getAttachedTo()); if (target != null) { diff --git a/Mage.Sets/src/mage/cards/f/FracturedLoyalty.java b/Mage.Sets/src/mage/cards/f/FracturedLoyalty.java index 2dc7d19d79a..6270e2f7ca7 100644 --- a/Mage.Sets/src/mage/cards/f/FracturedLoyalty.java +++ b/Mage.Sets/src/mage/cards/f/FracturedLoyalty.java @@ -66,12 +66,7 @@ class FracturedLoyaltyEffect extends OneShotEffect { @Override public boolean apply(Game game, Ability source) { - // In the case that Fractured Loyalty is blinked - Permanent enchantment = (Permanent) game.getLastKnownInformation(source.getSourceId(), Zone.BATTLEFIELD); - if (enchantment == null) { - // It was not blinked, use the standard method - enchantment = game.getPermanentOrLKIBattlefield(source.getSourceId()); - } + Permanent enchantment = source.getSourcePermanentOrLKI(game); if (enchantment == null || enchantment.getAttachedTo() == null) { return false; } diff --git a/Mage.Sets/src/mage/cards/f/FrayingSanity.java b/Mage.Sets/src/mage/cards/f/FrayingSanity.java index 8413826df59..5d749e0185f 100644 --- a/Mage.Sets/src/mage/cards/f/FrayingSanity.java +++ b/Mage.Sets/src/mage/cards/f/FrayingSanity.java @@ -14,7 +14,6 @@ import mage.constants.SubType; import mage.constants.Zone; import mage.game.Game; import mage.game.events.GameEvent; -import mage.game.events.GameEvent.EventType; import mage.game.permanent.Permanent; import mage.players.Player; import mage.target.TargetPlayer; @@ -86,8 +85,6 @@ class FrayingSanityTriggeredAbility extends TriggeredAbilityImpl { class FrayingSanityEffect extends OneShotEffect { - int xAmount = 0; - public FrayingSanityEffect() { super(Outcome.Detriment); this.staticText = ""; @@ -104,21 +101,14 @@ class FrayingSanityEffect extends OneShotEffect { @Override public boolean apply(Game game, Ability source) { - // In the case that the enchantment is blinked - Permanent enchantment = (Permanent) game.getLastKnownInformation(source.getSourceId(), Zone.BATTLEFIELD); - if (enchantment == null) { - // It was not blinked, use the standard method - enchantment = game.getPermanentOrLKIBattlefield(source.getSourceId()); - } + Permanent enchantment = source.getSourcePermanentOrLKI(game); if (enchantment == null) { return false; } Player enchantedPlayer = game.getPlayer(enchantment.getAttachedTo()); if (enchantedPlayer != null) { CardsPutIntoGraveyardWatcher watcher = game.getState().getWatcher(CardsPutIntoGraveyardWatcher.class); - if (watcher != null) { - xAmount = watcher.getAmountCardsPutToGraveyard(enchantedPlayer.getId()); - } + int xAmount = (watcher == null) ? 0 : watcher.getAmountCardsPutToGraveyard(enchantedPlayer.getId()); enchantedPlayer.millCards(xAmount, source, game); return true; } diff --git a/Mage.Sets/src/mage/cards/i/IronclawCurse.java b/Mage.Sets/src/mage/cards/i/IronclawCurse.java index 32765bee6ab..0d7ba651966 100644 --- a/Mage.Sets/src/mage/cards/i/IronclawCurse.java +++ b/Mage.Sets/src/mage/cards/i/IronclawCurse.java @@ -70,12 +70,7 @@ class IronclawCurseEffect extends CantBlockAttachedEffect { if (attacker == null) { return true; } - // In the case that the enchantment is blinked - Permanent enchantment = (Permanent) game.getLastKnownInformation(source.getSourceId(), Zone.BATTLEFIELD); - if (enchantment == null) { - // It was not blinked, use the standard method - enchantment = game.getPermanentOrLKIBattlefield(source.getSourceId()); - } + Permanent enchantment = source.getSourcePermanentOrLKI(game); if (enchantment == null) { return false; } diff --git a/Mage.Sets/src/mage/cards/m/MirrorMockery.java b/Mage.Sets/src/mage/cards/m/MirrorMockery.java index 4d2cad23b58..9db6f53a57f 100644 --- a/Mage.Sets/src/mage/cards/m/MirrorMockery.java +++ b/Mage.Sets/src/mage/cards/m/MirrorMockery.java @@ -15,7 +15,6 @@ import mage.constants.AttachmentType; import mage.constants.CardType; import mage.constants.SubType; import mage.constants.Outcome; -import mage.constants.Zone; import mage.game.Game; import mage.game.permanent.Permanent; import mage.target.TargetPermanent; @@ -71,12 +70,7 @@ class MirrorMockeryEffect extends OneShotEffect { @Override public boolean apply(Game game, Ability source) { - // In the case that the enchantment is blinked - Permanent enchantment = (Permanent) game.getLastKnownInformation(source.getSourceId(), Zone.BATTLEFIELD); - if (enchantment == null) { - // It was not blinked, use the standard method - enchantment = game.getPermanentOrLKIBattlefield(source.getSourceId()); - } + Permanent enchantment = source.getSourcePermanentOrLKI(game); if (enchantment == null) { return false; } diff --git a/Mage.Sets/src/mage/cards/o/OverwhelmingSplendor.java b/Mage.Sets/src/mage/cards/o/OverwhelmingSplendor.java index a6a42957e84..d780cb83a54 100644 --- a/Mage.Sets/src/mage/cards/o/OverwhelmingSplendor.java +++ b/Mage.Sets/src/mage/cards/o/OverwhelmingSplendor.java @@ -1,4 +1,3 @@ - package mage.cards.o; import mage.MageObject; @@ -60,7 +59,7 @@ public final class OverwhelmingSplendor extends CardImpl { class OverwhelmingSplendorLoseAbilitiesEffect extends ContinuousEffectImpl { - public OverwhelmingSplendorLoseAbilitiesEffect() { + OverwhelmingSplendorLoseAbilitiesEffect() { super(Duration.WhileOnBattlefield, Outcome.LoseAbility); staticText = "Creatures enchanted player controls lose all abilities and have base power and toughness 1/1"; } @@ -76,21 +75,14 @@ class OverwhelmingSplendorLoseAbilitiesEffect extends ContinuousEffectImpl { @Override public boolean apply(Layer layer, SubLayer sublayer, Ability source, Game game) { - // In the case that the enchantment is blinked - Permanent enchantment = (Permanent) game.getLastKnownInformation(source.getSourceId(), Zone.BATTLEFIELD); + Permanent enchantment = source.getSourcePermanentOrLKI(game); if (enchantment == null) { - // It was not blinked, use the standard method - enchantment = game.getPermanentOrLKIBattlefield(source.getSourceId()); - if (enchantment == null) { - return false; - } + return false; } - Player player = game.getPlayer(enchantment.getAttachedTo()); if (player == null) { return false; } - for (Permanent permanent : game.getState().getBattlefield().getAllActivePermanents(StaticFilters.FILTER_PERMANENT_CREATURE, player.getId(), game)) { switch (layer) { case AbilityAddingRemovingEffects_6: @@ -120,7 +112,7 @@ class OverwhelmingSplendorLoseAbilitiesEffect extends ContinuousEffectImpl { class OverwhelmingSplendorCantActivateEffect extends ContinuousRuleModifyingEffectImpl { - public OverwhelmingSplendorCantActivateEffect() { + OverwhelmingSplendorCantActivateEffect() { super(Duration.WhileOnBattlefield, Outcome.Detriment); staticText = "Enchanted player can't activate abilities that aren't mana abilities or loyalty abilities"; } diff --git a/Mage.Sets/src/mage/cards/s/Seizures.java b/Mage.Sets/src/mage/cards/s/Seizures.java index a3ef4737962..14abf0c6946 100644 --- a/Mage.Sets/src/mage/cards/s/Seizures.java +++ b/Mage.Sets/src/mage/cards/s/Seizures.java @@ -19,7 +19,6 @@ import mage.target.TargetPermanent; import mage.target.common.TargetCreaturePermanent; import java.util.UUID; -import mage.constants.Zone; /** * @author LoneFox @@ -68,12 +67,7 @@ class SeizuresEffect extends OneShotEffect { @Override public boolean apply(Game game, Ability source) { - // In the case that the enchantment is blinked - Permanent enchantment = (Permanent) game.getLastKnownInformation(source.getSourceId(), Zone.BATTLEFIELD); - if (enchantment == null) { - // It was not blinked, use the standard method - enchantment = game.getPermanentOrLKIBattlefield(source.getSourceId()); - } + Permanent enchantment = source.getSourcePermanentOrLKI(game); if (enchantment == null) { return false; } diff --git a/Mage.Sets/src/mage/cards/s/SerraBestiary.java b/Mage.Sets/src/mage/cards/s/SerraBestiary.java index 7f5da2c191a..e6c550a7736 100644 --- a/Mage.Sets/src/mage/cards/s/SerraBestiary.java +++ b/Mage.Sets/src/mage/cards/s/SerraBestiary.java @@ -87,12 +87,7 @@ class SerraBestiaryRuleModifyingEffect extends ContinuousRuleModifyingEffectImpl @Override public boolean applies(GameEvent event, Ability source, Game game) { - // In the case that the enchantment is blinked - Permanent enchantment = (Permanent) game.getLastKnownInformation(source.getSourceId(), Zone.BATTLEFIELD); - if (enchantment == null) { - // It was not blinked, use the standard method - enchantment = game.getPermanentOrLKIBattlefield(source.getSourceId()); - } + Permanent enchantment = source.getSourcePermanentOrLKI(game); if (enchantment == null) { return false; } diff --git a/Mage.Sets/src/mage/cards/t/TreacherousLink.java b/Mage.Sets/src/mage/cards/t/TreacherousLink.java index 0bdb77e0432..a86997c22b4 100644 --- a/Mage.Sets/src/mage/cards/t/TreacherousLink.java +++ b/Mage.Sets/src/mage/cards/t/TreacherousLink.java @@ -95,12 +95,7 @@ class TreacherousLinkEffect extends ReplacementEffectImpl { @Override public boolean applies(GameEvent event, Ability source, Game game) { - // In the case that the enchantment is blinked - Permanent enchantment = (Permanent) game.getLastKnownInformation(source.getSourceId(), Zone.BATTLEFIELD); - if (enchantment == null) { - // It was not blinked, use the standard method - enchantment = game.getPermanentOrLKIBattlefield(source.getSourceId()); - } + Permanent enchantment = source.getSourcePermanentOrLKI(game); Player controller = game.getPlayer(source.getControllerId()); DamageEvent damageEvent = (DamageEvent) event; if (controller != null && enchantment != null) { diff --git a/Mage.Sets/src/mage/cards/v/VisionsOfBrutality.java b/Mage.Sets/src/mage/cards/v/VisionsOfBrutality.java index 9f49b2330e3..7dc0f3bfdf8 100644 --- a/Mage.Sets/src/mage/cards/v/VisionsOfBrutality.java +++ b/Mage.Sets/src/mage/cards/v/VisionsOfBrutality.java @@ -60,7 +60,7 @@ public final class VisionsOfBrutality extends CardImpl { class VisionsOfBrutalityEffect extends OneShotEffect { - public VisionsOfBrutalityEffect() { + VisionsOfBrutalityEffect() { super(Outcome.Benefit); this.staticText = "its controller loses that much life"; } @@ -77,28 +77,20 @@ class VisionsOfBrutalityEffect extends OneShotEffect { @Override public boolean apply(Game game, Ability source) { Player controller = game.getPlayer(source.getControllerId()); - if (controller != null) { - // In the case that the enchantment is blinked - Permanent enchantment = (Permanent) game.getLastKnownInformation(source.getSourceId(), Zone.BATTLEFIELD); - if (enchantment == null) { - // It was not blinked, use the standard method - enchantment = game.getPermanentOrLKIBattlefield(source.getSourceId()); - } - if (enchantment != null - && enchantment.getAttachedTo() != null) { - Permanent enchanted = game.getPermanentOrLKIBattlefield(enchantment.getAttachedTo()); - if (enchanted != null) { - Player controllerEnchanted = game.getPlayer(enchanted.getControllerId()); - if (controllerEnchanted != null) { - int damage = (Integer) getValue("damage"); - if (damage > 0) { - controllerEnchanted.loseLife(damage, game, source, false); - } - } + Permanent enchantment = source.getSourcePermanentOrLKI(game); + if (controller == null || enchantment == null || enchantment.getAttachedTo() == null) { + return false; + } + Permanent enchanted = game.getPermanentOrLKIBattlefield(enchantment.getAttachedTo()); + if (enchanted != null) { + Player controllerEnchanted = game.getPlayer(enchanted.getControllerId()); + if (controllerEnchanted != null) { + int damage = (Integer) getValue("damage"); + if (damage > 0) { + controllerEnchanted.loseLife(damage, game, source, false); } } - return true; } - return false; + return true; } } diff --git a/Mage/src/main/java/mage/abilities/effects/common/DamageAttachedControllerEffect.java b/Mage/src/main/java/mage/abilities/effects/common/DamageAttachedControllerEffect.java index ac85b90d186..702aef678c7 100644 --- a/Mage/src/main/java/mage/abilities/effects/common/DamageAttachedControllerEffect.java +++ b/Mage/src/main/java/mage/abilities/effects/common/DamageAttachedControllerEffect.java @@ -1,12 +1,10 @@ package mage.abilities.effects.common; import mage.abilities.Ability; -import mage.abilities.Mode; import mage.abilities.dynamicvalue.DynamicValue; import mage.abilities.dynamicvalue.common.StaticValue; import mage.abilities.effects.OneShotEffect; import mage.constants.Outcome; -import mage.constants.Zone; import mage.game.Game; import mage.game.permanent.Permanent; import mage.players.Player; @@ -40,12 +38,7 @@ public class DamageAttachedControllerEffect extends OneShotEffect { @Override public boolean apply(Game game, Ability source) { - // In the case that the enchantment is blinked - Permanent enchantment = (Permanent) game.getLastKnownInformation(source.getSourceId(), Zone.BATTLEFIELD); - if (enchantment == null) { - // It was not blinked, use the standard method - enchantment = game.getPermanentOrLKIBattlefield(source.getSourceId()); - } + Permanent enchantment = source.getSourcePermanentOrLKI(game); if (enchantment == null) { return false; } diff --git a/Mage/src/main/java/mage/abilities/effects/common/DamageAttachedEffect.java b/Mage/src/main/java/mage/abilities/effects/common/DamageAttachedEffect.java index 4047bd3f334..142cfb19028 100644 --- a/Mage/src/main/java/mage/abilities/effects/common/DamageAttachedEffect.java +++ b/Mage/src/main/java/mage/abilities/effects/common/DamageAttachedEffect.java @@ -1,12 +1,10 @@ package mage.abilities.effects.common; import mage.abilities.Ability; -import mage.abilities.Mode; import mage.abilities.dynamicvalue.DynamicValue; import mage.abilities.dynamicvalue.common.StaticValue; import mage.abilities.effects.OneShotEffect; import mage.constants.Outcome; -import mage.constants.Zone; import mage.game.Game; import mage.game.permanent.Permanent; @@ -47,12 +45,7 @@ public class DamageAttachedEffect extends OneShotEffect { @Override public boolean apply(Game game, Ability source) { - // In the case that the enchantment is blinked - Permanent enchantment = (Permanent) game.getLastKnownInformation(source.getSourceId(), Zone.BATTLEFIELD); - if (enchantment == null) { - // It was not blinked, use the standard method - enchantment = game.getPermanentOrLKIBattlefield(source.getSourceId()); - } + Permanent enchantment = source.getSourcePermanentOrLKI(game); if (enchantment == null) { return false; } diff --git a/Mage/src/main/java/mage/abilities/effects/common/ExileAttachedEffect.java b/Mage/src/main/java/mage/abilities/effects/common/ExileAttachedEffect.java index 202158dd436..a4116c0d23b 100644 --- a/Mage/src/main/java/mage/abilities/effects/common/ExileAttachedEffect.java +++ b/Mage/src/main/java/mage/abilities/effects/common/ExileAttachedEffect.java @@ -3,7 +3,6 @@ package mage.abilities.effects.common; import mage.abilities.Ability; import mage.abilities.effects.OneShotEffect; import mage.constants.Outcome; -import mage.constants.Zone; import mage.game.Game; import mage.game.permanent.Permanent; import mage.players.Player; @@ -31,12 +30,7 @@ public class ExileAttachedEffect extends OneShotEffect { public boolean apply(Game game, Ability source) { Player controller = game.getPlayer(source.getControllerId()); // The LKI must be used for this step. 608.2g - // In the case that the enchantment is blinked - Permanent enchantment = (Permanent) game.getLastKnownInformation(source.getSourceId(), Zone.BATTLEFIELD); - if (enchantment == null) { - // It was not blinked, use the standard method - enchantment = game.getPermanentOrLKIBattlefield(source.getSourceId()); - } + Permanent enchantment = source.getSourcePermanentOrLKI(game); if (controller != null && enchantment != null && enchantment.getAttachedTo() != null) { diff --git a/Mage/src/main/java/mage/abilities/effects/common/PhaseOutAttachedEffect.java b/Mage/src/main/java/mage/abilities/effects/common/PhaseOutAttachedEffect.java index ca4d540d768..1823bca9589 100644 --- a/Mage/src/main/java/mage/abilities/effects/common/PhaseOutAttachedEffect.java +++ b/Mage/src/main/java/mage/abilities/effects/common/PhaseOutAttachedEffect.java @@ -3,7 +3,6 @@ package mage.abilities.effects.common; import mage.abilities.Ability; import mage.abilities.effects.OneShotEffect; import mage.constants.Outcome; -import mage.constants.Zone; import mage.game.Game; import mage.game.permanent.Permanent; @@ -28,12 +27,7 @@ public class PhaseOutAttachedEffect extends OneShotEffect { @Override public boolean apply(Game game, Ability source) { - // In the case that the enchantment is blinked - Permanent enchantment = (Permanent) game.getLastKnownInformation(source.getSourceId(), Zone.BATTLEFIELD); - if (enchantment == null) { - // It was not blinked, use the standard method - enchantment = game.getPermanentOrLKIBattlefield(source.getSourceId()); - } + Permanent enchantment = source.getSourcePermanentOrLKI(game); if (enchantment != null) { Permanent enchanted = game.getPermanent(enchantment.getAttachedTo()); if (enchanted != null) {