diff --git a/Mage.Sets/src/mage/cards/a/AbattoirGhoul.java b/Mage.Sets/src/mage/cards/a/AbattoirGhoul.java index 5350171150..2f78aafef9 100644 --- a/Mage.Sets/src/mage/cards/a/AbattoirGhoul.java +++ b/Mage.Sets/src/mage/cards/a/AbattoirGhoul.java @@ -1,4 +1,3 @@ - package mage.cards.a; import java.util.UUID; @@ -7,13 +6,11 @@ import mage.abilities.Ability; import mage.abilities.common.DealtDamageAndDiedTriggeredAbility; import mage.abilities.effects.OneShotEffect; import mage.abilities.keyword.FirstStrikeAbility; -import mage.cards.Card; import mage.cards.CardImpl; 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; @@ -25,7 +22,7 @@ import mage.players.Player; public final class AbattoirGhoul extends CardImpl { public AbattoirGhoul(UUID ownerId, CardSetInfo setInfo) { - super(ownerId,setInfo,new CardType[]{CardType.CREATURE},"{3}{B}"); + super(ownerId, setInfo, new CardType[]{CardType.CREATURE}, "{3}{B}"); this.subtype.add(SubType.ZOMBIE); this.power = new MageInt(3); @@ -65,18 +62,15 @@ class AbattoirGhoulEffect extends OneShotEffect { @Override public boolean apply(Game game, Ability source) { - Player you = game.getPlayer(source.getControllerId()); - Card card = game.getCard(targetPointer.getFirst(game, source)); - if (card != null) { - Permanent creature = (Permanent) game.getLastKnownInformation(card.getId(), Zone.BATTLEFIELD); - if (creature != null) { - int toughness = creature.getToughness().getValue(); - if (you != null) { - you.gainLife(toughness, game, source); - return true; - } + Player controller = game.getPlayer(source.getControllerId()); + Permanent creature = getTargetPointer().getFirstTargetPermanentOrLKI(game, source); + if (creature != null) { + int toughness = creature.getToughness().getValue(); + if (controller != null) { + controller.gainLife(toughness, game, source); + return true; } } return false; } -} \ No newline at end of file +} diff --git a/Mage.Sets/src/mage/cards/a/AbbotOfKeralKeep.java b/Mage.Sets/src/mage/cards/a/AbbotOfKeralKeep.java index 0d85e9cf3c..92be44357d 100644 --- a/Mage.Sets/src/mage/cards/a/AbbotOfKeralKeep.java +++ b/Mage.Sets/src/mage/cards/a/AbbotOfKeralKeep.java @@ -76,7 +76,7 @@ class AbbotOfKeralKeepExileEffect extends OneShotEffect { String exileName = sourcePermanent.getIdName() + " "; controller.moveCardsToExile(card, source, game, true, source.getSourceId(), exileName); ContinuousEffect effect = new PlayFromNotOwnHandZoneTargetEffect(Duration.EndOfTurn); - effect.setTargetPointer(new FixedTarget(card.getId(), card.getZoneChangeCounter(game))); + effect.setTargetPointer(new FixedTarget(card, game)); game.addEffect(effect, source); } return true; diff --git a/Mage.Sets/src/mage/cards/a/AcornCatapult.java b/Mage.Sets/src/mage/cards/a/AcornCatapult.java index d19f4460e2..7742ba3ae9 100644 --- a/Mage.Sets/src/mage/cards/a/AcornCatapult.java +++ b/Mage.Sets/src/mage/cards/a/AcornCatapult.java @@ -1,4 +1,3 @@ - package mage.cards.a; import java.util.UUID; @@ -28,7 +27,7 @@ public final class AcornCatapult extends CardImpl { public AcornCatapult(UUID ownerId, CardSetInfo setInfo) { super(ownerId, setInfo, new CardType[]{CardType.ARTIFACT}, "{4}"); - // {1}, {tap}: Acorn Catapult deals 1 damage to any target. That creature's controller or that player creates a 1/1 green Squirrel creature token. + // {1}, {T}: Acorn Catapult deals 1 damage to any target. That creature's controller or that player creates a 1/1 green Squirrel creature token. Ability ability = new SimpleActivatedAbility(Zone.BATTLEFIELD, new DamageTargetEffect(1), new ManaCostsImpl("{1}")); ability.addCost(new TapSourceCost()); ability.addEffect(new AcornCatapultEffect()); @@ -64,10 +63,9 @@ class AcornCatapultEffect extends OneShotEffect { @Override public boolean apply(Game game, Ability source) { - UUID targetId = getTargetPointer().getFirst(game, source); - Player player = game.getPlayer(targetId); + Player player = game.getPlayer(getTargetPointer().getFirst(game, source)); if (player == null) { - Permanent permanent = game.getPermanent(targetId); + Permanent permanent = getTargetPointer().getFirstTargetPermanentOrLKI(game, source); if (permanent != null) { player = game.getPlayer(permanent.getControllerId()); } diff --git a/Mage.Sets/src/mage/cards/a/ActOfAuthority.java b/Mage.Sets/src/mage/cards/a/ActOfAuthority.java index 916d33963d..c1acf361ec 100644 --- a/Mage.Sets/src/mage/cards/a/ActOfAuthority.java +++ b/Mage.Sets/src/mage/cards/a/ActOfAuthority.java @@ -1,4 +1,3 @@ - package mage.cards.a; import java.util.UUID; @@ -66,7 +65,7 @@ class ActOfAuthorityEffect extends OneShotEffect { @Override public boolean apply(Game game, Ability source) { - Permanent targetPermanent = game.getPermanent(this.getTargetPointer().getFirst(game, source)); + Permanent targetPermanent = game.getPermanent(getTargetPointer().getFirst(game, source)); if (targetPermanent != null && new ExileTargetEffect().apply(game, source)) { Permanent sourcePermanent = source.getSourcePermanentIfItStillExists(game); if (sourcePermanent != null) { diff --git a/Mage.Sets/src/mage/cards/a/AerialCaravan.java b/Mage.Sets/src/mage/cards/a/AerialCaravan.java index 27524c47b4..be2342656c 100644 --- a/Mage.Sets/src/mage/cards/a/AerialCaravan.java +++ b/Mage.Sets/src/mage/cards/a/AerialCaravan.java @@ -81,7 +81,7 @@ class AerialCaravanExileEffect extends OneShotEffect { String exileName = sourcePermanent.getIdName() + " "; controller.moveCardsToExile(card, source, game, true, source.getSourceId(), exileName); ContinuousEffect effect = new PlayFromNotOwnHandZoneTargetEffect(Zone.EXILED, Duration.EndOfTurn); - effect.setTargetPointer(new FixedTarget(card.getId(), card.getZoneChangeCounter(game))); + effect.setTargetPointer(new FixedTarget(card, game)); game.addEffect(effect, source); } return true; diff --git a/Mage.Sets/src/mage/cards/a/Afterlife.java b/Mage.Sets/src/mage/cards/a/Afterlife.java index 802a5e90ba..ba29b8b578 100644 --- a/Mage.Sets/src/mage/cards/a/Afterlife.java +++ b/Mage.Sets/src/mage/cards/a/Afterlife.java @@ -1,4 +1,3 @@ - package mage.cards.a; import java.util.UUID; @@ -21,7 +20,7 @@ import mage.target.common.TargetCreaturePermanent; public final class Afterlife extends CardImpl { public Afterlife(UUID ownerId, CardSetInfo setInfo) { - super(ownerId,setInfo,new CardType[]{CardType.INSTANT},"{2}{W}"); + super(ownerId, setInfo, new CardType[]{CardType.INSTANT}, "{2}{W}"); // Destroy target creature. It can't be regenerated. Its controller puts a // 1/1 white Spirit creature token with flying. @@ -58,7 +57,7 @@ class AfterlifeEffect extends OneShotEffect { @Override public boolean apply(Game game, Ability source) { - Permanent permanent = game.getPermanentOrLKIBattlefield(this.getTargetPointer().getFirst(game, source)); + Permanent permanent = getTargetPointer().getFirstTargetPermanentOrLKI(game, source); if (permanent != null) { SpiritWhiteToken token = new SpiritWhiteToken(); token.putOntoBattlefield(1, game, source.getSourceId(), permanent.getControllerId()); diff --git a/Mage.Sets/src/mage/cards/a/AkoumHellkite.java b/Mage.Sets/src/mage/cards/a/AkoumHellkite.java index 991fae1edd..09d4da7474 100644 --- a/Mage.Sets/src/mage/cards/a/AkoumHellkite.java +++ b/Mage.Sets/src/mage/cards/a/AkoumHellkite.java @@ -115,7 +115,7 @@ class AkoumHellkiteDamageEffect extends OneShotEffect { @Override public boolean apply(Game game, Ability source) { - Permanent land = game.getPermanentOrLKIBattlefield(getTargetPointer().getFirst(game, source)); + Permanent land = getTargetPointer().getFirstTargetPermanentOrLKI(game, source); Player player = game.getPlayer(source.getFirstTarget()); if (land != null && player != null) { if (land.hasSubtype(SubType.MOUNTAIN, game)) { diff --git a/Mage.Sets/src/mage/cards/a/AminatouTheFateshifter.java b/Mage.Sets/src/mage/cards/a/AminatouTheFateshifter.java index af5db56ead..d2f3040e85 100644 --- a/Mage.Sets/src/mage/cards/a/AminatouTheFateshifter.java +++ b/Mage.Sets/src/mage/cards/a/AminatouTheFateshifter.java @@ -172,7 +172,7 @@ class AminatouUltimateEffect extends OneShotEffect { continue; } ContinuousEffect effect = new GainControlTargetEffect(Duration.EndOfGame, currentPlayer); - effect.setTargetPointer(new FixedTarget(permanent.getId())); + effect.setTargetPointer(new FixedTarget(permanent, game)); game.addEffect(effect, source); } currentPlayer = nextPlayer; diff --git a/Mage.Sets/src/mage/cards/a/AminatousAugury.java b/Mage.Sets/src/mage/cards/a/AminatousAugury.java index 78a047d2d3..2c46320553 100644 --- a/Mage.Sets/src/mage/cards/a/AminatousAugury.java +++ b/Mage.Sets/src/mage/cards/a/AminatousAugury.java @@ -104,7 +104,7 @@ class AminatousAuguryEffect extends OneShotEffect { } for (Card card : cardsToCast.getCards(StaticFilters.FILTER_CARD_NON_LAND, game)) { AminatousAuguryCastFromExileEffect effect = new AminatousAuguryCastFromExileEffect(); - effect.setTargetPointer(new FixedTarget(card.getId(), card.getZoneChangeCounter(game))); + effect.setTargetPointer(new FixedTarget(card, game)); game.addEffect(effect, source); } } diff --git a/Mage.Sets/src/mage/cards/a/AngelicAscension.java b/Mage.Sets/src/mage/cards/a/AngelicAscension.java index 4d99578f64..afe5de86d2 100644 --- a/Mage.Sets/src/mage/cards/a/AngelicAscension.java +++ b/Mage.Sets/src/mage/cards/a/AngelicAscension.java @@ -1,5 +1,6 @@ package mage.cards.a; +import java.util.UUID; import mage.abilities.Ability; import mage.abilities.effects.OneShotEffect; import mage.abilities.effects.common.ExileTargetEffect; @@ -13,8 +14,6 @@ import mage.game.permanent.token.AngelToken; import mage.game.permanent.token.Token; import mage.target.common.TargetCreatureOrPlaneswalker; -import java.util.UUID; - /** * @author TheElk801 */ @@ -59,7 +58,7 @@ class AngelicAscensionEffect extends OneShotEffect { @Override public boolean apply(Game game, Ability source) { - Permanent permanent = game.getPermanentOrLKIBattlefield(source.getFirstTarget()); + Permanent permanent = getTargetPointer().getFirstTargetPermanentOrLKI(game, source); if (permanent == null) { return false; } diff --git a/Mage.Sets/src/mage/cards/a/ApexOfPower.java b/Mage.Sets/src/mage/cards/a/ApexOfPower.java index edf7670988..ed498bf484 100644 --- a/Mage.Sets/src/mage/cards/a/ApexOfPower.java +++ b/Mage.Sets/src/mage/cards/a/ApexOfPower.java @@ -79,7 +79,7 @@ class ApexOfPowerSpellEffect extends OneShotEffect { continue; } ContinuousEffect effect = new PlayFromNotOwnHandZoneTargetEffect(Zone.EXILED, Duration.EndOfTurn); - effect.setTargetPointer(new FixedTarget(card.getId(), card.getZoneChangeCounter(game))); + effect.setTargetPointer(new FixedTarget(card, game)); game.addEffect(effect, source); } return true; diff --git a/Mage.Sets/src/mage/cards/a/ArchonOfRedemption.java b/Mage.Sets/src/mage/cards/a/ArchonOfRedemption.java index f382139061..df21ecbce8 100644 --- a/Mage.Sets/src/mage/cards/a/ArchonOfRedemption.java +++ b/Mage.Sets/src/mage/cards/a/ArchonOfRedemption.java @@ -1,5 +1,6 @@ package mage.cards.a; +import java.util.UUID; import mage.MageInt; import mage.abilities.Ability; import mage.abilities.common.EntersBattlefieldThisOrAnotherTriggeredAbility; @@ -18,8 +19,6 @@ import mage.game.Game; import mage.game.permanent.Permanent; import mage.players.Player; -import java.util.UUID; - /** * @author Loki */ @@ -75,7 +74,7 @@ class ArchonOfRedemptionEffect extends OneShotEffect { @Override public boolean apply(Game game, Ability source) { Player player = game.getPlayer(source.getControllerId()); - Permanent permanent = game.getPermanent(getTargetPointer().getFirst(game, source)); + Permanent permanent = getTargetPointer().getFirstTargetPermanentOrLKI(game, source); if (player == null || permanent == null) { return false; } diff --git a/Mage.Sets/src/mage/cards/a/AssassinsTrophy.java b/Mage.Sets/src/mage/cards/a/AssassinsTrophy.java index 829c6253fa..5bafb3999a 100644 --- a/Mage.Sets/src/mage/cards/a/AssassinsTrophy.java +++ b/Mage.Sets/src/mage/cards/a/AssassinsTrophy.java @@ -70,7 +70,7 @@ class AssassinsTrophyEffect extends OneShotEffect { @Override public boolean apply(Game game, Ability source) { - Permanent permanent = game.getPermanentOrLKIBattlefield(source.getFirstTarget()); + Permanent permanent = getTargetPointer().getFirstTargetPermanentOrLKI(game, source); if (permanent != null) { Player controller = game.getPlayer(permanent.getControllerId()); if (controller != null) { diff --git a/Mage.Sets/src/mage/cards/a/AvengerEnDal.java b/Mage.Sets/src/mage/cards/a/AvengerEnDal.java index 78d78ccd1e..aba9f96d53 100644 --- a/Mage.Sets/src/mage/cards/a/AvengerEnDal.java +++ b/Mage.Sets/src/mage/cards/a/AvengerEnDal.java @@ -70,7 +70,7 @@ class AvengerEnDalEffect extends OneShotEffect { @Override public boolean apply(Game game, Ability source) { - Permanent permanent = game.getPermanentOrLKIBattlefield(getTargetPointer().getFirst(game, source)); + Permanent permanent = getTargetPointer().getFirstTargetPermanentOrLKI(game, source); if (permanent != null) { Player player = game.getPlayer(permanent.getControllerId()); if (player != null) { diff --git a/Mage.Sets/src/mage/cards/b/BeastWithin.java b/Mage.Sets/src/mage/cards/b/BeastWithin.java index 72454f668e..4446cc0592 100644 --- a/Mage.Sets/src/mage/cards/b/BeastWithin.java +++ b/Mage.Sets/src/mage/cards/b/BeastWithin.java @@ -59,7 +59,7 @@ class BeastWithinEffect extends OneShotEffect { // If the permanent is an illegal target when Beast Within tries to resolve, the spell won’t resolve and none // of its effects will happen. The permanent’s controller won’t get a Beast token. // (2011-06-01) - Permanent permanent = game.getPermanentOrLKIBattlefield(getTargetPointer().getFirst(game, source)); // must use LKI + Permanent permanent = getTargetPointer().getFirstTargetPermanentOrLKI(game, source); // must use LKI if (permanent != null) { new BeastToken().putOntoBattlefield(1, game, source.getSourceId(), permanent.getControllerId()); } diff --git a/Mage.Sets/src/mage/cards/b/BellowingFiend.java b/Mage.Sets/src/mage/cards/b/BellowingFiend.java index 1e332e77b9..848f6afcfa 100644 --- a/Mage.Sets/src/mage/cards/b/BellowingFiend.java +++ b/Mage.Sets/src/mage/cards/b/BellowingFiend.java @@ -15,7 +15,6 @@ import mage.constants.SubType; import mage.game.Game; import mage.game.permanent.Permanent; import mage.players.Player; -import mage.target.targetpointer.FixedTarget; import java.util.UUID; @@ -69,7 +68,7 @@ class BellowingFiendEffect extends OneShotEffect { @Override public boolean apply(Game game, Ability source) { boolean applied = false; - Permanent damagedCreature = ((FixedTarget) targetPointer).getTargetedPermanentOrLKIBattlefield(game); + Permanent damagedCreature = getTargetPointer().getFirstTargetPermanentOrLKI(game, source); if (damagedCreature != null) { Player controller = game.getPlayer(damagedCreature.getControllerId()); if (controller != null) { diff --git a/Mage.Sets/src/mage/cards/b/BlastOfGenius.java b/Mage.Sets/src/mage/cards/b/BlastOfGenius.java index 30e0be5637..5fe18c9ded 100644 --- a/Mage.Sets/src/mage/cards/b/BlastOfGenius.java +++ b/Mage.Sets/src/mage/cards/b/BlastOfGenius.java @@ -1,5 +1,6 @@ package mage.cards.b; +import java.util.UUID; import mage.abilities.Ability; import mage.abilities.effects.OneShotEffect; import mage.cards.Card; @@ -13,8 +14,6 @@ import mage.players.Player; import mage.target.common.TargetAnyTarget; import mage.target.common.TargetDiscard; -import java.util.UUID; - /** * @author LevelX2 */ @@ -43,7 +42,7 @@ class BlastOfGeniusEffect extends OneShotEffect { public BlastOfGeniusEffect() { super(Outcome.Benefit); - this.staticText = "Choose any target. Draw three cards and discard a card. Blast of Genius deals damage equal to the converted mana cost of the discard card to that permanent or player"; + this.staticText = "Choose any target. Draw three cards and discard a card. {this} deals damage equal to the converted mana cost of the discard card to that permanent or player"; } public BlastOfGeniusEffect(final BlastOfGeniusEffect effect) { diff --git a/Mage.Sets/src/mage/cards/b/BlowflyInfestation.java b/Mage.Sets/src/mage/cards/b/BlowflyInfestation.java index 77782f57c3..7e0d0e41ab 100644 --- a/Mage.Sets/src/mage/cards/b/BlowflyInfestation.java +++ b/Mage.Sets/src/mage/cards/b/BlowflyInfestation.java @@ -1,4 +1,3 @@ - package mage.cards.b; import java.util.UUID; @@ -28,11 +27,11 @@ import mage.target.common.TargetCreaturePermanent; * */ public final class BlowflyInfestation extends CardImpl { - + private static final String rule = "Whenever a creature dies, if it had a -1/-1 counter on it, put a -1/-1 counter on target creature."; public BlowflyInfestation(UUID ownerId, CardSetInfo setInfo) { - super(ownerId,setInfo,new CardType[]{CardType.ENCHANTMENT},"{2}{B}"); + super(ownerId, setInfo, new CardType[]{CardType.ENCHANTMENT}, "{2}{B}"); //Whenever a creature dies, if it had a -1/-1 counter on it, put a -1/-1 counter on target creature. Effect effect = new BlowflyInfestationEffect(); @@ -61,7 +60,7 @@ class BlowflyInfestationCondition implements Condition { public boolean apply(Game game, Ability source) { for (Effect effect : source.getEffects()) { if (effect.getTargetPointer().getFirst(game, source) != null) { - permanent = game.getPermanentOrLKIBattlefield(effect.getTargetPointer().getFirst(game, source)); + permanent = effect.getTargetPointer().getFirstTargetPermanentOrLKI(game, source); } } if (permanent != null) { diff --git a/Mage.Sets/src/mage/cards/b/BombSquad.java b/Mage.Sets/src/mage/cards/b/BombSquad.java index 4d7216ca2d..6605a03513 100644 --- a/Mage.Sets/src/mage/cards/b/BombSquad.java +++ b/Mage.Sets/src/mage/cards/b/BombSquad.java @@ -94,7 +94,7 @@ class BombSquadTriggeredAbility extends TriggeredAbilityImpl { if (permanent != null && filter.match(permanent, game)) { if (4 <= permanent.getCounters(game).getCount(CounterType.FUSE)) { for (Effect effect : this.getEffects()) { - effect.setTargetPointer(new FixedTarget(permanent.getId())); + effect.setTargetPointer(new FixedTarget(permanent, game)); } return true; } diff --git a/Mage.Sets/src/mage/cards/b/BorosFuryShield.java b/Mage.Sets/src/mage/cards/b/BorosFuryShield.java index 9f15ea62fc..ea5b4233c3 100644 --- a/Mage.Sets/src/mage/cards/b/BorosFuryShield.java +++ b/Mage.Sets/src/mage/cards/b/BorosFuryShield.java @@ -1,5 +1,6 @@ package mage.cards.b; +import java.util.UUID; import mage.abilities.Ability; import mage.abilities.condition.common.ManaWasSpentCondition; import mage.abilities.decorator.ConditionalOneShotEffect; @@ -18,12 +19,11 @@ import mage.game.permanent.Permanent; import mage.players.Player; import mage.target.common.TargetCreaturePermanent; -import java.util.UUID; - /** * @author Dilnu */ public final class BorosFuryShield extends CardImpl { + private static final FilterAttackingOrBlockingCreature filter = new FilterAttackingOrBlockingCreature(); public BorosFuryShield(UUID ownerId, CardSetInfo setInfo) { @@ -49,6 +49,7 @@ public final class BorosFuryShield extends CardImpl { } static class BorosFuryShieldDamageEffect extends OneShotEffect { + BorosFuryShieldDamageEffect() { super(Outcome.Damage); staticText = "{this} deals damage to that creature's controller equal to the creature's power"; @@ -60,7 +61,7 @@ public final class BorosFuryShield extends CardImpl { @Override public boolean apply(Game game, Ability source) { - Permanent target = game.getPermanent(targetPointer.getFirst(game, source)); + Permanent target = getTargetPointer().getFirstTargetPermanentOrLKI(game, source); if (target != null) { Player player = game.getPlayer(target.getControllerId()); if (player != null) { diff --git a/Mage.Sets/src/mage/cards/b/BrambleSovereign.java b/Mage.Sets/src/mage/cards/b/BrambleSovereign.java index caa98f8bf6..33c4ae111a 100644 --- a/Mage.Sets/src/mage/cards/b/BrambleSovereign.java +++ b/Mage.Sets/src/mage/cards/b/BrambleSovereign.java @@ -1,4 +1,3 @@ - package mage.cards.b; import java.util.UUID; @@ -9,12 +8,12 @@ import mage.abilities.costs.mana.ManaCostsImpl; import mage.abilities.effects.OneShotEffect; import mage.abilities.effects.common.CreateTokenCopyTargetEffect; import mage.abilities.effects.common.DoIfCostPaid; -import mage.constants.SubType; import mage.cards.CardImpl; import mage.cards.CardSetInfo; import mage.constants.CardType; import mage.constants.Outcome; import mage.constants.SetTargetPointer; +import mage.constants.SubType; import mage.constants.Zone; import mage.filter.common.FilterCreaturePermanent; import mage.filter.predicate.Predicates; @@ -81,7 +80,7 @@ class BrambleSovereignEffect extends OneShotEffect { @Override public boolean apply(Game game, Ability source) { - Permanent permanent = game.getPermanentOrLKIBattlefield(this.getTargetPointer().getFirst(game, source)); + Permanent permanent = getTargetPointer().getFirstTargetPermanentOrLKI(game, source); if (permanent != null) { CreateTokenCopyTargetEffect effect = new CreateTokenCopyTargetEffect(permanent.getControllerId()); effect.setTargetPointer(targetPointer); diff --git a/Mage.Sets/src/mage/cards/b/BrokenVisage.java b/Mage.Sets/src/mage/cards/b/BrokenVisage.java index 3505018f22..519cad5aef 100644 --- a/Mage.Sets/src/mage/cards/b/BrokenVisage.java +++ b/Mage.Sets/src/mage/cards/b/BrokenVisage.java @@ -69,7 +69,7 @@ class BrokenVisageEffect extends OneShotEffect { @Override public boolean apply(Game game, Ability source) { - Permanent permanent = game.getPermanentOrLKIBattlefield(this.getTargetPointer().getFirst(game, source)); + Permanent permanent = getTargetPointer().getFirstTargetPermanentOrLKI(game, source); if (permanent != null) { permanent.destroy(source.getSourceId(), game, true); CreateTokenEffect effect = new CreateTokenEffect(new BrokenVisageSpiritToken(permanent.getPower().getValue(), permanent.getToughness().getValue())); diff --git a/Mage.Sets/src/mage/cards/c/CemeteryPuca.java b/Mage.Sets/src/mage/cards/c/CemeteryPuca.java index 37498a7238..3b70f6560f 100644 --- a/Mage.Sets/src/mage/cards/c/CemeteryPuca.java +++ b/Mage.Sets/src/mage/cards/c/CemeteryPuca.java @@ -1,4 +1,3 @@ - package mage.cards.c; import java.util.UUID; @@ -16,7 +15,6 @@ import mage.constants.CardType; import mage.constants.SubType; import mage.constants.Duration; import mage.constants.Outcome; -import mage.constants.Zone; import mage.filter.common.FilterCreaturePermanent; import mage.game.Game; import mage.game.permanent.Permanent; @@ -30,7 +28,7 @@ import mage.util.functions.EmptyApplyToPermanent; public final class CemeteryPuca extends CardImpl { public CemeteryPuca(UUID ownerId, CardSetInfo setInfo) { - super(ownerId,setInfo,new CardType[]{CardType.CREATURE},"{1}{U/B}{U/B}"); + super(ownerId, setInfo, new CardType[]{CardType.CREATURE}, "{1}{U/B}{U/B}"); this.subtype.add(SubType.SHAPESHIFTER); this.power = new MageInt(1); @@ -71,7 +69,7 @@ class CemeteryPucaEffect extends OneShotEffect { public boolean apply(Game game, Ability source) { Permanent copyToCreature = game.getPermanent(source.getSourceId()); if (copyToCreature != null) { - Permanent copyFromCreature = (Permanent) game.getLastKnownInformation(targetPointer.getFirst(game, source), Zone.BATTLEFIELD); + Permanent copyFromCreature = getTargetPointer().getFirstTargetPermanentOrLKI(game, source); if (copyFromCreature != null) { game.copyPermanent(Duration.WhileOnBattlefield, copyFromCreature, copyToCreature.getId(), source, new EmptyApplyToPermanent()); ContinuousEffect effect = new GainAbilityTargetEffect(new DiesCreatureTriggeredAbility(new DoIfCostPaid(new CemeteryPucaEffect(), new ManaCostsImpl("{1}")), false, new FilterCreaturePermanent("a creature"), true), Duration.WhileOnBattlefield); diff --git a/Mage.Sets/src/mage/cards/c/ChandraAcolyteOfFlame.java b/Mage.Sets/src/mage/cards/c/ChandraAcolyteOfFlame.java index 131bc23a7e..6187069669 100644 --- a/Mage.Sets/src/mage/cards/c/ChandraAcolyteOfFlame.java +++ b/Mage.Sets/src/mage/cards/c/ChandraAcolyteOfFlame.java @@ -147,7 +147,7 @@ class ChandraAcolyteOfFlameGraveyardEffect extends OneShotEffect { Card card = game.getCard(this.getTargetPointer().getFirst(game, source)); if (card != null) { ContinuousEffect effect = new ChandraAcolyteOfFlameCastFromGraveyardEffect(); - effect.setTargetPointer(new FixedTarget(card.getId(), card.getZoneChangeCounter(game))); + effect.setTargetPointer(new FixedTarget(card, game)); game.addEffect(effect, source); effect = new ChandraAcolyteOfFlameReplacementEffect(card.getId()); game.addEffect(effect, source); diff --git a/Mage.Sets/src/mage/cards/c/Chastise.java b/Mage.Sets/src/mage/cards/c/Chastise.java index 8a4d08e222..5bf683719e 100644 --- a/Mage.Sets/src/mage/cards/c/Chastise.java +++ b/Mage.Sets/src/mage/cards/c/Chastise.java @@ -58,7 +58,7 @@ class ChastiseEffect extends OneShotEffect { @Override public boolean apply(Game game, Ability source) { - Permanent permanent = game.getPermanentOrLKIBattlefield(this.getTargetPointer().getFirst(game, source)); + Permanent permanent = getTargetPointer().getFirstTargetPermanentOrLKI(game, source); if (permanent != null) { int power = permanent.getPower().getValue(); Player player = game.getPlayer(source.getControllerId()); diff --git a/Mage.Sets/src/mage/cards/c/CloudstoneCurio.java b/Mage.Sets/src/mage/cards/c/CloudstoneCurio.java index e684313621..23bf56bcd2 100644 --- a/Mage.Sets/src/mage/cards/c/CloudstoneCurio.java +++ b/Mage.Sets/src/mage/cards/c/CloudstoneCurio.java @@ -1,4 +1,3 @@ - package mage.cards.c; import mage.abilities.Ability; @@ -14,7 +13,6 @@ import mage.game.Game; import mage.game.permanent.Permanent; import mage.players.Player; import mage.target.TargetPermanent; -import mage.target.targetpointer.FixedTarget; import java.util.UUID; import java.util.stream.Collectors; @@ -69,10 +67,7 @@ class CloudstoneCurioEffect extends OneShotEffect { public boolean apply(Game game, Ability source) { Player controller = game.getPlayer(source.getControllerId()); if (controller != null) { - Permanent triggeringCreature = ((FixedTarget) getTargetPointer()).getTargetedPermanentOrLKIBattlefield(game); - if (triggeringCreature == null) { - triggeringCreature = (Permanent) game.getLastKnownInformation(getTargetPointer().getFirst(game, source), Zone.BATTLEFIELD); - } + Permanent triggeringCreature = getTargetPointer().getFirstTargetPermanentOrLKI(game, source); if (triggeringCreature != null) { FilterPermanent filter = new FilterPermanent("another permanent you control that shares a permanent type with " + triggeringCreature.getName()); filter.add(Predicates.not(new PermanentIdPredicate(triggeringCreature.getId()))); diff --git a/Mage.Sets/src/mage/cards/c/ConsumingVapors.java b/Mage.Sets/src/mage/cards/c/ConsumingVapors.java index 6653e4a7e5..61d9fbd7fa 100644 --- a/Mage.Sets/src/mage/cards/c/ConsumingVapors.java +++ b/Mage.Sets/src/mage/cards/c/ConsumingVapors.java @@ -1,4 +1,3 @@ - package mage.cards.c; import java.util.UUID; @@ -23,11 +22,8 @@ import mage.target.common.TargetControlledPermanent; */ public final class ConsumingVapors extends CardImpl { - - public ConsumingVapors(UUID ownerId, CardSetInfo setInfo) { - super(ownerId,setInfo,new CardType[]{CardType.SORCERY},"{3}{B}"); - + super(ownerId, setInfo, new CardType[]{CardType.SORCERY}, "{3}{B}"); // Target player sacrifices a creature. You gain life equal to that creature's toughness. this.getSpellAbility().addEffect(new ConsumingVaporsEffect()); @@ -49,12 +45,12 @@ public final class ConsumingVapors extends CardImpl { class ConsumingVaporsEffect extends OneShotEffect { - ConsumingVaporsEffect ( ) { + ConsumingVaporsEffect() { super(Outcome.Sacrifice); staticText = "Target player sacrifices a creature. You gain life equal to that creature's toughness"; } - ConsumingVaporsEffect ( ConsumingVaporsEffect effect ) { + ConsumingVaporsEffect(ConsumingVaporsEffect effect) { super(effect); } @@ -68,15 +64,13 @@ class ConsumingVaporsEffect extends OneShotEffect { filter.add(TargetController.YOU.getControllerPredicate()); TargetControlledPermanent target = new TargetControlledPermanent(1, 1, filter, true); - //A spell or ability could have removed the only legal target this player - //had, if thats the case this ability should fizzle. if (player != null && target.canChoose(player.getId(), game)) { player.choose(Outcome.Sacrifice, target, source.getSourceId(), game); Permanent permanent = game.getPermanent(target.getFirstTarget()); - if ( permanent != null ) { + if (permanent != null) { + permanent.sacrifice(source.getSourceId(), game); controller.gainLife(permanent.getToughness().getValue(), game, source); - return permanent.sacrifice(source.getSourceId(), game); } return true; } diff --git a/Mage.Sets/src/mage/cards/c/CoordinatedBarrage.java b/Mage.Sets/src/mage/cards/c/CoordinatedBarrage.java index 33c621edc5..b2d04a8993 100644 --- a/Mage.Sets/src/mage/cards/c/CoordinatedBarrage.java +++ b/Mage.Sets/src/mage/cards/c/CoordinatedBarrage.java @@ -1,6 +1,6 @@ - package mage.cards.c; +import java.util.UUID; import mage.abilities.Ability; import mage.abilities.effects.OneShotEffect; import mage.cards.CardImpl; @@ -16,8 +16,6 @@ import mage.game.permanent.Permanent; import mage.players.Player; import mage.target.common.TargetAttackingOrBlockingCreature; -import java.util.UUID; - /** * * @author emerald000 @@ -25,7 +23,7 @@ import java.util.UUID; public final class CoordinatedBarrage extends CardImpl { public CoordinatedBarrage(UUID ownerId, CardSetInfo setInfo) { - super(ownerId,setInfo,new CardType[]{CardType.INSTANT},"{W}"); + super(ownerId, setInfo, new CardType[]{CardType.INSTANT}, "{W}"); // Choose a creature type. Coordinated Barrage deals damage to target attacking or blocking creature equal to the number of permanents you control of the chosen type. this.getSpellAbility().addEffect(new CoordinatedBarrageEffect()); @@ -46,7 +44,7 @@ class CoordinatedBarrageEffect extends OneShotEffect { CoordinatedBarrageEffect() { super(Outcome.Damage); - this.staticText = "Choose a creature type. Coordinated Barrage deals damage to target attacking or blocking creature equal to the number of permanents you control of the chosen type"; + this.staticText = "Choose a creature type. {this} deals damage to target attacking or blocking creature equal to the number of permanents you control of the chosen type"; } CoordinatedBarrageEffect(final CoordinatedBarrageEffect effect) { diff --git a/Mage.Sets/src/mage/cards/c/CreamOfTheCrop.java b/Mage.Sets/src/mage/cards/c/CreamOfTheCrop.java index dbf1c4d519..c09d904c45 100644 --- a/Mage.Sets/src/mage/cards/c/CreamOfTheCrop.java +++ b/Mage.Sets/src/mage/cards/c/CreamOfTheCrop.java @@ -72,7 +72,7 @@ class CreamOfTheCropEffect extends OneShotEffect { @Override public boolean apply(Game game, Ability source) { Player controller = game.getPlayer(source.getControllerId()); - Permanent permanent = ((FixedTarget) getTargetPointer()).getTargetedPermanentOrLKIBattlefield(game); + Permanent permanent = getTargetPointer().getFirstTargetPermanentOrLKI(game, source); if (controller != null && permanent != null) { Cards cards = new CardsImpl(controller.getLibrary().getTopCards(game, permanent.getPower().getValue())); if (!cards.isEmpty()) { diff --git a/Mage.Sets/src/mage/cards/c/CribSwap.java b/Mage.Sets/src/mage/cards/c/CribSwap.java index b1388e1994..671bc13ae5 100644 --- a/Mage.Sets/src/mage/cards/c/CribSwap.java +++ b/Mage.Sets/src/mage/cards/c/CribSwap.java @@ -66,7 +66,7 @@ class CribSwapEffect extends OneShotEffect { public boolean apply(Game game, Ability source) { Player controller = game.getPlayer(source.getControllerId()); if (controller != null) { - Permanent targetCreature = game.getPermanentOrLKIBattlefield(this.getTargetPointer().getFirst(game, source)); + Permanent targetCreature = getTargetPointer().getFirstTargetPermanentOrLKI(game, source); if (targetCreature != null) { CribSwapShapeshifterWhiteToken token = new CribSwapShapeshifterWhiteToken(); return token.putOntoBattlefield(1, game, source.getSourceId(), targetCreature.getControllerId()); diff --git a/Mage.Sets/src/mage/cards/c/Crumble.java b/Mage.Sets/src/mage/cards/c/Crumble.java index 90ead36ee1..00fedafe61 100644 --- a/Mage.Sets/src/mage/cards/c/Crumble.java +++ b/Mage.Sets/src/mage/cards/c/Crumble.java @@ -1,5 +1,6 @@ package mage.cards.c; +import java.util.UUID; import mage.abilities.Ability; import mage.abilities.effects.OneShotEffect; import mage.abilities.effects.common.DestroyTargetEffect; @@ -12,8 +13,6 @@ import mage.game.permanent.Permanent; import mage.players.Player; import mage.target.common.TargetArtifactPermanent; -import java.util.UUID; - /** * @author fireshoes */ @@ -58,9 +57,7 @@ class CrumbleEffect extends OneShotEffect { @Override public boolean apply(Game game, Ability source) { - // If the target artifact becomes illegal before resolution, the player does not gain any life. - // (2004-10-04) - Permanent permanent = game.getPermanentOrLKIBattlefield(getTargetPointer().getFirst(game, source)); // must use LKI + Permanent permanent = getTargetPointer().getFirstTargetPermanentOrLKI(game, source); // must use LKI if (permanent != null) { int cost = permanent.getConvertedManaCost(); Player player = game.getPlayer(permanent.getControllerId()); diff --git a/Mage.Sets/src/mage/cards/d/DarettiScrapSavant.java b/Mage.Sets/src/mage/cards/d/DarettiScrapSavant.java index 294589fc0c..7f04fb3a77 100644 --- a/Mage.Sets/src/mage/cards/d/DarettiScrapSavant.java +++ b/Mage.Sets/src/mage/cards/d/DarettiScrapSavant.java @@ -154,7 +154,7 @@ class DarettiScrapSavantEffect extends OneShotEffect { Card card = game.getCard(getTargetPointer().getFirst(game, source)); if (card != null && game.getState().getZone(card.getId()) == Zone.GRAVEYARD) { Effect effect = new ReturnFromGraveyardToBattlefieldTargetEffect(); - effect.setTargetPointer(new FixedTarget(card.getId(), card.getZoneChangeCounter(game))); + effect.setTargetPointer(new FixedTarget(card, game)); effect.setText("return that card to the battlefield at the beginning of the next end step"); game.addDelayedTriggeredAbility(new AtTheBeginOfNextEndStepDelayedTriggeredAbility(Zone.COMMAND, effect, TargetController.ANY), source); return true; diff --git a/Mage.Sets/src/mage/cards/d/DarkDabbling.java b/Mage.Sets/src/mage/cards/d/DarkDabbling.java index 5d60a57d60..a336174ebe 100644 --- a/Mage.Sets/src/mage/cards/d/DarkDabbling.java +++ b/Mage.Sets/src/mage/cards/d/DarkDabbling.java @@ -66,7 +66,7 @@ class DarkDabblingEffect extends OneShotEffect { for (Permanent permanent : game.getBattlefield().getAllActivePermanents(StaticFilters.FILTER_PERMANENT_CREATURE, source.getControllerId(), game)) { if (!permanent.getId().equals(getTargetPointer().getFirst(game, source))) { RegenerateTargetEffect regenEffect = new RegenerateTargetEffect(); - regenEffect.setTargetPointer(new FixedTarget(permanent.getId())); + regenEffect.setTargetPointer(new FixedTarget(permanent, game)); game.addEffect(regenEffect, source); } } diff --git a/Mage.Sets/src/mage/cards/d/DarkImpostor.java b/Mage.Sets/src/mage/cards/d/DarkImpostor.java index 268e22d04a..412a01f2a2 100644 --- a/Mage.Sets/src/mage/cards/d/DarkImpostor.java +++ b/Mage.Sets/src/mage/cards/d/DarkImpostor.java @@ -72,7 +72,7 @@ class DarkImpostorExileTargetEffect extends OneShotEffect { @Override public boolean apply(Game game, Ability source) { - Permanent permanent = game.getPermanentOrLKIBattlefield(source.getFirstTarget()); + Permanent permanent = getTargetPointer().getFirstTargetPermanentOrLKI(game, source); MageObject sourceObject = source.getSourceObject(game); if (permanent != null) { permanent.moveToExile(null, null, source.getSourceId(), game); diff --git a/Mage.Sets/src/mage/cards/d/DazzlingReflection.java b/Mage.Sets/src/mage/cards/d/DazzlingReflection.java index c125dcfc32..01de779624 100644 --- a/Mage.Sets/src/mage/cards/d/DazzlingReflection.java +++ b/Mage.Sets/src/mage/cards/d/DazzlingReflection.java @@ -1,4 +1,3 @@ - package mage.cards.d; import java.util.UUID; @@ -25,7 +24,7 @@ import mage.target.targetpointer.FixedTarget; public final class DazzlingReflection extends CardImpl { public DazzlingReflection(UUID ownerId, CardSetInfo setInfo) { - super(ownerId,setInfo,new CardType[]{CardType.INSTANT},"{1}{W}"); + super(ownerId, setInfo, new CardType[]{CardType.INSTANT}, "{1}{W}"); // You gain life equal to target creature's power. The next time that creature would deal damage this turn, prevent that damage. getSpellAbility().addEffect(new DazzlingReflectionEffect()); @@ -62,12 +61,14 @@ class DazzlingReflectionEffect extends OneShotEffect { public boolean apply(Game game, Ability source) { Player controller = game.getPlayer(source.getControllerId()); if (controller != null) { - Permanent targetCreature = game.getPermanentOrLKIBattlefield(getTargetPointer().getFirst(game, source)); - controller.gainLife(targetCreature.getPower().getValue(), game, source); - ContinuousEffect effect = new DazzlingReflectionPreventEffect(); - effect.setTargetPointer(new FixedTarget(targetCreature, game)); - game.addEffect(effect, source); - return true; + Permanent targetCreature = getTargetPointer().getFirstTargetPermanentOrLKI(game, source); + if (targetCreature != null) { + controller.gainLife(targetCreature.getPower().getValue(), game, source); + ContinuousEffect effect = new DazzlingReflectionPreventEffect(); + effect.setTargetPointer(new FixedTarget(targetCreature, game)); + game.addEffect(effect, source); + return true; + } } return false; } diff --git a/Mage.Sets/src/mage/cards/d/Deadshot.java b/Mage.Sets/src/mage/cards/d/Deadshot.java index 88a3d88040..6e2db1af86 100644 --- a/Mage.Sets/src/mage/cards/d/Deadshot.java +++ b/Mage.Sets/src/mage/cards/d/Deadshot.java @@ -73,7 +73,7 @@ class DeadshotDamageEffect extends OneShotEffect { @Override public boolean apply(Game game, Ability source) { - Permanent ownCreature = game.getPermanentOrLKIBattlefield(source.getFirstTarget()); + Permanent ownCreature = getTargetPointer().getFirstTargetPermanentOrLKI(game, source); if (ownCreature != null) { int damage = ownCreature.getPower().getValue(); Permanent targetCreature = game.getPermanent(getTargetPointer().getFirst(game, source)); diff --git a/Mage.Sets/src/mage/cards/d/DecayingSoil.java b/Mage.Sets/src/mage/cards/d/DecayingSoil.java index 6e8c872d77..42318087da 100644 --- a/Mage.Sets/src/mage/cards/d/DecayingSoil.java +++ b/Mage.Sets/src/mage/cards/d/DecayingSoil.java @@ -101,7 +101,7 @@ class DecayingSoilTriggeredAbility extends TriggeredAbilityImpl { if (zEvent.isDiesEvent()) { Permanent permanent = (Permanent) game.getLastKnownInformation(event.getTargetId(), Zone.BATTLEFIELD); if (permanent != null && filter.match(permanent, this.getSourceId(), this.getControllerId(), game)) { - getEffects().get(0).setTargetPointer(new FixedTarget(permanent.getId())); + getEffects().get(0).setTargetPointer(new FixedTarget(permanent, game)); return true; } } diff --git a/Mage.Sets/src/mage/cards/d/DesecratedEarth.java b/Mage.Sets/src/mage/cards/d/DesecratedEarth.java index 43361ca127..0ffa994598 100644 --- a/Mage.Sets/src/mage/cards/d/DesecratedEarth.java +++ b/Mage.Sets/src/mage/cards/d/DesecratedEarth.java @@ -58,7 +58,7 @@ class DesecratedEarthEffect extends OneShotEffect { @Override public boolean apply(Game game, Ability source) { - Permanent permanent = game.getPermanentOrLKIBattlefield(getTargetPointer().getFirst(game, source)); + Permanent permanent = getTargetPointer().getFirstTargetPermanentOrLKI(game, source); if (permanent != null) { Player player = game.getPlayer(permanent.getControllerId()); if (player != null) { diff --git a/Mage.Sets/src/mage/cards/d/DestroyTheEvidence.java b/Mage.Sets/src/mage/cards/d/DestroyTheEvidence.java index 93820f75f0..7de58bdad8 100644 --- a/Mage.Sets/src/mage/cards/d/DestroyTheEvidence.java +++ b/Mage.Sets/src/mage/cards/d/DestroyTheEvidence.java @@ -59,7 +59,7 @@ class DestroyTheEvidenceEffect extends OneShotEffect { @Override public boolean apply(Game game, Ability source) { - Permanent landPermanent = game.getPermanentOrLKIBattlefield(getTargetPointer().getFirst(game, source)); + Permanent landPermanent = getTargetPointer().getFirstTargetPermanentOrLKI(game, source); if (landPermanent != null) { Player player = game.getPlayer(landPermanent.getControllerId()); if (player == null) { diff --git a/Mage.Sets/src/mage/cards/d/DevourInShadow.java b/Mage.Sets/src/mage/cards/d/DevourInShadow.java index 75dcbe367d..db3c330200 100644 --- a/Mage.Sets/src/mage/cards/d/DevourInShadow.java +++ b/Mage.Sets/src/mage/cards/d/DevourInShadow.java @@ -61,7 +61,7 @@ class DevourInShadowEffect extends OneShotEffect { @Override public boolean apply(Game game, Ability source) { Player player = game.getPlayer(source.getControllerId()); - Permanent target = game.getPermanentOrLKIBattlefield(this.getTargetPointer().getFirst(game, source)); + Permanent target = getTargetPointer().getFirstTargetPermanentOrLKI(game, source); if (player != null && target != null) { player.loseLife(target.getToughness().getValue(), game, false); return true; diff --git a/Mage.Sets/src/mage/cards/d/DraconicRoar.java b/Mage.Sets/src/mage/cards/d/DraconicRoar.java index b9baa020cf..b020519c61 100644 --- a/Mage.Sets/src/mage/cards/d/DraconicRoar.java +++ b/Mage.Sets/src/mage/cards/d/DraconicRoar.java @@ -92,7 +92,7 @@ class DraconicRoarEffect extends OneShotEffect { if (controller != null) { DragonOnTheBattlefieldWhileSpellWasCastWatcher watcher = game.getState().getWatcher(DragonOnTheBattlefieldWhileSpellWasCastWatcher.class); if (watcher != null && watcher.castWithConditionTrue(source.getId())) { - Permanent permanent = game.getPermanentOrLKIBattlefield(getTargetPointer().getFirst(game, source)); + Permanent permanent = getTargetPointer().getFirstTargetPermanentOrLKI(game, source); if (permanent != null) { Player player = game.getPlayer(permanent.getControllerId()); if (player != null) { diff --git a/Mage.Sets/src/mage/cards/d/DreadWight.java b/Mage.Sets/src/mage/cards/d/DreadWight.java index 9d7ace6d78..0483bcaebe 100644 --- a/Mage.Sets/src/mage/cards/d/DreadWight.java +++ b/Mage.Sets/src/mage/cards/d/DreadWight.java @@ -126,7 +126,7 @@ class DreadWightEffect extends OneShotEffect { if (permanent != null) { // add paralyzation counter Effect effect = new AddCountersTargetEffect(CounterType.PARALYZATION.createInstance()); - effect.setTargetPointer(new FixedTarget(permanent.getId())); + effect.setTargetPointer(new FixedTarget(permanent, game)); effect.apply(game, source); // tap permanent permanent.tap(game); @@ -146,7 +146,7 @@ class DreadWightEffect extends OneShotEffect { ability, Duration.WhileOnBattlefield); ability.setRuleVisible(true); - effect3.setTargetPointer(new FixedTarget(permanent.getId())); + effect3.setTargetPointer(new FixedTarget(permanent, game)); game.addEffect(effect3, source); // each gains 4: remove paralyzation counter Ability activatedAbility = new SimpleActivatedAbility( @@ -156,7 +156,7 @@ class DreadWightEffect extends OneShotEffect { ContinuousEffect effect4 = new GainAbilityTargetEffect( activatedAbility, Duration.WhileOnBattlefield); - effect4.setTargetPointer(new FixedTarget(permanent.getId())); + effect4.setTargetPointer(new FixedTarget(permanent, game)); game.addEffect(effect4, source); return true; } diff --git a/Mage.Sets/src/mage/cards/d/DreamCoat.java b/Mage.Sets/src/mage/cards/d/DreamCoat.java index ee5585f44b..3f88c6d44d 100644 --- a/Mage.Sets/src/mage/cards/d/DreamCoat.java +++ b/Mage.Sets/src/mage/cards/d/DreamCoat.java @@ -109,7 +109,7 @@ class BecomesColorOrColorsEnchantedEffect extends OneShotEffect { String colors = new String(sb); ObjectColor chosenColors = new ObjectColor(colors); ContinuousEffect effect = new BecomesColorTargetEffect(chosenColors, Duration.Custom); - effect.setTargetPointer(new FixedTarget(permanent.getId())); + effect.setTargetPointer(new FixedTarget(permanent, game)); game.addEffect(effect, source); return true; diff --git a/Mage.Sets/src/mage/cards/d/DualNature.java b/Mage.Sets/src/mage/cards/d/DualNature.java index 2105105790..7842ff9c64 100644 --- a/Mage.Sets/src/mage/cards/d/DualNature.java +++ b/Mage.Sets/src/mage/cards/d/DualNature.java @@ -86,7 +86,7 @@ class DualNatureCreateTokenEffect extends OneShotEffect { @Override public boolean apply(Game game, Ability source) { - Permanent permanent = game.getPermanentOrLKIBattlefield(this.getTargetPointer().getFirst(game, source)); + Permanent permanent = getTargetPointer().getFirstTargetPermanentOrLKI(game, source); if (permanent != null) { CreateTokenCopyTargetEffect effect = new CreateTokenCopyTargetEffect(permanent.getControllerId()); effect.setTargetPointer(targetPointer); @@ -127,7 +127,7 @@ class DualNatureCreatureLeavesEffect extends OneShotEffect { @Override public boolean apply(Game game, Ability source) { - Permanent creature = game.getPermanentOrLKIBattlefield(this.getTargetPointer().getFirst(game, source)); + Permanent creature = getTargetPointer().getFirstTargetPermanentOrLKI(game, source); if (creature != null) { FilterPermanent filter = new FilterPermanent(); filter.add(TokenPredicate.instance); diff --git a/Mage.Sets/src/mage/cards/e/EldraziMimic.java b/Mage.Sets/src/mage/cards/e/EldraziMimic.java index 657a7a8565..b3a2ed8129 100644 --- a/Mage.Sets/src/mage/cards/e/EldraziMimic.java +++ b/Mage.Sets/src/mage/cards/e/EldraziMimic.java @@ -73,7 +73,7 @@ class EldraziMimicEffect extends OneShotEffect { public boolean apply(Game game, Ability source) { Player controller = game.getPlayer(source.getControllerId()); if (controller != null) { - Permanent permanent = ((FixedTarget) getTargetPointer()).getTargetedPermanentOrLKIBattlefield(game); + Permanent permanent = getTargetPointer().getFirstTargetPermanentOrLKI(game, source); if (permanent != null) { ContinuousEffect effect = new SetPowerToughnessTargetEffect(permanent.getPower().getValue(), permanent.getToughness().getValue(), Duration.EndOfTurn); effect.setTargetPointer(new FixedTarget(source.getSourceId())); diff --git a/Mage.Sets/src/mage/cards/e/EnfysNest.java b/Mage.Sets/src/mage/cards/e/EnfysNest.java index a1c387a804..661b8856c6 100644 --- a/Mage.Sets/src/mage/cards/e/EnfysNest.java +++ b/Mage.Sets/src/mage/cards/e/EnfysNest.java @@ -65,7 +65,7 @@ class EnfysNestEffect extends ExileTargetEffect { @Override public boolean apply(Game game, Ability source) { - Permanent permanent = game.getPermanentOrLKIBattlefield(source.getFirstTarget()); + Permanent permanent = getTargetPointer().getFirstTargetPermanentOrLKI(game, source); if(permanent != null) { // you may exile target creature an opponent controls if(!super.apply(game, source)) { diff --git a/Mage.Sets/src/mage/cards/e/EngulfingSlagwurm.java b/Mage.Sets/src/mage/cards/e/EngulfingSlagwurm.java index 2ff0a9b403..2b7acd48cc 100644 --- a/Mage.Sets/src/mage/cards/e/EngulfingSlagwurm.java +++ b/Mage.Sets/src/mage/cards/e/EngulfingSlagwurm.java @@ -60,7 +60,7 @@ class EngulfingSlagwurmEffect extends OneShotEffect { @Override public boolean apply(Game game, Ability source) { Player controller = game.getPlayer(source.getControllerId()); - Permanent creature = game.getPermanentOrLKIBattlefield(this.getTargetPointer().getFirst(game, source)); + Permanent creature = getTargetPointer().getFirstTargetPermanentOrLKI(game, source); if (creature != null && controller != null) { controller.gainLife(creature.getPower().getValue(), game, source); } diff --git a/Mage.Sets/src/mage/cards/e/EyeOfSingularity.java b/Mage.Sets/src/mage/cards/e/EyeOfSingularity.java index c3ba613992..160ee560df 100644 --- a/Mage.Sets/src/mage/cards/e/EyeOfSingularity.java +++ b/Mage.Sets/src/mage/cards/e/EyeOfSingularity.java @@ -159,7 +159,7 @@ class EyeOfSingularityTriggeredEffect extends OneShotEffect { @Override public boolean apply(Game game, Ability source) { Map toDestroy = new HashMap<>(); - Permanent etbPermanent = game.getPermanentOrLKIBattlefield(getTargetPointer().getFirst(game, source)); + Permanent etbPermanent = getTargetPointer().getFirstTargetPermanentOrLKI(game, source); if (etbPermanent == null) { return false; diff --git a/Mage.Sets/src/mage/cards/f/FaerieArtisans.java b/Mage.Sets/src/mage/cards/f/FaerieArtisans.java index 8eb37e5af9..c9924321fb 100644 --- a/Mage.Sets/src/mage/cards/f/FaerieArtisans.java +++ b/Mage.Sets/src/mage/cards/f/FaerieArtisans.java @@ -1,5 +1,7 @@ package mage.cards.f; +import java.util.StringTokenizer; +import java.util.UUID; import mage.MageInt; import mage.abilities.Ability; import mage.abilities.common.EntersBattlefieldAllTriggeredAbility; @@ -19,9 +21,6 @@ import mage.game.permanent.Permanent; import mage.players.Player; import mage.target.targetpointer.FixedTarget; -import java.util.StringTokenizer; -import java.util.UUID; - /** * @author LevelX2 */ @@ -80,7 +79,7 @@ class FaerieArtisansEffect extends OneShotEffect { @Override public boolean apply(Game game, Ability source) { - Permanent permanentToCopy = game.getPermanentOrLKIBattlefield(targetPointer.getFixedTarget(game, source).getTarget()); + Permanent permanentToCopy = getTargetPointer().getFirstTargetPermanentOrLKI(game, source); Player controller = game.getPlayer(source.getControllerId()); if (controller != null && permanentToCopy != null) { CreateTokenCopyTargetEffect effect = new CreateTokenCopyTargetEffect(null, CardType.ARTIFACT, false); diff --git a/Mage.Sets/src/mage/cards/f/FelhideSpiritbinder.java b/Mage.Sets/src/mage/cards/f/FelhideSpiritbinder.java index 4b7c656183..291e56ad8b 100644 --- a/Mage.Sets/src/mage/cards/f/FelhideSpiritbinder.java +++ b/Mage.Sets/src/mage/cards/f/FelhideSpiritbinder.java @@ -78,7 +78,7 @@ class FelhideSpiritbinderEffect extends OneShotEffect { @Override public boolean apply(Game game, Ability source) { - Permanent permanent = game.getPermanentOrLKIBattlefield(source.getFirstTarget()); + Permanent permanent = getTargetPointer().getFirstTargetPermanentOrLKI(game, source); if (permanent != null) { CreateTokenCopyTargetEffect effect = new CreateTokenCopyTargetEffect(null, CardType.ENCHANTMENT, true); effect.setTargetPointer(getTargetPointer()); diff --git a/Mage.Sets/src/mage/cards/f/FellTheMighty.java b/Mage.Sets/src/mage/cards/f/FellTheMighty.java index a53a034e48..ac6085360b 100644 --- a/Mage.Sets/src/mage/cards/f/FellTheMighty.java +++ b/Mage.Sets/src/mage/cards/f/FellTheMighty.java @@ -58,7 +58,7 @@ class FellTheMightyEffect extends OneShotEffect { @Override public boolean apply(Game game, Ability source) { Player controller = game.getPlayer(source.getControllerId()); - Permanent targetCreature = game.getPermanentOrLKIBattlefield(source.getFirstTarget()); + Permanent targetCreature = getTargetPointer().getFirstTargetPermanentOrLKI(game, source); if (controller != null && targetCreature != null) { for (Permanent permanent : game.getBattlefield().getActivePermanents(StaticFilters.FILTER_PERMANENT_CREATURE, controller.getId(), source.getSourceId(), game)) { if (permanent.getPower().getValue() > targetCreature.getPower().getValue()) { diff --git a/Mage.Sets/src/mage/cards/f/FierceInvocation.java b/Mage.Sets/src/mage/cards/f/FierceInvocation.java index c50291390a..3b88a89853 100644 --- a/Mage.Sets/src/mage/cards/f/FierceInvocation.java +++ b/Mage.Sets/src/mage/cards/f/FierceInvocation.java @@ -67,7 +67,7 @@ class FierceInvocationEffect extends OneShotEffect { Permanent permanent = game.getPermanent(card.getId()); if (permanent != null) { Effect effect = new AddCountersTargetEffect(CounterType.P1P1.createInstance(2)); - effect.setTargetPointer(new FixedTarget(permanent.getId())); + effect.setTargetPointer(new FixedTarget(permanent, game)); return effect.apply(game, source); } } diff --git a/Mage.Sets/src/mage/cards/f/FightOrFlight.java b/Mage.Sets/src/mage/cards/f/FightOrFlight.java index 6e88e228ce..219d9d307e 100644 --- a/Mage.Sets/src/mage/cards/f/FightOrFlight.java +++ b/Mage.Sets/src/mage/cards/f/FightOrFlight.java @@ -95,7 +95,7 @@ class FightOrFlightEffect extends OneShotEffect { if (permanent != null) { RestrictionEffect effect = new CantAttackTargetEffect(Duration.EndOfTurn); effect.setText(""); - effect.setTargetPointer(new FixedTarget(permanent.getId())); + effect.setTargetPointer(new FixedTarget(permanent, game)); game.addEffect(effect, source); } } diff --git a/Mage.Sets/src/mage/cards/f/FlamerushRider.java b/Mage.Sets/src/mage/cards/f/FlamerushRider.java index be2c67e9fd..2596f076f6 100644 --- a/Mage.Sets/src/mage/cards/f/FlamerushRider.java +++ b/Mage.Sets/src/mage/cards/f/FlamerushRider.java @@ -84,7 +84,7 @@ class FlamerushRiderEffect extends OneShotEffect { @Override public boolean apply(Game game, Ability source) { Player controller = game.getPlayer(source.getControllerId()); - Permanent permanent = game.getPermanentOrLKIBattlefield(getTargetPointer().getFirst(game, source)); + Permanent permanent = getTargetPointer().getFirstTargetPermanentOrLKI(game, source); if (controller != null && permanent != null) { CreateTokenCopyTargetEffect effect = new CreateTokenCopyTargetEffect(source.getControllerId(), null, true, 1, true, true); effect.setTargetPointer(new FixedTarget(permanent, game)); diff --git a/Mage.Sets/src/mage/cards/f/FlameshadowConjuring.java b/Mage.Sets/src/mage/cards/f/FlameshadowConjuring.java index 9db0cd3935..2b87176bb7 100644 --- a/Mage.Sets/src/mage/cards/f/FlameshadowConjuring.java +++ b/Mage.Sets/src/mage/cards/f/FlameshadowConjuring.java @@ -77,7 +77,7 @@ class FlameshadowConjuringEffect extends OneShotEffect { @Override public boolean apply(Game game, Ability source) { - Permanent permanent = ((FixedTarget) getTargetPointer()).getTargetedPermanentOrLKIBattlefield(game); + Permanent permanent = getTargetPointer().getFirstTargetPermanentOrLKI(game, source); if (permanent != null) { CreateTokenCopyTargetEffect effect = new CreateTokenCopyTargetEffect(null, null, true); effect.setTargetPointer(getTargetPointer()); diff --git a/Mage.Sets/src/mage/cards/f/FlayedNim.java b/Mage.Sets/src/mage/cards/f/FlayedNim.java index 336542943e..81c51ecdd1 100644 --- a/Mage.Sets/src/mage/cards/f/FlayedNim.java +++ b/Mage.Sets/src/mage/cards/f/FlayedNim.java @@ -67,7 +67,7 @@ class FlayedNimEffect extends OneShotEffect { @Override public boolean apply(Game game, Ability source) { - Permanent creature = ((FixedTarget) targetPointer).getTargetedPermanentOrLKIBattlefield(game); + Permanent creature = getTargetPointer().getFirstTargetPermanentOrLKI(game, source); if (creature == null) { return false; } diff --git a/Mage.Sets/src/mage/cards/f/FleshAllergy.java b/Mage.Sets/src/mage/cards/f/FleshAllergy.java index 7ac5f4227f..9134edaaf4 100644 --- a/Mage.Sets/src/mage/cards/f/FleshAllergy.java +++ b/Mage.Sets/src/mage/cards/f/FleshAllergy.java @@ -101,7 +101,7 @@ class FleshAllergyEffect extends OneShotEffect { @Override public boolean apply(Game game, Ability source) { FleshAllergyWatcher watcher = game.getState().getWatcher(FleshAllergyWatcher.class); - Permanent permanent = game.getPermanentOrLKIBattlefield(getTargetPointer().getFirst(game, source)); + Permanent permanent = getTargetPointer().getFirstTargetPermanentOrLKI(game, source); if (permanent != null && watcher != null) { Player player = game.getPlayer(permanent.getControllerId()); if (player != null) { diff --git a/Mage.Sets/src/mage/cards/f/ForceProjection.java b/Mage.Sets/src/mage/cards/f/ForceProjection.java index 6770afe6c7..d696d95331 100644 --- a/Mage.Sets/src/mage/cards/f/ForceProjection.java +++ b/Mage.Sets/src/mage/cards/f/ForceProjection.java @@ -68,7 +68,7 @@ class ForceProjectionEffect extends OneShotEffect { @Override public boolean apply(Game game, Ability source) { Player controller = game.getPlayer(source.getControllerId()); - Permanent permanent = game.getPermanentOrLKIBattlefield(getTargetPointer().getFirst(game, source)); + Permanent permanent = getTargetPointer().getFirstTargetPermanentOrLKI(game, source); if (controller != null && permanent != null) { // Create a token that is a copy of target creature CreateTokenCopyTargetEffect effect = new CreateTokenCopyTargetEffect(source.getControllerId(), null, true); diff --git a/Mage.Sets/src/mage/cards/f/FullMoonsRise.java b/Mage.Sets/src/mage/cards/f/FullMoonsRise.java index c1c0c06ebb..3093568217 100644 --- a/Mage.Sets/src/mage/cards/f/FullMoonsRise.java +++ b/Mage.Sets/src/mage/cards/f/FullMoonsRise.java @@ -82,7 +82,7 @@ class FullMoonsRiseEffect extends OneShotEffect { public boolean apply(Game game, Ability source) { for (Permanent permanent : game.getBattlefield().getAllActivePermanents(filter, source.getControllerId(), game)) { ReplacementEffect effect = new RegenerateTargetEffect(); - effect.setTargetPointer(new FixedTarget(permanent.getId())); + effect.setTargetPointer(new FixedTarget(permanent, game)); game.addEffect(effect, source); } return true; diff --git a/Mage.Sets/src/mage/cards/g/GarrukApexPredator.java b/Mage.Sets/src/mage/cards/g/GarrukApexPredator.java index 80a0d2e4c5..fa37f0f872 100644 --- a/Mage.Sets/src/mage/cards/g/GarrukApexPredator.java +++ b/Mage.Sets/src/mage/cards/g/GarrukApexPredator.java @@ -97,7 +97,7 @@ class GarrukApexPredatorEffect3 extends OneShotEffect { @Override public boolean apply(Game game, Ability source) { Player player = game.getPlayer(source.getControllerId()); - Permanent creature = game.getPermanentOrLKIBattlefield(getTargetPointer().getFirst(game, source)); + Permanent creature = getTargetPointer().getFirstTargetPermanentOrLKI(game, source); if (player != null && creature != null) { player.gainLife(creature.getToughness().getValue(), game, source); return true; diff --git a/Mage.Sets/src/mage/cards/g/GauntletOfPower.java b/Mage.Sets/src/mage/cards/g/GauntletOfPower.java index f3e4348683..ec7df62533 100644 --- a/Mage.Sets/src/mage/cards/g/GauntletOfPower.java +++ b/Mage.Sets/src/mage/cards/g/GauntletOfPower.java @@ -144,7 +144,7 @@ class GauntletOfPowerTapForManaAllTriggeredAbility extends TriggeredManaAbility } switch (setTargetPointer) { case PERMANENT: - getEffects().get(0).setTargetPointer(new FixedTarget(permanent.getId())); + getEffects().get(0).setTargetPointer(new FixedTarget(permanent, game)); break; case PLAYER: getEffects().get(0).setTargetPointer(new FixedTarget(permanent.getControllerId())); @@ -182,7 +182,7 @@ class GauntletOfPowerManaEffect2 extends ManaEffect { @Override public Player getPlayer(Game game, Ability source) { - Permanent land = game.getPermanentOrLKIBattlefield(getTargetPointer().getFirst(game, source)); + Permanent land = getTargetPointer().getFirstTargetPermanentOrLKI(game, source); if (land != null) { return game.getPlayer(land.getControllerId()); } @@ -204,7 +204,7 @@ class GauntletOfPowerManaEffect2 extends ManaEffect { @Override public Mana produceMana(Game game, Ability source) { if (game != null) { - Permanent land = game.getPermanentOrLKIBattlefield(getTargetPointer().getFirst(game, source)); + Permanent land = getTargetPointer().getFirstTargetPermanentOrLKI(game, source); if (land != null) { Mana mana = (Mana) getValue("mana"); if (mana != null) { diff --git a/Mage.Sets/src/mage/cards/g/GenesisChamber.java b/Mage.Sets/src/mage/cards/g/GenesisChamber.java index 5cee00b105..4cdb08d115 100644 --- a/Mage.Sets/src/mage/cards/g/GenesisChamber.java +++ b/Mage.Sets/src/mage/cards/g/GenesisChamber.java @@ -92,7 +92,7 @@ class GenesisChamberEffect extends OneShotEffect { @Override public boolean apply(Game game, Ability source) { - Permanent permanent = ((FixedTarget) targetPointer).getTargetedPermanentOrLKIBattlefield(game); + Permanent permanent = getTargetPointer().getFirstTargetPermanentOrLKI(game, source); if (permanent != null) { MyrToken token = new MyrToken(); token.putOntoBattlefield(1, game, source.getSourceId(), permanent.getControllerId()); diff --git a/Mage.Sets/src/mage/cards/g/GeomancersGambit.java b/Mage.Sets/src/mage/cards/g/GeomancersGambit.java index 3c5c47b580..e1bcac24d8 100644 --- a/Mage.Sets/src/mage/cards/g/GeomancersGambit.java +++ b/Mage.Sets/src/mage/cards/g/GeomancersGambit.java @@ -66,7 +66,7 @@ class GeomancersGambitEffect extends OneShotEffect { @Override public boolean apply(Game game, Ability source) { - Permanent permanent = game.getPermanentOrLKIBattlefield(source.getFirstTarget()); + Permanent permanent = getTargetPointer().getFirstTargetPermanentOrLKI(game, source); if (permanent == null) { return false; } diff --git a/Mage.Sets/src/mage/cards/g/GhostQuarter.java b/Mage.Sets/src/mage/cards/g/GhostQuarter.java index 881f2da242..0e394f2ad6 100644 --- a/Mage.Sets/src/mage/cards/g/GhostQuarter.java +++ b/Mage.Sets/src/mage/cards/g/GhostQuarter.java @@ -68,7 +68,7 @@ class GhostQuarterEffect extends OneShotEffect { @Override public boolean apply(Game game, Ability source) { - Permanent permanent = game.getPermanentOrLKIBattlefield(source.getFirstTarget()); + Permanent permanent = getTargetPointer().getFirstTargetPermanentOrLKI(game, source); if (permanent != null) { Player controller = game.getPlayer(permanent.getControllerId()); if (controller != null && controller.chooseUse(Outcome.PutLandInPlay, "Do you wish to search for a basic land, put it onto the battlefield and then shuffle your library?", source, game)) { diff --git a/Mage.Sets/src/mage/cards/g/Gloomlance.java b/Mage.Sets/src/mage/cards/g/Gloomlance.java index f7a42d9e08..dc16a34913 100644 --- a/Mage.Sets/src/mage/cards/g/Gloomlance.java +++ b/Mage.Sets/src/mage/cards/g/Gloomlance.java @@ -60,7 +60,7 @@ class GloomlanceEffect extends OneShotEffect { if (targetCreature != null) { Player targetController = game.getPlayer(targetCreature.getControllerId()); targetCreature.destroy(source.getSourceId(), game, false); - Permanent destroyedCreature = game.getPermanentOrLKIBattlefield(source.getFirstTarget()); + Permanent destroyedCreature = getTargetPointer().getFirstTargetPermanentOrLKI(game, source); if (destroyedCreature.getColor(game).isGreen() || destroyedCreature.getColor(game).isWhite()) { if(targetController != null) { diff --git a/Mage.Sets/src/mage/cards/g/GloomwidowsFeast.java b/Mage.Sets/src/mage/cards/g/GloomwidowsFeast.java index 3739a74863..e6622535df 100644 --- a/Mage.Sets/src/mage/cards/g/GloomwidowsFeast.java +++ b/Mage.Sets/src/mage/cards/g/GloomwidowsFeast.java @@ -71,7 +71,7 @@ class GloomwidowsFeastEffect extends OneShotEffect { Permanent targetCreature = game.getPermanent(source.getFirstTarget()); if (targetCreature != null) { targetCreature.destroy(source.getSourceId(), game, false); - Permanent destroyedCreature = game.getPermanentOrLKIBattlefield(source.getFirstTarget()); + Permanent destroyedCreature = getTargetPointer().getFirstTargetPermanentOrLKI(game, source); if (destroyedCreature.getColor(game).isBlue() || destroyedCreature.getColor(game).isBlack()) { SpiderToken token = new SpiderToken(); diff --git a/Mage.Sets/src/mage/cards/g/GlyphOfReincarnation.java b/Mage.Sets/src/mage/cards/g/GlyphOfReincarnation.java index 349ab923be..410741c12b 100644 --- a/Mage.Sets/src/mage/cards/g/GlyphOfReincarnation.java +++ b/Mage.Sets/src/mage/cards/g/GlyphOfReincarnation.java @@ -80,7 +80,7 @@ class GlyphOfReincarnationEffect extends OneShotEffect { @Override public boolean apply(Game game, Ability source) { Player controller = game.getPlayer(source.getControllerId()); - Permanent targetWall = game.getPermanentOrLKIBattlefield(source.getFirstTarget()); + Permanent targetWall = getTargetPointer().getFirstTargetPermanentOrLKI(game, source); if (controller != null && targetWall != null) { BlockedAttackerWatcher watcher = game.getState().getWatcher(BlockedAttackerWatcher.class); if (watcher != null) { diff --git a/Mage.Sets/src/mage/cards/g/GoblinTinkerer.java b/Mage.Sets/src/mage/cards/g/GoblinTinkerer.java index d16991a09b..98604a8c2e 100644 --- a/Mage.Sets/src/mage/cards/g/GoblinTinkerer.java +++ b/Mage.Sets/src/mage/cards/g/GoblinTinkerer.java @@ -71,7 +71,7 @@ class GoblinTinkererDamageEffect extends OneShotEffect { @Override public boolean apply(Game game, Ability source) { Player controller = game.getPlayer(source.getControllerId()); - Permanent targetArtifact = game.getPermanentOrLKIBattlefield(getTargetPointer().getFirst(game, source)); + Permanent targetArtifact = getTargetPointer().getFirstTargetPermanentOrLKI(game, source); if (controller != null && targetArtifact != null) { Permanent sourceObject = game.getPermanent(source.getSourceId()); int damage = targetArtifact.getConvertedManaCost(); diff --git a/Mage.Sets/src/mage/cards/g/GraveBetrayal.java b/Mage.Sets/src/mage/cards/g/GraveBetrayal.java index fb1ccc708a..21ad036129 100644 --- a/Mage.Sets/src/mage/cards/g/GraveBetrayal.java +++ b/Mage.Sets/src/mage/cards/g/GraveBetrayal.java @@ -79,7 +79,7 @@ class GraveBetrayalTriggeredAbility extends TriggeredAbilityImpl { Card card = (Card) game.getObject(permanent.getId()); if (card != null) { Effect effect = new GraveBetrayalEffect(); - effect.setTargetPointer(new FixedTarget(card.getId(), card.getZoneChangeCounter(game))); + effect.setTargetPointer(new FixedTarget(card, game)); DelayedTriggeredAbility delayedAbility = new AtTheBeginOfNextEndStepDelayedTriggeredAbility(effect); game.addDelayedTriggeredAbility(delayedAbility, this); return true; diff --git a/Mage.Sets/src/mage/cards/g/GraviticPunch.java b/Mage.Sets/src/mage/cards/g/GraviticPunch.java index 41344214d2..ee8559365b 100644 --- a/Mage.Sets/src/mage/cards/g/GraviticPunch.java +++ b/Mage.Sets/src/mage/cards/g/GraviticPunch.java @@ -62,7 +62,7 @@ class GraviticPunchEffect extends OneShotEffect { @Override public boolean apply(Game game, Ability source) { - Permanent controlledCreature = game.getPermanentOrLKIBattlefield(getTargetPointer().getFirst(game, source)); + Permanent controlledCreature = getTargetPointer().getFirstTargetPermanentOrLKI(game, source); Player player = game.getPlayer(source.getTargets().get(1).getFirstTarget()); if (player == null || controlledCreature == null) { return false; diff --git a/Mage.Sets/src/mage/cards/g/GreaterWerewolf.java b/Mage.Sets/src/mage/cards/g/GreaterWerewolf.java index 5c05d3c4be..6022daf232 100644 --- a/Mage.Sets/src/mage/cards/g/GreaterWerewolf.java +++ b/Mage.Sets/src/mage/cards/g/GreaterWerewolf.java @@ -72,7 +72,7 @@ class GreaterWerewolfEffect extends OneShotEffect { filter.add(Predicates.or(new BlockedByIdPredicate(sourcePermanent.getId()), new BlockingAttackerIdPredicate(sourcePermanent.getId()))); for (Permanent permanent : game.getBattlefield().getAllActivePermanents(filter, game)) { Effect effect = new AddCountersTargetEffect(new BoostCounter(0, -2), Outcome.UnboostCreature); - effect.setTargetPointer(new FixedTarget(permanent.getId())); + effect.setTargetPointer(new FixedTarget(permanent, game)); effect.apply(game, source); } return true; diff --git a/Mage.Sets/src/mage/cards/g/GrimFeast.java b/Mage.Sets/src/mage/cards/g/GrimFeast.java index 57abc08d14..5b4c07864d 100644 --- a/Mage.Sets/src/mage/cards/g/GrimFeast.java +++ b/Mage.Sets/src/mage/cards/g/GrimFeast.java @@ -91,7 +91,7 @@ class GrimFeastEffect extends OneShotEffect { @Override public boolean apply(Game game, Ability source) { - Permanent creature = ((FixedTarget) targetPointer).getTargetedPermanentOrLKIBattlefield(game); + Permanent creature = getTargetPointer().getFirstTargetPermanentOrLKI(game, source); if (creature == null) { return false; } diff --git a/Mage.Sets/src/mage/cards/g/GrislySpectacle.java b/Mage.Sets/src/mage/cards/g/GrislySpectacle.java index c2d21bb0d5..13cd075001 100644 --- a/Mage.Sets/src/mage/cards/g/GrislySpectacle.java +++ b/Mage.Sets/src/mage/cards/g/GrislySpectacle.java @@ -68,7 +68,7 @@ class GrislySpectacleEffect extends OneShotEffect { @Override public boolean apply(Game game, Ability source) { - Permanent creature = game.getPermanentOrLKIBattlefield(this.getTargetPointer().getFirst(game, source)); + Permanent creature = getTargetPointer().getFirstTargetPermanentOrLKI(game, source); if (creature != null) { Player controller = game.getPlayer(creature.getControllerId()); if (controller != null) { diff --git a/Mage.Sets/src/mage/cards/g/GuardDogs.java b/Mage.Sets/src/mage/cards/g/GuardDogs.java index 30fe2c42ee..f642ea67d7 100644 --- a/Mage.Sets/src/mage/cards/g/GuardDogs.java +++ b/Mage.Sets/src/mage/cards/g/GuardDogs.java @@ -86,7 +86,7 @@ class GuardDogsEffect extends PreventionEffectImpl { if (mageObject != null && controlledTarget.getFirstTarget() != null) { Permanent permanent = game.getPermanentOrLKIBattlefield(controlledTarget.getFirstTarget()); - Permanent targetPermanent = game.getPermanentOrLKIBattlefield(this.getTargetPointer().getFirst(game, source)); + Permanent targetPermanent = getTargetPointer().getFirstTargetPermanentOrLKI(game, source); if (permanent != null && targetPermanent != null && this.getTargetPointer().getTargets(game, source).contains(event.getSourceId()) diff --git a/Mage.Sets/src/mage/cards/g/GuardianOfTazeem.java b/Mage.Sets/src/mage/cards/g/GuardianOfTazeem.java index d020498187..b93d560868 100644 --- a/Mage.Sets/src/mage/cards/g/GuardianOfTazeem.java +++ b/Mage.Sets/src/mage/cards/g/GuardianOfTazeem.java @@ -119,7 +119,7 @@ class GuardianOfTazeemEffect extends OneShotEffect { @Override public boolean apply(Game game, Ability source) { - Permanent land = game.getPermanentOrLKIBattlefield(getTargetPointer().getFirst(game, source)); + Permanent land = getTargetPointer().getFirstTargetPermanentOrLKI(game, source); Permanent targetCreature = game.getPermanent(source.getFirstTarget()); if (land != null && targetCreature != null && land.hasSubtype(SubType.ISLAND, game)) { ContinuousEffect effect = new DontUntapInControllersNextUntapStepTargetEffect("that creature"); diff --git a/Mage.Sets/src/mage/cards/g/GuulDrazOverseer.java b/Mage.Sets/src/mage/cards/g/GuulDrazOverseer.java index fafd74cf71..3c1af084cf 100644 --- a/Mage.Sets/src/mage/cards/g/GuulDrazOverseer.java +++ b/Mage.Sets/src/mage/cards/g/GuulDrazOverseer.java @@ -63,7 +63,7 @@ class GuulDrazOverseerEffect extends OneShotEffect { @Override public boolean apply(Game game, Ability source) { Player controller = game.getPlayer(source.getControllerId()); - Permanent land = game.getPermanentOrLKIBattlefield(getTargetPointer().getFirst(game, source)); + Permanent land = getTargetPointer().getFirstTargetPermanentOrLKI(game, source); if (controller != null && land != null) { int boost = 1; if (land.hasSubtype(SubType.SWAMP, game)) { diff --git a/Mage.Sets/src/mage/cards/g/GyrusWakerOfCorpses.java b/Mage.Sets/src/mage/cards/g/GyrusWakerOfCorpses.java index 00f97af202..eb5cf51177 100644 --- a/Mage.Sets/src/mage/cards/g/GyrusWakerOfCorpses.java +++ b/Mage.Sets/src/mage/cards/g/GyrusWakerOfCorpses.java @@ -99,7 +99,7 @@ class GyrusWakerOfCorpsesEffect extends OneShotEffect { } controller.moveCards(card, Zone.EXILED, source, game); CreateTokenCopyTargetEffect effect = new CreateTokenCopyTargetEffect(source.getControllerId(), null, true, 1, true, true); - effect.setTargetPointer(new FixedTarget(card.getId(), card.getZoneChangeCounter(game))); + effect.setTargetPointer(new FixedTarget(card, game)); effect.apply(game, source); for (Permanent addedToken : effect.getAddedPermanent()) { Effect exileEffect = new ExileTargetEffect(); diff --git a/Mage.Sets/src/mage/cards/h/HamletbackGoliath.java b/Mage.Sets/src/mage/cards/h/HamletbackGoliath.java index 7e868438ad..4de43f8c52 100644 --- a/Mage.Sets/src/mage/cards/h/HamletbackGoliath.java +++ b/Mage.Sets/src/mage/cards/h/HamletbackGoliath.java @@ -1,5 +1,6 @@ package mage.cards.h; +import java.util.UUID; import mage.MageInt; import mage.abilities.Ability; import mage.abilities.TriggeredAbilityImpl; @@ -18,9 +19,8 @@ import mage.game.events.GameEvent.EventType; import mage.game.permanent.Permanent; import mage.target.targetpointer.FixedTarget; -import java.util.UUID; - /** + * * @author jeffwadsworth */ public final class HamletbackGoliath extends CardImpl { @@ -74,7 +74,7 @@ class HamletbackGoliathTriggeredAbility extends TriggeredAbilityImpl { if (permanent != null && permanent.isCreature() && !(targetId.equals(this.getSourceId()))) { for (Effect effect : this.getEffects()) { - effect.setTargetPointer(new FixedTarget(event.getTargetId())); + effect.setTargetPointer(new FixedTarget(permanent, game)); } return true; } @@ -99,11 +99,8 @@ class HamletbackGoliathEffect extends OneShotEffect { @Override public boolean apply(Game game, Ability source) { - Permanent creature = game.getPermanent(targetPointer.getFirst(game, source)); + Permanent creature = getTargetPointer().getFirstTargetPermanentOrLKI(game, source); Permanent sourceObject = game.getPermanent(source.getSourceId()); - if (creature == null) { - creature = (Permanent) game.getLastKnownInformation(targetPointer.getFirst(game, source), Zone.BATTLEFIELD); - } if (creature != null && sourceObject != null) { sourceObject.addCounters(CounterType.P1P1.createInstance(creature.getPower().getValue()), source, game); } diff --git a/Mage.Sets/src/mage/cards/h/HealTheScars.java b/Mage.Sets/src/mage/cards/h/HealTheScars.java index 4c7a3423f0..6cb9b7a5d6 100644 --- a/Mage.Sets/src/mage/cards/h/HealTheScars.java +++ b/Mage.Sets/src/mage/cards/h/HealTheScars.java @@ -58,7 +58,7 @@ class HealTheScarsEffect extends OneShotEffect { @Override public boolean apply(Game game, Ability source) { - Permanent permanent = game.getPermanentOrLKIBattlefield(getTargetPointer().getFirst(game, source)); + Permanent permanent = getTargetPointer().getFirstTargetPermanentOrLKI(game, source); if (permanent != null) { Player player = game.getPlayer(source.getControllerId()); if (player != null) { diff --git a/Mage.Sets/src/mage/cards/h/HeatShimmer.java b/Mage.Sets/src/mage/cards/h/HeatShimmer.java index e0e8cb79ca..3c431549e1 100644 --- a/Mage.Sets/src/mage/cards/h/HeatShimmer.java +++ b/Mage.Sets/src/mage/cards/h/HeatShimmer.java @@ -61,7 +61,7 @@ class HeatShimmerEffect extends OneShotEffect { @Override public boolean apply(Game game, Ability source) { Player controller = game.getPlayer(source.getControllerId()); - Permanent permanent = game.getPermanentOrLKIBattlefield(getTargetPointer().getFirst(game, source)); + Permanent permanent = getTargetPointer().getFirstTargetPermanentOrLKI(game, source); if (controller != null && permanent != null) { CreateTokenCopyTargetEffect effect = new CreateTokenCopyTargetEffect(source.getControllerId(), null, true); diff --git a/Mage.Sets/src/mage/cards/h/HellkiteTyrant.java b/Mage.Sets/src/mage/cards/h/HellkiteTyrant.java index d39feaeecf..4bdf2470ab 100644 --- a/Mage.Sets/src/mage/cards/h/HellkiteTyrant.java +++ b/Mage.Sets/src/mage/cards/h/HellkiteTyrant.java @@ -101,7 +101,7 @@ class HellkiteTyrantEffect extends OneShotEffect { List permanents = game.getBattlefield().getActivePermanents(filter, source.getControllerId(), game); for (Permanent permanent : permanents) { ContinuousEffect effect = new HellkiteTyrantControlEffect(source.getControllerId()); - effect.setTargetPointer(new FixedTarget(permanent.getId())); + effect.setTargetPointer(new FixedTarget(permanent, game)); game.addEffect(effect, source); } return true; diff --git a/Mage.Sets/src/mage/cards/h/HeraldOfLeshrac.java b/Mage.Sets/src/mage/cards/h/HeraldOfLeshrac.java index ec94e92c5e..bd411af8e5 100644 --- a/Mage.Sets/src/mage/cards/h/HeraldOfLeshrac.java +++ b/Mage.Sets/src/mage/cards/h/HeraldOfLeshrac.java @@ -141,7 +141,7 @@ class HeraldOfLeshracLeavesEffect extends OneShotEffect { filter.add(new ControllerIdPredicate(source.getControllerId())); for (Permanent permanent : game.getBattlefield().getActivePermanents(filter, source.getControllerId(), source.getSourceId(), game)) { ContinuousEffect effect = new GainControlTargetEffect(Duration.EndOfGame, playerId); - effect.setTargetPointer(new FixedTarget(permanent.getId())); + effect.setTargetPointer(new FixedTarget(permanent, game)); game.addEffect(effect, source); } } diff --git a/Mage.Sets/src/mage/cards/h/Heroism.java b/Mage.Sets/src/mage/cards/h/Heroism.java index 85b7e04162..fd867fc861 100644 --- a/Mage.Sets/src/mage/cards/h/Heroism.java +++ b/Mage.Sets/src/mage/cards/h/Heroism.java @@ -107,7 +107,7 @@ class HeroismEffect extends OneShotEffect { for (Permanent permanent : permanentsToPrevent) { ContinuousEffect effect = new PreventDamageByTargetEffect(Duration.EndOfTurn, Integer.MAX_VALUE, true); - effect.setTargetPointer(new FixedTarget(permanent.getId())); + effect.setTargetPointer(new FixedTarget(permanent, game)); game.addEffect(effect, source); } return true; diff --git a/Mage.Sets/src/mage/cards/i/IdentityThief.java b/Mage.Sets/src/mage/cards/i/IdentityThief.java index 79cb1bd4f8..f50ea256cd 100644 --- a/Mage.Sets/src/mage/cards/i/IdentityThief.java +++ b/Mage.Sets/src/mage/cards/i/IdentityThief.java @@ -108,7 +108,7 @@ class IdentityThiefEffect extends OneShotEffect { @Override public boolean apply(Game game, Ability source) { - Permanent targetPermanent = game.getPermanentOrLKIBattlefield(source.getFirstTarget()); + Permanent targetPermanent = getTargetPointer().getFirstTargetPermanentOrLKI(game, source); Player controller = game.getPlayer(source.getControllerId()); Permanent sourcePermanent = game.getPermanentOrLKIBattlefield(source.getSourceId()); if (controller != null diff --git a/Mage.Sets/src/mage/cards/i/ImpelledGiant.java b/Mage.Sets/src/mage/cards/i/ImpelledGiant.java index 0baf4fff2c..d32858d470 100644 --- a/Mage.Sets/src/mage/cards/i/ImpelledGiant.java +++ b/Mage.Sets/src/mage/cards/i/ImpelledGiant.java @@ -1,7 +1,5 @@ - package mage.cards.i; -import java.util.List; import java.util.UUID; import mage.MageInt; import mage.ObjectColor; @@ -16,9 +14,9 @@ import mage.abilities.keyword.TrampleAbility; import mage.cards.CardImpl; import mage.cards.CardSetInfo; import mage.constants.CardType; -import mage.constants.SubType; import mage.constants.Duration; import mage.constants.Outcome; +import mage.constants.SubType; import mage.constants.Zone; import mage.filter.common.FilterControlledCreaturePermanent; import mage.filter.predicate.Predicates; @@ -45,7 +43,7 @@ public final class ImpelledGiant extends CardImpl { } public ImpelledGiant(UUID ownerId, CardSetInfo setInfo) { - super(ownerId,setInfo,new CardType[]{CardType.CREATURE},"{4}{R}{R}"); + super(ownerId, setInfo, new CardType[]{CardType.CREATURE}, "{4}{R}{R}"); this.subtype.add(SubType.GIANT); this.subtype.add(SubType.WARRIOR); @@ -87,13 +85,14 @@ class ImpelledGiantCost extends CostImpl { @Override public boolean pay(Ability ability, Game game, UUID sourceId, UUID controllerId, boolean noMana, Cost costToPay) { if (target.choose(Outcome.Tap, controllerId, sourceId, game)) { - for (UUID targetId: target.getTargets()) { + for (UUID targetId : target.getTargets()) { Permanent permanent = game.getPermanent(targetId); - if (permanent == null) + if (permanent == null) { return false; + } paid |= permanent.tap(game); for (Effect effect : ability.getEffects()) { - effect.setTargetPointer(new FixedTarget(permanent.getId())); + effect.setTargetPointer(new FixedTarget(permanent, game)); } } } @@ -110,10 +109,8 @@ class ImpelledGiantCost extends CostImpl { return new ImpelledGiantCost(this); } - } - class ImpelledGiantBoostEffect extends OneShotEffect { public ImpelledGiantBoostEffect() { @@ -128,7 +125,7 @@ class ImpelledGiantBoostEffect extends OneShotEffect { @Override public boolean apply(Game game, Ability source) { Permanent impelledGiant = game.getPermanent(source.getSourceId()); - Permanent tappedCreature = game.getPermanentOrLKIBattlefield(this.targetPointer.getFirst(game, source)); + Permanent tappedCreature = getTargetPointer().getFirstTargetPermanentOrLKI(game, source); if (tappedCreature != null && impelledGiant != null) { int amount = tappedCreature.getPower().getValue(); game.addEffect(new BoostSourceEffect(amount, 0, Duration.EndOfTurn), source); diff --git a/Mage.Sets/src/mage/cards/i/Imprison.java b/Mage.Sets/src/mage/cards/i/Imprison.java index 7f1b8c062b..b507ab20c4 100644 --- a/Mage.Sets/src/mage/cards/i/Imprison.java +++ b/Mage.Sets/src/mage/cards/i/Imprison.java @@ -141,7 +141,7 @@ class ImprisonUnblockEffect extends OneShotEffect { // Remove it from combat Effect effect = new RemoveFromCombatTargetEffect(); - effect.setTargetPointer(new FixedTarget(permanent.getId())); + effect.setTargetPointer(new FixedTarget(permanent, game)); effect.apply(game, source); // Make blocked creatures unblocked diff --git a/Mage.Sets/src/mage/cards/i/InallaArchmageRitualist.java b/Mage.Sets/src/mage/cards/i/InallaArchmageRitualist.java index 05917740bf..7e84b40142 100644 --- a/Mage.Sets/src/mage/cards/i/InallaArchmageRitualist.java +++ b/Mage.Sets/src/mage/cards/i/InallaArchmageRitualist.java @@ -110,7 +110,7 @@ class InallaArchmageRitualistEffect extends OneShotEffect { @Override public boolean apply(Game game, Ability source) { - Permanent permanent = ((FixedTarget) getTargetPointer()).getTargetedPermanentOrLKIBattlefield(game); + Permanent permanent = getTargetPointer().getFirstTargetPermanentOrLKI(game, source); if (permanent != null) { CreateTokenCopyTargetEffect effect = new CreateTokenCopyTargetEffect(null, null, true); effect.setTargetPointer(getTargetPointer()); diff --git a/Mage.Sets/src/mage/cards/i/IncubationIncongruity.java b/Mage.Sets/src/mage/cards/i/IncubationIncongruity.java index 17fa9b0850..18b1348157 100644 --- a/Mage.Sets/src/mage/cards/i/IncubationIncongruity.java +++ b/Mage.Sets/src/mage/cards/i/IncubationIncongruity.java @@ -74,7 +74,7 @@ class IncongruityEffect extends OneShotEffect { // If the target creature is an illegal target by the time Incongruity tries to resolve, the spell doesn’t resolve. // No player creates a Frog Lizard token. // (2019-01-25) - Permanent permanent = game.getPermanentOrLKIBattlefield(targetPointer.getFirst(game, source)); // must use LKI + Permanent permanent = getTargetPointer().getFirstTargetPermanentOrLKI(game, source); // must use LKI if (permanent != null) { FrogLizardToken token = new FrogLizardToken(); token.putOntoBattlefield(1, game, source.getSourceId(), permanent.getControllerId()); diff --git a/Mage.Sets/src/mage/cards/i/InfernalReckoning.java b/Mage.Sets/src/mage/cards/i/InfernalReckoning.java index de48593fe5..b7c90635ba 100644 --- a/Mage.Sets/src/mage/cards/i/InfernalReckoning.java +++ b/Mage.Sets/src/mage/cards/i/InfernalReckoning.java @@ -62,7 +62,7 @@ class InfernalJudgmentEffect extends OneShotEffect { @Override public boolean apply(Game game, Ability source) { - Permanent permanent = game.getPermanentOrLKIBattlefield(getTargetPointer().getFirst(game, source)); + Permanent permanent = getTargetPointer().getFirstTargetPermanentOrLKI(game, source); Player player = game.getPlayer(source.getControllerId()); if (permanent == null || player == null) { return false; diff --git a/Mage.Sets/src/mage/cards/j/JoragaInvocation.java b/Mage.Sets/src/mage/cards/j/JoragaInvocation.java index ae428a239c..d250f4f51b 100644 --- a/Mage.Sets/src/mage/cards/j/JoragaInvocation.java +++ b/Mage.Sets/src/mage/cards/j/JoragaInvocation.java @@ -65,7 +65,7 @@ class JoragaInvocationEffect extends OneShotEffect { if (controller != null) { for (Permanent permanent : game.getBattlefield().getAllActivePermanents(StaticFilters.FILTER_PERMANENT_CREATURE, game)) { ContinuousEffect effect = new MustBeBlockedByAtLeastOneTargetEffect(); - effect.setTargetPointer(new FixedTarget(permanent.getId())); + effect.setTargetPointer(new FixedTarget(permanent, game)); game.addEffect(effect, source); } return true; diff --git a/Mage.Sets/src/mage/cards/k/KeldonBattlewagon.java b/Mage.Sets/src/mage/cards/k/KeldonBattlewagon.java index 091a1b3292..ac7b16a92e 100644 --- a/Mage.Sets/src/mage/cards/k/KeldonBattlewagon.java +++ b/Mage.Sets/src/mage/cards/k/KeldonBattlewagon.java @@ -1,7 +1,5 @@ - package mage.cards.k; -import java.util.List; import java.util.UUID; import mage.MageInt; import mage.abilities.Ability; @@ -20,9 +18,9 @@ import mage.abilities.keyword.TrampleAbility; import mage.cards.CardImpl; import mage.cards.CardSetInfo; import mage.constants.CardType; -import mage.constants.SubType; import mage.constants.Duration; import mage.constants.Outcome; +import mage.constants.SubType; import mage.constants.Zone; import mage.filter.common.FilterControlledCreaturePermanent; import mage.filter.predicate.Predicates; @@ -39,12 +37,13 @@ import mage.target.targetpointer.FixedTarget; public final class KeldonBattlewagon extends CardImpl { private static final FilterControlledCreaturePermanent filter = new FilterControlledCreaturePermanent("an untapped creature you control"); + static { filter.add(Predicates.not(TappedPredicate.instance)); } public KeldonBattlewagon(UUID ownerId, CardSetInfo setInfo) { - super(ownerId,setInfo,new CardType[]{CardType.ARTIFACT,CardType.CREATURE},"{5}"); + super(ownerId, setInfo, new CardType[]{CardType.ARTIFACT, CardType.CREATURE}, "{5}"); this.subtype.add(SubType.JUGGERNAUT); this.power = new MageInt(0); this.toughness = new MageInt(3); @@ -90,13 +89,14 @@ class KeldonBattlewagonCost extends CostImpl { @Override public boolean pay(Ability ability, Game game, UUID sourceId, UUID controllerId, boolean noMana, Cost costToPay) { if (target.choose(Outcome.Tap, controllerId, sourceId, game)) { - for (UUID targetId: target.getTargets()) { + for (UUID targetId : target.getTargets()) { Permanent permanent = game.getPermanent(targetId); - if (permanent == null) + if (permanent == null) { return false; + } paid |= permanent.tap(game); for (Effect effect : ability.getEffects()) { - effect.setTargetPointer(new FixedTarget(permanent.getId())); + effect.setTargetPointer(new FixedTarget(permanent, game)); } } } @@ -128,7 +128,7 @@ class KeldonBattlewagonBoostEffect extends OneShotEffect { @Override public boolean apply(Game game, Ability source) { Permanent KeldonBattlewagon = game.getPermanent(source.getSourceId()); - Permanent tappedCreature = game.getPermanentOrLKIBattlefield(this.targetPointer.getFirst(game, source)); + Permanent tappedCreature = getTargetPointer().getFirstTargetPermanentOrLKI(game, source); if (tappedCreature != null && KeldonBattlewagon != null) { int amount = tappedCreature.getPower().getValue(); game.addEffect(new BoostSourceEffect(amount, 0, Duration.EndOfTurn), source); diff --git a/Mage.Sets/src/mage/cards/k/KikiJikiMirrorBreaker.java b/Mage.Sets/src/mage/cards/k/KikiJikiMirrorBreaker.java index 2122879c3e..12935d0415 100644 --- a/Mage.Sets/src/mage/cards/k/KikiJikiMirrorBreaker.java +++ b/Mage.Sets/src/mage/cards/k/KikiJikiMirrorBreaker.java @@ -83,7 +83,7 @@ class KikiJikiMirrorBreakerEffect extends OneShotEffect { @Override public boolean apply(Game game, Ability source) { - Permanent permanent = game.getPermanentOrLKIBattlefield(source.getFirstTarget()); + Permanent permanent = getTargetPointer().getFirstTargetPermanentOrLKI(game, source); if (permanent != null) { CreateTokenCopyTargetEffect effect = new CreateTokenCopyTargetEffect(source.getControllerId(), null, true); effect.setTargetPointer(new FixedTarget(permanent, game)); diff --git a/Mage.Sets/src/mage/cards/k/KitsunePalliator.java b/Mage.Sets/src/mage/cards/k/KitsunePalliator.java index a905c0e62d..55f0d7112b 100644 --- a/Mage.Sets/src/mage/cards/k/KitsunePalliator.java +++ b/Mage.Sets/src/mage/cards/k/KitsunePalliator.java @@ -68,7 +68,7 @@ class KitsunePalliatorEffect extends OneShotEffect { List permanents = game.getBattlefield().getActivePermanents(StaticFilters.FILTER_PERMANENT_CREATURE, source.getControllerId(), game); for (Permanent permanent : permanents) { - effect.setTargetPointer(new FixedTarget(permanent.getId())); + effect.setTargetPointer(new FixedTarget(permanent, game)); game.addEffect(effect, source); } for (UUID playerId : game.getState().getPlayersInRange(source.getControllerId(), game)) { diff --git a/Mage.Sets/src/mage/cards/k/KreshTheBloodbraided.java b/Mage.Sets/src/mage/cards/k/KreshTheBloodbraided.java index 41dff62957..1eb4113608 100644 --- a/Mage.Sets/src/mage/cards/k/KreshTheBloodbraided.java +++ b/Mage.Sets/src/mage/cards/k/KreshTheBloodbraided.java @@ -1,4 +1,3 @@ - package mage.cards.k; import java.util.UUID; @@ -12,7 +11,6 @@ import mage.constants.CardType; import mage.constants.SubType; import mage.constants.Outcome; import mage.constants.SuperType; -import mage.constants.Zone; import mage.counters.CounterType; import mage.game.Game; import mage.game.permanent.Permanent; @@ -24,7 +22,7 @@ import mage.game.permanent.Permanent; public final class KreshTheBloodbraided extends CardImpl { public KreshTheBloodbraided(UUID ownerId, CardSetInfo setInfo) { - super(ownerId,setInfo,new CardType[]{CardType.CREATURE},"{2}{B}{R}{G}"); + super(ownerId, setInfo, new CardType[]{CardType.CREATURE}, "{2}{B}{R}{G}"); addSuperType(SuperType.LEGENDARY); this.subtype.add(SubType.HUMAN); this.subtype.add(SubType.WARRIOR); @@ -59,7 +57,7 @@ class KreshTheBloodbraidedEffect extends OneShotEffect { @Override public boolean apply(Game game, Ability source) { - Permanent permanent = (Permanent) game.getLastKnownInformation(targetPointer.getFirst(game, source), Zone.BATTLEFIELD); + Permanent permanent = getTargetPointer().getFirstTargetPermanentOrLKI(game, source); Permanent kreshTheBloodbraided = game.getPermanent(source.getSourceId()); if (permanent != null && kreshTheBloodbraided != null) { int amount = permanent.getPower().getValue(); diff --git a/Mage.Sets/src/mage/cards/l/LabyrinthRaptor.java b/Mage.Sets/src/mage/cards/l/LabyrinthRaptor.java index fd54137a03..0ad3bdccf8 100644 --- a/Mage.Sets/src/mage/cards/l/LabyrinthRaptor.java +++ b/Mage.Sets/src/mage/cards/l/LabyrinthRaptor.java @@ -92,7 +92,7 @@ class LabyrinthRaptorEffect extends OneShotEffect { @Override public boolean apply(Game game, Ability source) { - Permanent permanent = game.getPermanentOrLKIBattlefield(targetPointer.getFirst(game, source)); + Permanent permanent = getTargetPointer().getFirstTargetPermanentOrLKI(game, source); if (permanent == null) { return false; } diff --git a/Mage.Sets/src/mage/cards/l/LastBreath.java b/Mage.Sets/src/mage/cards/l/LastBreath.java index cc1fdf2727..02fc0d9ebe 100644 --- a/Mage.Sets/src/mage/cards/l/LastBreath.java +++ b/Mage.Sets/src/mage/cards/l/LastBreath.java @@ -1,4 +1,3 @@ - package mage.cards.l; import java.util.UUID; @@ -10,7 +9,6 @@ import mage.cards.CardSetInfo; import mage.constants.CardType; import mage.constants.ComparisonType; import mage.constants.Outcome; -import mage.constants.Zone; import mage.filter.common.FilterCreaturePermanent; import mage.filter.predicate.mageobject.PowerPredicate; import mage.game.Game; @@ -25,13 +23,13 @@ import mage.target.TargetPermanent; public final class LastBreath extends CardImpl { private static final FilterCreaturePermanent filter = new FilterCreaturePermanent("creature with power 2 or less"); + static { filter.add(new PowerPredicate(ComparisonType.FEWER_THAN, 3)); } public LastBreath(UUID ownerId, CardSetInfo setInfo) { - super(ownerId,setInfo,new CardType[]{CardType.INSTANT},"{1}{W}"); - + super(ownerId, setInfo, new CardType[]{CardType.INSTANT}, "{1}{W}"); // Exile target creature with power 2 or less. Its controller gains 4 life. this.getSpellAbility().addEffect(new ExileTargetEffect()); @@ -51,6 +49,7 @@ public final class LastBreath extends CardImpl { } class LastBreathEffect extends OneShotEffect { + LastBreathEffect() { super(Outcome.GainLife); staticText = "Its controller gains 4 life"; @@ -62,7 +61,7 @@ class LastBreathEffect extends OneShotEffect { @Override public boolean apply(Game game, Ability source) { - Permanent target = (Permanent) game.getLastKnownInformation(targetPointer.getFirst(game, source), Zone.BATTLEFIELD); + Permanent target = getTargetPointer().getFirstTargetPermanentOrLKI(game, source); if (target != null) { Player player = game.getPlayer(target.getControllerId()); if (player != null) { diff --git a/Mage.Sets/src/mage/cards/l/Lifeline.java b/Mage.Sets/src/mage/cards/l/Lifeline.java index 398aec314d..46d0d56e3c 100644 --- a/Mage.Sets/src/mage/cards/l/Lifeline.java +++ b/Mage.Sets/src/mage/cards/l/Lifeline.java @@ -67,7 +67,7 @@ class LifelineEffect extends OneShotEffect { Card card = game.getCard(getTargetPointer().getFirst(game, source)); if (card != null) { Effect effect = new ReturnToBattlefieldUnderOwnerControlTargetEffect(false, false); - effect.setTargetPointer(new FixedTarget(card.getId(), card.getZoneChangeCounter(game))); + effect.setTargetPointer(new FixedTarget(card, game)); effect.setText("return that card to the battlefield under it's owner's control at the beginning of the next end step"); game.addDelayedTriggeredAbility(new AtTheBeginOfNextEndStepDelayedTriggeredAbility(Zone.BATTLEFIELD, effect, TargetController.ANY), source); return true; diff --git a/Mage.Sets/src/mage/cards/m/ManaEchoes.java b/Mage.Sets/src/mage/cards/m/ManaEchoes.java index 0df24532a2..0e266ad925 100644 --- a/Mage.Sets/src/mage/cards/m/ManaEchoes.java +++ b/Mage.Sets/src/mage/cards/m/ManaEchoes.java @@ -61,7 +61,7 @@ class ManaEchoesEffect extends OneShotEffect { @Override public boolean apply(Game game, Ability source) { Player controller = game.getPlayer(source.getControllerId()); - Permanent permanent = game.getPermanentOrLKIBattlefield(getTargetPointer().getFirst(game, source)); + Permanent permanent = getTargetPointer().getFirstTargetPermanentOrLKI(game, source); if (controller != null && permanent != null) { int foundCreatures = 0; for (Permanent perm : game.getBattlefield().getAllActivePermanents(StaticFilters.FILTER_PERMANENT_CREATURE, source.getControllerId(), game)) { diff --git a/Mage.Sets/src/mage/cards/m/MartyrsBond.java b/Mage.Sets/src/mage/cards/m/MartyrsBond.java index 5461588c7b..31d5a450f5 100644 --- a/Mage.Sets/src/mage/cards/m/MartyrsBond.java +++ b/Mage.Sets/src/mage/cards/m/MartyrsBond.java @@ -75,7 +75,7 @@ class MartyrsBondTriggeredAbility extends TriggeredAbilityImpl { Permanent permanent = (Permanent) game.getLastKnownInformation(event.getTargetId(), Zone.BATTLEFIELD); if (permanent.isControlledBy(this.getControllerId()) && !permanent.isLand()) { for (Effect effect : this.getEffects()) { - effect.setTargetPointer(new FixedTarget(permanent.getId())); + effect.setTargetPointer(new FixedTarget(permanent, game)); } return true; } @@ -110,7 +110,7 @@ class MartyrsBondEffect extends OneShotEffect { public boolean apply(Game game, Ability source) { List perms = new ArrayList<>(); if (source != null) { - Permanent saccedPermanent = game.getPermanentOrLKIBattlefield(getTargetPointer().getFirst(game, source)); + Permanent saccedPermanent = getTargetPointer().getFirstTargetPermanentOrLKI(game, source); Player controller = game.getPlayer(source.getControllerId()); if (controller != null && saccedPermanent != null) { FilterControlledPermanent filter = new FilterControlledPermanent(); diff --git a/Mage.Sets/src/mage/cards/m/MasterWarcraft.java b/Mage.Sets/src/mage/cards/m/MasterWarcraft.java index be36268265..a436ebd0b8 100644 --- a/Mage.Sets/src/mage/cards/m/MasterWarcraft.java +++ b/Mage.Sets/src/mage/cards/m/MasterWarcraft.java @@ -168,7 +168,7 @@ class MasterWarcraftChooseAttackersEffect extends ContinuousRuleModifyingEffectI if (target.getTargets().contains(permanent.getId())) { RequirementEffect effect = new AttacksIfAbleTargetEffect(Duration.EndOfCombat); effect.setText(""); - effect.setTargetPointer(new FixedTarget(permanent.getId())); + effect.setTargetPointer(new FixedTarget(permanent, game)); game.addEffect(effect, source); game.informPlayers(controller.getLogName() + " has decided that " + permanent.getLogName() + " attacks this combat if able"); @@ -184,7 +184,7 @@ class MasterWarcraftChooseAttackersEffect extends ContinuousRuleModifyingEffectI if (!hasToAttack) { RestrictionEffect effect = new CantAttackTargetEffect(Duration.EndOfCombat); effect.setText(""); - effect.setTargetPointer(new FixedTarget(permanent.getId())); + effect.setTargetPointer(new FixedTarget(permanent, game)); game.addEffect(effect, source); } } diff --git a/Mage.Sets/src/mage/cards/m/MercyKilling.java b/Mage.Sets/src/mage/cards/m/MercyKilling.java index af41b4f1ff..57d825141d 100644 --- a/Mage.Sets/src/mage/cards/m/MercyKilling.java +++ b/Mage.Sets/src/mage/cards/m/MercyKilling.java @@ -56,7 +56,7 @@ class MercyKillingTokenEffect extends OneShotEffect { @Override public boolean apply(Game game, Ability source) { - Permanent permanent = game.getPermanentOrLKIBattlefield(getTargetPointer().getFirst(game, source)); + Permanent permanent = getTargetPointer().getFirstTargetPermanentOrLKI(game, source); if (permanent != null) { int power = permanent.getPower().getValue(); return new MercyKillingToken().putOntoBattlefield(power, game, source.getSourceId(), permanent.getControllerId()); diff --git a/Mage.Sets/src/mage/cards/m/Metamorphose.java b/Mage.Sets/src/mage/cards/m/Metamorphose.java index ab78e2ef56..ffb1e83314 100644 --- a/Mage.Sets/src/mage/cards/m/Metamorphose.java +++ b/Mage.Sets/src/mage/cards/m/Metamorphose.java @@ -74,7 +74,7 @@ class MetamorphoseEffect extends OneShotEffect { @Override public boolean apply(Game game, Ability source) { - Permanent permanent = game.getPermanentOrLKIBattlefield(source.getFirstTarget()); + Permanent permanent = getTargetPointer().getFirstTargetPermanentOrLKI(game, source); if (permanent != null) { Player controller = game.getPlayer(permanent.getControllerId()); if (controller != null && controller.canRespond() && controller.chooseUse(Outcome.PutCardInPlay, "Do you wish to put an artifact, creature, enchantment, or land card onto the battlefield?", source, game)) { diff --git a/Mage.Sets/src/mage/cards/m/MikaeusTheUnhallowed.java b/Mage.Sets/src/mage/cards/m/MikaeusTheUnhallowed.java index c42b1c8cdb..c10d4266d2 100644 --- a/Mage.Sets/src/mage/cards/m/MikaeusTheUnhallowed.java +++ b/Mage.Sets/src/mage/cards/m/MikaeusTheUnhallowed.java @@ -86,7 +86,7 @@ class MikaeusTheUnhallowedAbility extends TriggeredAbilityImpl { if (event.getTargetId().equals(this.controllerId)) { Permanent permanent = game.getPermanent(event.getSourceId()); if (permanent != null && permanent.hasSubtype(SubType.HUMAN, game)) { - this.getEffects().get(0).setTargetPointer(new FixedTarget(permanent.getId())); + this.getEffects().get(0).setTargetPointer(new FixedTarget(permanent, game)); return true; } } diff --git a/Mage.Sets/src/mage/cards/m/MimicVat.java b/Mage.Sets/src/mage/cards/m/MimicVat.java index 2e1d4bbfc4..f0ae7a737c 100644 --- a/Mage.Sets/src/mage/cards/m/MimicVat.java +++ b/Mage.Sets/src/mage/cards/m/MimicVat.java @@ -181,7 +181,7 @@ class MimicVatCreateTokenEffect extends OneShotEffect { Card card = game.getCard(permanent.getImprinted().get(0)); if (card != null) { CreateTokenCopyTargetEffect effect = new CreateTokenCopyTargetEffect(source.getControllerId(), null, true); - effect.setTargetPointer(new FixedTarget(card.getId(), card.getZoneChangeCounter(game))); + effect.setTargetPointer(new FixedTarget(card, game)); effect.apply(game, source); for (Permanent addedToken : effect.getAddedPermanent()) { ExileTargetEffect exileEffect = new ExileTargetEffect(); diff --git a/Mage.Sets/src/mage/cards/m/MinionReflector.java b/Mage.Sets/src/mage/cards/m/MinionReflector.java index 31da2e2881..a06489cf4c 100644 --- a/Mage.Sets/src/mage/cards/m/MinionReflector.java +++ b/Mage.Sets/src/mage/cards/m/MinionReflector.java @@ -83,7 +83,7 @@ class MinionReflectorEffect extends OneShotEffect { @Override public boolean apply(Game game, Ability source) { - Permanent permanent = game.getPermanentOrLKIBattlefield(this.getTargetPointer().getFirst(game, source)); + Permanent permanent = getTargetPointer().getFirstTargetPermanentOrLKI(game, source); if (permanent != null) { CreateTokenCopyTargetEffect effect = new CreateTokenCopyTargetEffect(source.getControllerId(), null, true); effect.setTargetPointer(new FixedTarget(permanent, game)); diff --git a/Mage.Sets/src/mage/cards/m/Mirrorweave.java b/Mage.Sets/src/mage/cards/m/Mirrorweave.java index 9be7608464..07c32b9a1f 100644 --- a/Mage.Sets/src/mage/cards/m/Mirrorweave.java +++ b/Mage.Sets/src/mage/cards/m/Mirrorweave.java @@ -72,7 +72,7 @@ class MirrorWeaveEffect extends OneShotEffect { FilterCreaturePermanent filter = new FilterCreaturePermanent(); if (controller != null) { - Permanent copyFromCreature = game.getPermanentOrLKIBattlefield(source.getFirstTarget()); + Permanent copyFromCreature = getTargetPointer().getFirstTargetPermanentOrLKI(game, source); if (copyFromCreature != null) { filter.add(Predicates.not(new PermanentIdPredicate(copyFromCreature.getId()))); for (Permanent copyToCreature : game.getBattlefield().getAllActivePermanents(filter, game)) { diff --git a/Mage.Sets/src/mage/cards/m/MistformSliver.java b/Mage.Sets/src/mage/cards/m/MistformSliver.java index d7de8a0b92..1e471dee58 100644 --- a/Mage.Sets/src/mage/cards/m/MistformSliver.java +++ b/Mage.Sets/src/mage/cards/m/MistformSliver.java @@ -72,7 +72,7 @@ class MistformSliverEffect extends OneShotEffect { } game.informPlayers(permanent.getName() + ": " + player.getLogName() + " has chosen " + typeChoice.getChoice()); ContinuousEffect effect = new AddCardSubTypeTargetEffect(SubType.byDescription(typeChoice.getChoice()), Duration.EndOfTurn); - effect.setTargetPointer(new FixedTarget(permanent.getId())); + effect.setTargetPointer(new FixedTarget(permanent, game)); game.addEffect(effect, source); } return false; diff --git a/Mage.Sets/src/mage/cards/m/MistformWakecaster.java b/Mage.Sets/src/mage/cards/m/MistformWakecaster.java index eca64b2369..62811464ae 100644 --- a/Mage.Sets/src/mage/cards/m/MistformWakecaster.java +++ b/Mage.Sets/src/mage/cards/m/MistformWakecaster.java @@ -93,7 +93,7 @@ class BecomesChosenCreatureTypeControlledEffect extends OneShotEffect { if (chosenType != null && !chosenType.isEmpty()) { for (Permanent permanent : game.getBattlefield().getAllActivePermanents(new FilterCreaturePermanent(), player.getId(), game)) { ContinuousEffect effect = new BecomesCreatureTypeTargetEffect(Duration.EndOfTurn, SubType.byDescription(chosenType)); - effect.setTargetPointer(new FixedTarget(permanent.getId())); + effect.setTargetPointer(new FixedTarget(permanent, game)); game.addEffect(effect, source); } return true; diff --git a/Mage.Sets/src/mage/cards/m/MoltenEchoes.java b/Mage.Sets/src/mage/cards/m/MoltenEchoes.java index a21876d3f2..446c6aab06 100644 --- a/Mage.Sets/src/mage/cards/m/MoltenEchoes.java +++ b/Mage.Sets/src/mage/cards/m/MoltenEchoes.java @@ -78,7 +78,7 @@ class MoltenEchoesEffect extends OneShotEffect { @Override public boolean apply(Game game, Ability source) { - Permanent permanent = ((FixedTarget) getTargetPointer()).getTargetedPermanentOrLKIBattlefield(game); + Permanent permanent = getTargetPointer().getFirstTargetPermanentOrLKI(game, source); if (permanent != null) { CreateTokenCopyTargetEffect effect = new CreateTokenCopyTargetEffect(null, null, true); effect.setTargetPointer(getTargetPointer()); diff --git a/Mage.Sets/src/mage/cards/m/MonkeyCage.java b/Mage.Sets/src/mage/cards/m/MonkeyCage.java index 4f33c49874..3342f74e5b 100644 --- a/Mage.Sets/src/mage/cards/m/MonkeyCage.java +++ b/Mage.Sets/src/mage/cards/m/MonkeyCage.java @@ -61,7 +61,7 @@ class MonkeyCageEffect extends OneShotEffect { } public boolean apply(Game game, Ability source) { - Permanent creature = game.getPermanentOrLKIBattlefield(getTargetPointer().getFirst(game, source)); + Permanent creature = getTargetPointer().getFirstTargetPermanentOrLKI(game, source); if (creature != null) { int cmc = creature.getConvertedManaCost(); return new CreateTokenEffect(new ApeToken(), cmc).apply(game, source); diff --git a/Mage.Sets/src/mage/cards/n/NaturesClaim.java b/Mage.Sets/src/mage/cards/n/NaturesClaim.java index ff65e52242..2358f9f13a 100644 --- a/Mage.Sets/src/mage/cards/n/NaturesClaim.java +++ b/Mage.Sets/src/mage/cards/n/NaturesClaim.java @@ -54,7 +54,7 @@ class NaturesClaimEffect extends OneShotEffect { @Override public boolean apply(Game game, Ability source) { - Permanent target = game.getPermanentOrLKIBattlefield(getTargetPointer().getFirst(game, source)); + Permanent target = getTargetPointer().getFirstTargetPermanentOrLKI(game, source); if (target != null) { Player player = game.getPlayer(target.getControllerId()); if (player != null) { diff --git a/Mage.Sets/src/mage/cards/n/Necropotence.java b/Mage.Sets/src/mage/cards/n/Necropotence.java index 3c1cc4bf28..107a5cae8a 100644 --- a/Mage.Sets/src/mage/cards/n/Necropotence.java +++ b/Mage.Sets/src/mage/cards/n/Necropotence.java @@ -119,7 +119,7 @@ class NecropotenceEffect extends OneShotEffect { card.setFaceDown(true, game); Effect returnToHandEffect = new ReturnToHandTargetEffect(); returnToHandEffect.setText("put that face down card into your hand"); - returnToHandEffect.setTargetPointer(new FixedTarget(card.getId(), card.getZoneChangeCounter(game))); + returnToHandEffect.setTargetPointer(new FixedTarget(card, game)); game.addDelayedTriggeredAbility(new AtTheBeginOfNextEndStepDelayedTriggeredAbility(returnToHandEffect, TargetController.YOU), source); return true; } diff --git a/Mage.Sets/src/mage/cards/n/NemesisTrap.java b/Mage.Sets/src/mage/cards/n/NemesisTrap.java index 3951249678..e930b75f3d 100644 --- a/Mage.Sets/src/mage/cards/n/NemesisTrap.java +++ b/Mage.Sets/src/mage/cards/n/NemesisTrap.java @@ -79,7 +79,7 @@ class NemesisTrapEffect extends OneShotEffect { @Override public boolean apply(Game game, Ability source) { - Permanent targetedCreature = game.getPermanentOrLKIBattlefield(source.getFirstTarget()); + Permanent targetedCreature = getTargetPointer().getFirstTargetPermanentOrLKI(game, source); Player controller = game.getPlayer(source.getControllerId()); if (controller != null && targetedCreature != null) { // exile target diff --git a/Mage.Sets/src/mage/cards/n/NiambiEsteemedSpeaker.java b/Mage.Sets/src/mage/cards/n/NiambiEsteemedSpeaker.java index 515650dbab..83a79d8d9e 100644 --- a/Mage.Sets/src/mage/cards/n/NiambiEsteemedSpeaker.java +++ b/Mage.Sets/src/mage/cards/n/NiambiEsteemedSpeaker.java @@ -98,7 +98,7 @@ class NiambiEsteemedSpeakerEffect extends OneShotEffect { @Override public boolean apply(Game game, Ability source) { - Permanent permanent = game.getPermanentOrLKIBattlefield(source.getFirstTarget()); + Permanent permanent = getTargetPointer().getFirstTargetPermanentOrLKI(game, source); Player player = game.getPlayer(source.getControllerId()); if (permanent == null || player == null) { return false; diff --git a/Mage.Sets/src/mage/cards/n/NimDeathmantle.java b/Mage.Sets/src/mage/cards/n/NimDeathmantle.java index 8815d4b752..005c8c843b 100644 --- a/Mage.Sets/src/mage/cards/n/NimDeathmantle.java +++ b/Mage.Sets/src/mage/cards/n/NimDeathmantle.java @@ -91,7 +91,7 @@ class NimDeathmantleTriggeredAbility extends TriggeredAbilityImpl { && !(permanent instanceof PermanentToken) && permanent.isCreature()) { - getEffects().get(0).setTargetPointer(new FixedTarget(permanent.getId())); + getEffects().get(0).setTargetPointer(new FixedTarget(permanent, game)); return true; } return false; diff --git a/Mage.Sets/src/mage/cards/o/OracleEnVec.java b/Mage.Sets/src/mage/cards/o/OracleEnVec.java index c3b9e8f6c3..2e64b202d9 100644 --- a/Mage.Sets/src/mage/cards/o/OracleEnVec.java +++ b/Mage.Sets/src/mage/cards/o/OracleEnVec.java @@ -89,11 +89,11 @@ class OracleEnVecEffect extends OneShotEffect { for (Permanent permanent : game.getBattlefield().getActivePermanents(new FilterControlledCreaturePermanent(), opponent.getId(), source.getSourceId(), game)) { if (target.getTargets().contains(permanent.getId())) { RequirementEffect effect = new OracleEnVecMustAttackRequirementEffect(); - effect.setTargetPointer(new FixedTarget(permanent.getId())); + effect.setTargetPointer(new FixedTarget(permanent, game)); game.addEffect(effect, source); } else { RestrictionEffect effect = new OracleEnVecCantAttackRestrictionEffect(); - effect.setTargetPointer(new FixedTarget(permanent.getId())); + effect.setTargetPointer(new FixedTarget(permanent, game)); game.addEffect(effect, source); } } diff --git a/Mage.Sets/src/mage/cards/o/OranRiefHydra.java b/Mage.Sets/src/mage/cards/o/OranRiefHydra.java index c07bba7147..7a4c0aa520 100644 --- a/Mage.Sets/src/mage/cards/o/OranRiefHydra.java +++ b/Mage.Sets/src/mage/cards/o/OranRiefHydra.java @@ -117,7 +117,7 @@ class OranRiefHydraEffect extends OneShotEffect { @Override public boolean apply(Game game, Ability source) { // the LKI of the land to verify the last-known land type - Permanent landLKI = game.getPermanentOrLKIBattlefield(getTargetPointer().getFirst(game, source)); + Permanent landLKI = getTargetPointer().getFirstTargetPermanentOrLKI(game, source); Permanent land = game.getPermanent(getTargetPointer().getFirst(game, source)); Permanent sourcePermanent = game.getPermanent(source.getSourceId()); // the land must be on the battlefield when the trigger resolves diff --git a/Mage.Sets/src/mage/cards/o/OrchardWarden.java b/Mage.Sets/src/mage/cards/o/OrchardWarden.java index 4888f45153..f773d5d122 100644 --- a/Mage.Sets/src/mage/cards/o/OrchardWarden.java +++ b/Mage.Sets/src/mage/cards/o/OrchardWarden.java @@ -68,7 +68,7 @@ class OrchardWardenffect extends OneShotEffect { @Override public boolean apply(Game game, Ability source) { Player controller = game.getPlayer(source.getControllerId()); - Permanent permanent = game.getPermanentOrLKIBattlefield(getTargetPointer().getFirst(game, source)); + Permanent permanent = getTargetPointer().getFirstTargetPermanentOrLKI(game, source); if (controller != null && permanent != null) { controller.gainLife(permanent.getToughness().getValue(), game, source); return true; diff --git a/Mage.Sets/src/mage/cards/o/OutpostSiege.java b/Mage.Sets/src/mage/cards/o/OutpostSiege.java index 4062fa1c78..61d2b18d12 100644 --- a/Mage.Sets/src/mage/cards/o/OutpostSiege.java +++ b/Mage.Sets/src/mage/cards/o/OutpostSiege.java @@ -99,7 +99,7 @@ class OutpostSiegeExileEffect extends OneShotEffect { controller.moveCardsToExile(card, source, game, true, source.getSourceId(), exileName); if (game.getState().getZone(card.getId()) == Zone.EXILED) { ContinuousEffect effect = new CastFromNonHandZoneTargetEffect(Duration.EndOfTurn); - effect.setTargetPointer(new FixedTarget(card.getId(), card.getZoneChangeCounter(game))); + effect.setTargetPointer(new FixedTarget(card, game)); game.addEffect(effect, source); } } diff --git a/Mage.Sets/src/mage/cards/o/OvergrowthElemental.java b/Mage.Sets/src/mage/cards/o/OvergrowthElemental.java index 7e1a00a040..3f8f14806a 100644 --- a/Mage.Sets/src/mage/cards/o/OvergrowthElemental.java +++ b/Mage.Sets/src/mage/cards/o/OvergrowthElemental.java @@ -86,7 +86,7 @@ class OvergrowthElementalEffect extends OneShotEffect { @Override public boolean apply(Game game, Ability source) { - Permanent permanent = game.getPermanentOrLKIBattlefield(targetPointer.getFirst(game, source)); + Permanent permanent = getTargetPointer().getFirstTargetPermanentOrLKI(game, source); if (permanent == null || !permanent.hasSubtype(SubType.ELEMENTAL, game)) { return false; } diff --git a/Mage.Sets/src/mage/cards/p/Pandemonium.java b/Mage.Sets/src/mage/cards/p/Pandemonium.java index a3b977b19c..f835bcdf11 100644 --- a/Mage.Sets/src/mage/cards/p/Pandemonium.java +++ b/Mage.Sets/src/mage/cards/p/Pandemonium.java @@ -80,7 +80,7 @@ class PandemoniumEffect extends OneShotEffect { public boolean apply(Game game, Ability source) { Player controller = game.getPlayer(source.getControllerId()); if (controller != null) { - Permanent enteringCreature = game.getPermanentOrLKIBattlefield(getTargetPointer().getFirst(game, source)); + Permanent enteringCreature = getTargetPointer().getFirstTargetPermanentOrLKI(game, source); if (enteringCreature != null) { Permanent targetPermanent = game.getPermanent(source.getTargets().getFirstTarget()); if (targetPermanent != null) { diff --git a/Mage.Sets/src/mage/cards/p/PeerPressure.java b/Mage.Sets/src/mage/cards/p/PeerPressure.java index cde6725dbf..2a130b8330 100644 --- a/Mage.Sets/src/mage/cards/p/PeerPressure.java +++ b/Mage.Sets/src/mage/cards/p/PeerPressure.java @@ -85,7 +85,7 @@ class PeerPressureEffect extends OneShotEffect { if (playerWithMost != null && playerWithMost.equals(controller.getId())) { for (Permanent permanent : game.getBattlefield().getActivePermanents(new FilterCreaturePermanent(SubType.byDescription(chosenType), chosenType), controller.getId(), source.getSourceId(), game)) { ContinuousEffect effect = new GainControlTargetEffect(Duration.EndOfGame); - effect.setTargetPointer(new FixedTarget(permanent.getId())); + effect.setTargetPointer(new FixedTarget(permanent, game)); game.addEffect(effect, source); } } diff --git a/Mage.Sets/src/mage/cards/p/PeltCollector.java b/Mage.Sets/src/mage/cards/p/PeltCollector.java index 7ef8ae3b5f..bd267e7b5b 100644 --- a/Mage.Sets/src/mage/cards/p/PeltCollector.java +++ b/Mage.Sets/src/mage/cards/p/PeltCollector.java @@ -135,7 +135,7 @@ class PeltCollectorEffect extends OneShotEffect { @Override public boolean apply(Game game, Ability source) { - Permanent triggeringCreature = game.getPermanentOrLKIBattlefield(getTargetPointer().getFirst(game, source)); + Permanent triggeringCreature = getTargetPointer().getFirstTargetPermanentOrLKI(game, source); Permanent sourceCreature = game.getPermanent(source.getSourceId()); if (!PeltCollectorAbility.isPowerGreater(sourceCreature, triggeringCreature)) { return false; diff --git a/Mage.Sets/src/mage/cards/p/PermeatingMass.java b/Mage.Sets/src/mage/cards/p/PermeatingMass.java index 286739e23c..3a08fd59e4 100644 --- a/Mage.Sets/src/mage/cards/p/PermeatingMass.java +++ b/Mage.Sets/src/mage/cards/p/PermeatingMass.java @@ -59,7 +59,7 @@ class PermeatingMassEffect extends OneShotEffect { @Override public boolean apply(Game game, Ability ability) { - Permanent copyTo = game.getPermanentOrLKIBattlefield(getTargetPointer().getFirst(game, ability)); + Permanent copyTo = game.getPermanent(getTargetPointer().getFirst(game, ability)); if (copyTo != null) { Permanent copyFrom = ability.getSourcePermanentOrLKI(game); if (copyFrom != null) { diff --git a/Mage.Sets/src/mage/cards/p/PistusStrike.java b/Mage.Sets/src/mage/cards/p/PistusStrike.java index 04992db9a4..7ffe18afc1 100644 --- a/Mage.Sets/src/mage/cards/p/PistusStrike.java +++ b/Mage.Sets/src/mage/cards/p/PistusStrike.java @@ -66,7 +66,7 @@ class PoisonControllerTargetCreatureEffect extends OneShotEffect { @Override public boolean apply(Game game, Ability source) { - Permanent permanent = game.getPermanentOrLKIBattlefield(getTargetPointer().getFirst(game, source)); + Permanent permanent = getTargetPointer().getFirstTargetPermanentOrLKI(game, source); if (permanent != null) { Player player = game.getPlayer(permanent.getControllerId()); if (player != null) { diff --git a/Mage.Sets/src/mage/cards/p/Polymorph.java b/Mage.Sets/src/mage/cards/p/Polymorph.java index 9e3a7446cf..addab1b2bf 100644 --- a/Mage.Sets/src/mage/cards/p/Polymorph.java +++ b/Mage.Sets/src/mage/cards/p/Polymorph.java @@ -64,7 +64,7 @@ class PolymorphEffect extends OneShotEffect { @Override public boolean apply(Game game, Ability source) { - Permanent permanent = game.getPermanentOrLKIBattlefield(getTargetPointer().getFirst(game, source)); + Permanent permanent = getTargetPointer().getFirstTargetPermanentOrLKI(game, source); if (permanent != null) { Player player = game.getPlayer(permanent.getControllerId()); if (player != null) { diff --git a/Mage.Sets/src/mage/cards/p/PowerLeak.java b/Mage.Sets/src/mage/cards/p/PowerLeak.java index 309ec4ec79..6d313dcf71 100644 --- a/Mage.Sets/src/mage/cards/p/PowerLeak.java +++ b/Mage.Sets/src/mage/cards/p/PowerLeak.java @@ -91,7 +91,7 @@ class PowerLeakEffect extends OneShotEffect { PreventDamageByTargetEffect effect = new PreventDamageByTargetEffect(Duration.OneUse, xValue, false); if (xValue != 0 && cost.isPaid()) { - effect.setTargetPointer(new FixedTarget(permanent.getId())); + effect.setTargetPointer(new FixedTarget(permanent, game)); game.addEffect(effect, source); } player.damage(2, source.getSourceId(), game); diff --git a/Mage.Sets/src/mage/cards/p/PriceOfGlory.java b/Mage.Sets/src/mage/cards/p/PriceOfGlory.java index 1fbc55a591..1e4c849cca 100644 --- a/Mage.Sets/src/mage/cards/p/PriceOfGlory.java +++ b/Mage.Sets/src/mage/cards/p/PriceOfGlory.java @@ -1,5 +1,6 @@ package mage.cards.p; +import java.util.UUID; import mage.abilities.Ability; import mage.abilities.TriggeredAbilityImpl; import mage.abilities.effects.OneShotEffect; @@ -15,8 +16,6 @@ import mage.game.permanent.Permanent; import mage.players.Player; import mage.target.targetpointer.FixedTarget; -import java.util.UUID; - /** * @author cbt33, Loki (Heartbeat of Spring) */ @@ -65,7 +64,7 @@ class PriceOfGloryAbility extends TriggeredAbilityImpl { if (permanent.isLand() && game.getState().getPlayersInRange(controllerId, game).contains(permanent.getControllerId()) && !permanent.isControlledBy(game.getActivePlayerId())) { // intervening if clause - getEffects().get(0).setTargetPointer(new FixedTarget(permanent.getId())); + getEffects().get(0).setTargetPointer(new FixedTarget(permanent, game)); return true; } return false; @@ -97,7 +96,7 @@ class PriceOfGloryEffect extends OneShotEffect { public boolean apply(Game game, Ability source) { Player controller = game.getPlayer(source.getControllerId()); if (controller != null) { - Permanent land = game.getPermanentOrLKIBattlefield(this.targetPointer.getFirst(game, source)); + Permanent land = game.getPermanent(getTargetPointer().getFirst(game, source)); if (land != null && !land.isControlledBy(game.getActivePlayerId())) { // intervening if clause has to be checked again land.destroy(source.getSourceId(), game, false); } diff --git a/Mage.Sets/src/mage/cards/p/ProfanerOfTheDead.java b/Mage.Sets/src/mage/cards/p/ProfanerOfTheDead.java index f7336f9897..ea1c4eb187 100644 --- a/Mage.Sets/src/mage/cards/p/ProfanerOfTheDead.java +++ b/Mage.Sets/src/mage/cards/p/ProfanerOfTheDead.java @@ -62,7 +62,7 @@ class ProfanerOfTheDeadReturnEffect extends OneShotEffect { @Override public boolean apply(Game game, Ability source) { Player controller = game.getPlayer(source.getControllerId()); - Permanent exploitedCreature = game.getPermanentOrLKIBattlefield(getTargetPointer().getFirst(game, source)); + Permanent exploitedCreature = getTargetPointer().getFirstTargetPermanentOrLKI(game, source); if (controller != null && exploitedCreature != null) { FilterCreaturePermanent filter = new FilterCreaturePermanent(); filter.add(TargetController.OPPONENT.getControllerPredicate()); diff --git a/Mage.Sets/src/mage/cards/p/Purgatory.java b/Mage.Sets/src/mage/cards/p/Purgatory.java index 7fdb5917e8..25818c66db 100644 --- a/Mage.Sets/src/mage/cards/p/Purgatory.java +++ b/Mage.Sets/src/mage/cards/p/Purgatory.java @@ -96,7 +96,7 @@ class PurgatoryTriggeredAbility extends TriggeredAbilityImpl { && permanent.isCreature() && permanent.isOwnedBy(controller.getId())) { - this.getEffects().get(0).setTargetPointer(new FixedTarget(permanent.getId())); + this.getEffects().get(0).setTargetPointer(new FixedTarget(permanent, game)); return true; } } diff --git a/Mage.Sets/src/mage/cards/r/RageForger.java b/Mage.Sets/src/mage/cards/r/RageForger.java index 3af9a97727..15d35f91ac 100644 --- a/Mage.Sets/src/mage/cards/r/RageForger.java +++ b/Mage.Sets/src/mage/cards/r/RageForger.java @@ -86,7 +86,7 @@ class RageForgerDamageEffect extends OneShotEffect { @Override public boolean apply(Game game, Ability source) { Player controller = game.getPlayer(source.getControllerId()); - Permanent attackingCreature = game.getPermanentOrLKIBattlefield(getTargetPointer().getFirst(game, source)); + Permanent attackingCreature = getTargetPointer().getFirstTargetPermanentOrLKI(game, source); if (controller != null && attackingCreature != null) { game.damagePlayerOrPlaneswalker(source.getFirstTarget(), 1, attackingCreature.getId(), game, false, true); return true; diff --git a/Mage.Sets/src/mage/cards/r/RakishHeir.java b/Mage.Sets/src/mage/cards/r/RakishHeir.java index 37de821632..a722a6cae7 100644 --- a/Mage.Sets/src/mage/cards/r/RakishHeir.java +++ b/Mage.Sets/src/mage/cards/r/RakishHeir.java @@ -74,7 +74,7 @@ class RakishHeirTriggeredAbility extends TriggeredAbilityImpl { && permanent.hasSubtype(SubType.VAMPIRE, game) && permanent.isControlledBy(controllerId)) { this.getEffects().clear(); AddCountersTargetEffect effect = new AddCountersTargetEffect(CounterType.P1P1.createInstance()); - effect.setTargetPointer(new FixedTarget(permanent.getId())); + effect.setTargetPointer(new FixedTarget(permanent, game)); this.addEffect(effect); return true; } diff --git a/Mage.Sets/src/mage/cards/r/RapidHybridization.java b/Mage.Sets/src/mage/cards/r/RapidHybridization.java index 5c157eeb92..79ed435dee 100644 --- a/Mage.Sets/src/mage/cards/r/RapidHybridization.java +++ b/Mage.Sets/src/mage/cards/r/RapidHybridization.java @@ -57,7 +57,7 @@ class RapidHybridizationEffect extends OneShotEffect { @Override public boolean apply(Game game, Ability source) { - Permanent permanent = game.getPermanentOrLKIBattlefield(targetPointer.getFirst(game, source)); + Permanent permanent = getTargetPointer().getFirstTargetPermanentOrLKI(game, source); if (permanent != null) { FrogLizardToken token = new FrogLizardToken(); token.putOntoBattlefield(1, game, source.getSourceId(), permanent.getControllerId()); diff --git a/Mage.Sets/src/mage/cards/r/RealityShift.java b/Mage.Sets/src/mage/cards/r/RealityShift.java index f50600a417..2aa4d4b22c 100644 --- a/Mage.Sets/src/mage/cards/r/RealityShift.java +++ b/Mage.Sets/src/mage/cards/r/RealityShift.java @@ -60,7 +60,7 @@ class RealityShiftEffect extends OneShotEffect { @Override public boolean apply(Game game, Ability source) { - Permanent targetCreature = game.getPermanentOrLKIBattlefield(getTargetPointer().getFirst(game, source)); + Permanent targetCreature = getTargetPointer().getFirstTargetPermanentOrLKI(game, source); if (targetCreature != null) { Effect effect = new ManifestTargetPlayerEffect(1, "Its controller"); effect.setTargetPointer(new FixedTarget(targetCreature.getControllerId())); diff --git a/Mage.Sets/src/mage/cards/r/RegalBehemoth.java b/Mage.Sets/src/mage/cards/r/RegalBehemoth.java index fdf945fef1..706c0d3b8f 100644 --- a/Mage.Sets/src/mage/cards/r/RegalBehemoth.java +++ b/Mage.Sets/src/mage/cards/r/RegalBehemoth.java @@ -89,7 +89,7 @@ class RegalBehemothTriggeredManaAbility extends TriggeredManaAbility { ManaEvent mEvent = (ManaEvent) event; for (Effect effect : getEffects()) { effect.setValue("mana", mEvent.getMana()); - effect.setTargetPointer(new FixedTarget(permanent.getId())); + effect.setTargetPointer(new FixedTarget(permanent, game)); } return true; } diff --git a/Mage.Sets/src/mage/cards/r/RenegadeDoppelganger.java b/Mage.Sets/src/mage/cards/r/RenegadeDoppelganger.java index a6c2585ab4..c6cf0e58e1 100644 --- a/Mage.Sets/src/mage/cards/r/RenegadeDoppelganger.java +++ b/Mage.Sets/src/mage/cards/r/RenegadeDoppelganger.java @@ -1,4 +1,3 @@ - package mage.cards.r; import java.util.UUID; @@ -10,9 +9,9 @@ import mage.abilities.effects.OneShotEffect; import mage.cards.CardImpl; import mage.cards.CardSetInfo; import mage.constants.CardType; -import mage.constants.SubType; import mage.constants.Duration; import mage.constants.Outcome; +import mage.constants.SubType; import mage.constants.Zone; import mage.game.Game; import mage.game.events.GameEvent; @@ -28,7 +27,7 @@ import mage.util.functions.EmptyApplyToPermanent; public final class RenegadeDoppelganger extends CardImpl { public RenegadeDoppelganger(UUID ownerId, CardSetInfo setInfo) { - super(ownerId,setInfo,new CardType[]{CardType.CREATURE},"{1}{U}"); + super(ownerId, setInfo, new CardType[]{CardType.CREATURE}, "{1}{U}"); this.subtype.add(SubType.SHAPESHIFTER); this.power = new MageInt(0); @@ -74,7 +73,7 @@ class RenegadeDoppelgangerTriggeredAbility extends TriggeredAbilityImpl { Permanent permanent = game.getPermanent(event.getTargetId()); if (permanent != null && permanent.isCreature() && permanent.isControlledBy(this.getControllerId())) { for (Effect effect : this.getEffects()) { - effect.setTargetPointer(new FixedTarget(permanent.getId())); + effect.setTargetPointer(new FixedTarget(permanent, game)); } return true; } @@ -107,10 +106,7 @@ class RenegadeDoppelgangerEffect extends OneShotEffect { @Override public boolean apply(Game game, Ability source) { Permanent permanent = game.getPermanent(source.getSourceId()); - Permanent targetCreature = game.getPermanent(targetPointer.getFirst(game, source)); - if (targetCreature == null) { - targetCreature = (Permanent) game.getLastKnownInformation(getTargetPointer().getFirst(game, source), Zone.BATTLEFIELD); - } + Permanent targetCreature = getTargetPointer().getFirstTargetPermanentOrLKI(game, source); if (targetCreature == null || permanent == null) { return false; } diff --git a/Mage.Sets/src/mage/cards/r/RienneAngelOfRebirth.java b/Mage.Sets/src/mage/cards/r/RienneAngelOfRebirth.java index b6c73306d9..345da504cf 100644 --- a/Mage.Sets/src/mage/cards/r/RienneAngelOfRebirth.java +++ b/Mage.Sets/src/mage/cards/r/RienneAngelOfRebirth.java @@ -133,7 +133,7 @@ class RienneAngelOfRebirthEffect extends OneShotEffect { Card card = game.getCard(getTargetPointer().getFirst(game, source)); if (card != null && game.getState().getZone(card.getId()) == Zone.GRAVEYARD) { Effect effect = new ReturnFromGraveyardToHandTargetEffect(); - effect.setTargetPointer(new FixedTarget(card.getId(), card.getZoneChangeCounter(game))); + effect.setTargetPointer(new FixedTarget(card, game)); effect.setText("return that card to your hand at the beginning of the next end step"); game.addDelayedTriggeredAbility(new AtTheBeginOfNextEndStepDelayedTriggeredAbility(effect), source); return true; diff --git a/Mage.Sets/src/mage/cards/r/RiskyMove.java b/Mage.Sets/src/mage/cards/r/RiskyMove.java index b72f91ad8d..1fc5ba2af7 100644 --- a/Mage.Sets/src/mage/cards/r/RiskyMove.java +++ b/Mage.Sets/src/mage/cards/r/RiskyMove.java @@ -165,7 +165,7 @@ class RiskyMoveFlipCoinEffect extends OneShotEffect { if (!controller.flipCoin(source, game, true)) { if (permanent != null && chosenOpponent != null) { ContinuousEffect effect = new RiskyMoveCreatureGainControlEffect(Duration.Custom, chosenOpponent.getId()); - effect.setTargetPointer(new FixedTarget(permanent.getId())); + effect.setTargetPointer(new FixedTarget(permanent, game)); game.addEffect(effect, source); game.informPlayers(chosenOpponent.getLogName() + " has gained control of " + permanent.getLogName()); return true; diff --git a/Mage.Sets/src/mage/cards/r/RiteOfTheSerpent.java b/Mage.Sets/src/mage/cards/r/RiteOfTheSerpent.java index 02b31e7760..1a7bb465bc 100644 --- a/Mage.Sets/src/mage/cards/r/RiteOfTheSerpent.java +++ b/Mage.Sets/src/mage/cards/r/RiteOfTheSerpent.java @@ -60,7 +60,7 @@ class RiteOfTheSerpentEffect extends OneShotEffect { @Override public boolean apply(Game game, Ability source) { - Permanent targetCreature = game.getPermanentOrLKIBattlefield(getTargetPointer().getFirst(game, source)); + Permanent targetCreature = getTargetPointer().getFirstTargetPermanentOrLKI(game, source); if (targetCreature != null) { if (targetCreature.getCounters(game).containsKey(CounterType.P1P1)) { new CreateTokenEffect(new SnakeToken("KTK")).apply(game, source); diff --git a/Mage.Sets/src/mage/cards/r/RoarOfJukai.java b/Mage.Sets/src/mage/cards/r/RoarOfJukai.java index 6d777a3cae..84af25a1d9 100644 --- a/Mage.Sets/src/mage/cards/r/RoarOfJukai.java +++ b/Mage.Sets/src/mage/cards/r/RoarOfJukai.java @@ -87,7 +87,7 @@ class RoarOfJukaiEffect extends OneShotEffect { if (new PermanentsOnTheBattlefieldCondition(filter).apply(game, source)) { for (Permanent permanent : game.getBattlefield().getActivePermanents(filterBlocked, source.getControllerId(), source.getSourceId(), game)) { ContinuousEffect effect = new BoostTargetEffect(2, 2, Duration.EndOfTurn); - effect.setTargetPointer(new FixedTarget(permanent.getId())); + effect.setTargetPointer(new FixedTarget(permanent, game)); game.addEffect(effect, source); } } diff --git a/Mage.Sets/src/mage/cards/s/SabaccGame.java b/Mage.Sets/src/mage/cards/s/SabaccGame.java index 7a60b3d2b1..733d46d314 100644 --- a/Mage.Sets/src/mage/cards/s/SabaccGame.java +++ b/Mage.Sets/src/mage/cards/s/SabaccGame.java @@ -76,7 +76,7 @@ class SabaccGameEffect extends OneShotEffect { public boolean apply(Game game, Ability source) { Player controller = game.getPlayer(source.getControllerId()); if (controller != null) { - Permanent targetPermanent = game.getPermanentOrLKIBattlefield(getTargetPointer().getFirst(game, source)); + Permanent targetPermanent = getTargetPointer().getFirstTargetPermanentOrLKI(game, source); if (targetPermanent != null) { Player opponent = game.getPlayer(targetPermanent.getControllerId()); if (opponent != null) { diff --git a/Mage.Sets/src/mage/cards/s/SamiteCenserBearer.java b/Mage.Sets/src/mage/cards/s/SamiteCenserBearer.java index ebc34483b8..411236965c 100644 --- a/Mage.Sets/src/mage/cards/s/SamiteCenserBearer.java +++ b/Mage.Sets/src/mage/cards/s/SamiteCenserBearer.java @@ -72,7 +72,7 @@ class SamiteCenserBearerEffect extends OneShotEffect { PreventDamageToTargetEffect effect = new PreventDamageToTargetEffect(Duration.EndOfTurn, 1); List permanents = game.getBattlefield().getAllActivePermanents(StaticFilters.FILTER_PERMANENT_CREATURE, player.getId(), game); for (Permanent permanent : permanents) { - effect.setTargetPointer(new FixedTarget(permanent.getId())); + effect.setTargetPointer(new FixedTarget(permanent, game)); game.addEffect(effect, source); } return true; diff --git a/Mage.Sets/src/mage/cards/s/Scrambleverse.java b/Mage.Sets/src/mage/cards/s/Scrambleverse.java index e90639cf5c..3f43dd7fae 100644 --- a/Mage.Sets/src/mage/cards/s/Scrambleverse.java +++ b/Mage.Sets/src/mage/cards/s/Scrambleverse.java @@ -58,7 +58,7 @@ class ScrambleverseEffect extends OneShotEffect { int count = players.size(); for (Permanent permanent : game.getBattlefield().getActivePermanents(new FilterNonlandPermanent(), source.getControllerId(), source.getSourceId(), game)) { ContinuousEffect effect = new GainControlTargetEffect(Duration.Custom, true, players.get(RandomUtil.nextInt(count))); - effect.setTargetPointer(new FixedTarget(permanent.getId())); + effect.setTargetPointer(new FixedTarget(permanent, game)); game.addEffect(effect, source); permanent.untap(game); } diff --git a/Mage.Sets/src/mage/cards/s/Seance.java b/Mage.Sets/src/mage/cards/s/Seance.java index 251b1b8e80..3d3ad5e70f 100644 --- a/Mage.Sets/src/mage/cards/s/Seance.java +++ b/Mage.Sets/src/mage/cards/s/Seance.java @@ -71,7 +71,7 @@ class SeanceEffect extends OneShotEffect { if (controller != null && card != null) { controller.moveCards(card, Zone.EXILED, source, game); // Also if the move to exile is replaced, the copy takes place CreateTokenCopyTargetEffect effect = new CreateTokenCopyTargetEffect(source.getControllerId(), null, false); - effect.setTargetPointer(new FixedTarget(card.getId(), card.getZoneChangeCounter(game))); + effect.setTargetPointer(new FixedTarget(card, game)); effect.setAdditionalSubType(SubType.SPIRIT); effect.apply(game, source); ExileTargetEffect exileEffect = new ExileTargetEffect(); diff --git a/Mage.Sets/src/mage/cards/s/SecureTheScene.java b/Mage.Sets/src/mage/cards/s/SecureTheScene.java index 60a79e6f4a..5680511915 100644 --- a/Mage.Sets/src/mage/cards/s/SecureTheScene.java +++ b/Mage.Sets/src/mage/cards/s/SecureTheScene.java @@ -59,7 +59,7 @@ class SecureTheSceneEffect extends OneShotEffect { @Override public boolean apply(Game game, Ability source) { - Permanent permanent = game.getPermanentOrLKIBattlefield(source.getFirstTarget()); + Permanent permanent = getTargetPointer().getFirstTargetPermanentOrLKI(game, source); if (permanent == null) { return false; } diff --git a/Mage.Sets/src/mage/cards/s/SelvalaHeartOfTheWilds.java b/Mage.Sets/src/mage/cards/s/SelvalaHeartOfTheWilds.java index 533634fe29..5bd3a0df20 100644 --- a/Mage.Sets/src/mage/cards/s/SelvalaHeartOfTheWilds.java +++ b/Mage.Sets/src/mage/cards/s/SelvalaHeartOfTheWilds.java @@ -92,7 +92,7 @@ class SelvalaHeartOfTheWildsEffect extends OneShotEffect { @Override public boolean apply(Game game, Ability source) { - Permanent permanent = game.getPermanentOrLKIBattlefield(targetPointer.getFirst(game, source)); + Permanent permanent = getTargetPointer().getFirstTargetPermanentOrLKI(game, source); if (permanent != null) { if (filter2.match(permanent, game)) { Player permanentController = game.getPlayer(permanent.getControllerId()); diff --git a/Mage.Sets/src/mage/cards/s/Sentinel.java b/Mage.Sets/src/mage/cards/s/Sentinel.java index bdbfd2e58c..323593fc76 100644 --- a/Mage.Sets/src/mage/cards/s/Sentinel.java +++ b/Mage.Sets/src/mage/cards/s/Sentinel.java @@ -78,7 +78,7 @@ class SentinelEffect extends OneShotEffect { @Override public boolean apply(Game game, Ability source) { Player controller = game.getPlayer(source.getControllerId()); - Permanent targetPermanent = game.getPermanentOrLKIBattlefield(targetPointer.getFirst(game, source)); + Permanent targetPermanent = getTargetPointer().getFirstTargetPermanentOrLKI(game, source); if (controller != null && targetPermanent != null) { int newToughness = CardUtil.addWithOverflowCheck(targetPermanent.getPower().getValue(), 1); game.addEffect(new SetToughnessSourceEffect(StaticValue.get(newToughness), Duration.Custom, SubLayer.SetPT_7b), source); diff --git a/Mage.Sets/src/mage/cards/s/SeverSoul.java b/Mage.Sets/src/mage/cards/s/SeverSoul.java index 96bf920f72..2df31e8d7a 100644 --- a/Mage.Sets/src/mage/cards/s/SeverSoul.java +++ b/Mage.Sets/src/mage/cards/s/SeverSoul.java @@ -64,7 +64,7 @@ class GainLifeEqualToToughnessEffect extends OneShotEffect { @Override public boolean apply(Game game, Ability source) { - Permanent permanent = game.getPermanentOrLKIBattlefield(getTargetPointer().getFirst(game, source)); + Permanent permanent = getTargetPointer().getFirstTargetPermanentOrLKI(game, source); if (permanent != null) { Player player = game.getPlayer(source.getControllerId()); if (player != null) { diff --git a/Mage.Sets/src/mage/cards/s/ShapeStealer.java b/Mage.Sets/src/mage/cards/s/ShapeStealer.java index d21b0e2c98..f9d7ba254c 100644 --- a/Mage.Sets/src/mage/cards/s/ShapeStealer.java +++ b/Mage.Sets/src/mage/cards/s/ShapeStealer.java @@ -70,7 +70,7 @@ class ShapeStealerEffect extends OneShotEffect { public boolean apply(Game game, Ability source) { Player controller = game.getPlayer(source.getControllerId()); if (controller != null) { - Permanent permanent = game.getPermanentOrLKIBattlefield(getTargetPointer().getFirst(game, source)); + Permanent permanent = getTargetPointer().getFirstTargetPermanentOrLKI(game, source); if (permanent != null) { ContinuousEffect effect = new SetPowerToughnessSourceEffect(permanent.getPower().getValue(), permanent.getToughness().getValue(), Duration.EndOfTurn, SubLayer.SetPT_7b); game.addEffect(effect, source); diff --git a/Mage.Sets/src/mage/cards/s/ShireiShizosCaretaker.java b/Mage.Sets/src/mage/cards/s/ShireiShizosCaretaker.java index 5af0b2937e..de64a813aa 100644 --- a/Mage.Sets/src/mage/cards/s/ShireiShizosCaretaker.java +++ b/Mage.Sets/src/mage/cards/s/ShireiShizosCaretaker.java @@ -121,7 +121,7 @@ class ShireiShizosCaretakerEffect extends OneShotEffect { Effect effect = new ShireiShizosCaretakerReturnEffect(shireiId); effect.setText("return that card to the battlefield if {this} is still on the battlefield"); DelayedTriggeredAbility delayedAbility = new AtTheBeginOfNextEndStepDelayedTriggeredAbility(effect); - delayedAbility.getEffects().get(0).setTargetPointer(new FixedTarget(card.getId(), card.getZoneChangeCounter(game))); + delayedAbility.getEffects().get(0).setTargetPointer(new FixedTarget(card, game)); game.addDelayedTriggeredAbility(delayedAbility, source); return true; } diff --git a/Mage.Sets/src/mage/cards/s/ShrivelingRot.java b/Mage.Sets/src/mage/cards/s/ShrivelingRot.java index dfe775bf0e..278fa9bab3 100644 --- a/Mage.Sets/src/mage/cards/s/ShrivelingRot.java +++ b/Mage.Sets/src/mage/cards/s/ShrivelingRot.java @@ -145,7 +145,7 @@ class ShrivelingRotEffect extends OneShotEffect { @Override public boolean apply(Game game, Ability source) { - Permanent permanent = game.getPermanentOrLKIBattlefield(getTargetPointer().getFirst(game, source)); + Permanent permanent = getTargetPointer().getFirstTargetPermanentOrLKI(game, source); if (permanent != null) { if (permanent.getZoneChangeCounter(game) + 1 == game.getState().getZoneChangeCounter(permanent.getId()) && game.getState().getZone(permanent.getId()) != Zone.GRAVEYARD) { diff --git a/Mage.Sets/src/mage/cards/s/SmashToSmithereens.java b/Mage.Sets/src/mage/cards/s/SmashToSmithereens.java index f3bbcbcb02..c2315cbb1d 100644 --- a/Mage.Sets/src/mage/cards/s/SmashToSmithereens.java +++ b/Mage.Sets/src/mage/cards/s/SmashToSmithereens.java @@ -56,7 +56,7 @@ class SmashToSmithereensEffect extends OneShotEffect { @Override public boolean apply(Game game, Ability source) { - Permanent targetArtifact = game.getPermanentOrLKIBattlefield(source.getFirstTarget()); + Permanent targetArtifact = getTargetPointer().getFirstTargetPermanentOrLKI(game, source); if (targetArtifact != null) { Player controllerOfArtifact = game.getPlayer(targetArtifact.getControllerId()); targetArtifact.destroy(source.getSourceId(), game, false); diff --git a/Mage.Sets/src/mage/cards/s/SoulReap.java b/Mage.Sets/src/mage/cards/s/SoulReap.java index ba1fb190a2..4520aec737 100644 --- a/Mage.Sets/src/mage/cards/s/SoulReap.java +++ b/Mage.Sets/src/mage/cards/s/SoulReap.java @@ -127,7 +127,7 @@ class SoulReapEffect extends OneShotEffect { @Override public boolean apply(Game game, Ability source) { - Permanent creature = game.getPermanentOrLKIBattlefield(getTargetPointer().getFirst(game, source)); + Permanent creature = getTargetPointer().getFirstTargetPermanentOrLKI(game, source); if (creature != null) { Player controller = game.getPlayer(creature.getControllerId()); if (controller != null) { diff --git a/Mage.Sets/src/mage/cards/s/SpittingSlug.java b/Mage.Sets/src/mage/cards/s/SpittingSlug.java index 4b52189692..b315f3d59f 100644 --- a/Mage.Sets/src/mage/cards/s/SpittingSlug.java +++ b/Mage.Sets/src/mage/cards/s/SpittingSlug.java @@ -79,7 +79,7 @@ class SpittingSlugEffect extends OneShotEffect { filter.add(Predicates.or(new BlockedByIdPredicate(sourcePermanent.getId()), new BlockingAttackerIdPredicate(sourcePermanent.getId()))); for (Permanent permanent : game.getBattlefield().getAllActivePermanents(filter, game)) { ContinuousEffect effect = new GainAbilityTargetEffect(FirstStrikeAbility.getInstance(), Duration.EndOfTurn); - effect.setTargetPointer(new FixedTarget(permanent.getId())); + effect.setTargetPointer(new FixedTarget(permanent, game)); game.addEffect(effect, source); } return true; diff --git a/Mage.Sets/src/mage/cards/s/SpreadingPlague.java b/Mage.Sets/src/mage/cards/s/SpreadingPlague.java index fea0ae4948..f2faa691fe 100644 --- a/Mage.Sets/src/mage/cards/s/SpreadingPlague.java +++ b/Mage.Sets/src/mage/cards/s/SpreadingPlague.java @@ -63,7 +63,7 @@ class SpreadingPlagueEffect extends OneShotEffect { @Override public boolean apply(Game game, Ability source) { - Permanent creature = game.getPermanentOrLKIBattlefield(targetPointer.getFirst(game, source)); + Permanent creature = getTargetPointer().getFirstTargetPermanentOrLKI(game, source); if (creature != null) { ObjectColor color = creature.getColor(game); for (Permanent permanent : game.getBattlefield().getActivePermanents(FILTER, source.getControllerId(), game)) { diff --git a/Mage.Sets/src/mage/cards/s/SquealingDevil.java b/Mage.Sets/src/mage/cards/s/SquealingDevil.java index 4a212aaf03..a2976211e5 100644 --- a/Mage.Sets/src/mage/cards/s/SquealingDevil.java +++ b/Mage.Sets/src/mage/cards/s/SquealingDevil.java @@ -87,7 +87,7 @@ class SquealingDevilEffect extends OneShotEffect { Permanent permanent = game.getPermanent(source.getFirstTarget()); if (permanent != null && permanent.isCreature()) { ContinuousEffect effect = new BoostTargetEffect(costX, 0, Duration.EndOfTurn); - effect.setTargetPointer(new FixedTarget(permanent.getId())); + effect.setTargetPointer(new FixedTarget(permanent, game)); game.addEffect(effect, source); return true; } diff --git a/Mage.Sets/src/mage/cards/s/StandOrFall.java b/Mage.Sets/src/mage/cards/s/StandOrFall.java index 5b15cd11a3..2c976bee06 100644 --- a/Mage.Sets/src/mage/cards/s/StandOrFall.java +++ b/Mage.Sets/src/mage/cards/s/StandOrFall.java @@ -117,7 +117,7 @@ class StandOrFallEffect extends OneShotEffect { if (permanent != null) { RestrictionEffect effect = new CantBlockTargetEffect(Duration.EndOfTurn); effect.setText(""); - effect.setTargetPointer(new FixedTarget(permanent.getId())); + effect.setTargetPointer(new FixedTarget(permanent, game)); game.addEffect(effect, source); } } diff --git a/Mage.Sets/src/mage/cards/s/StensiaMasquerade.java b/Mage.Sets/src/mage/cards/s/StensiaMasquerade.java index ee86d460f3..994a4ce5df 100644 --- a/Mage.Sets/src/mage/cards/s/StensiaMasquerade.java +++ b/Mage.Sets/src/mage/cards/s/StensiaMasquerade.java @@ -91,7 +91,7 @@ class StensiaMasqueradeTriggeredAbility extends TriggeredAbilityImpl { && permanent.hasSubtype(SubType.VAMPIRE, game) && permanent.isControlledBy(controllerId)) { this.getEffects().clear(); AddCountersTargetEffect effect = new AddCountersTargetEffect(CounterType.P1P1.createInstance()); - effect.setTargetPointer(new FixedTarget(permanent.getId())); + effect.setTargetPointer(new FixedTarget(permanent, game)); this.addEffect(effect); return true; } diff --git a/Mage.Sets/src/mage/cards/s/SwornDefender.java b/Mage.Sets/src/mage/cards/s/SwornDefender.java index 71ff72a02b..2032339f9e 100644 --- a/Mage.Sets/src/mage/cards/s/SwornDefender.java +++ b/Mage.Sets/src/mage/cards/s/SwornDefender.java @@ -72,7 +72,7 @@ class SwornDefenderEffect extends OneShotEffect { @Override public boolean apply(Game game, Ability source) { Player controller = game.getPlayer(source.getControllerId()); - Permanent targetPermanent = game.getPermanentOrLKIBattlefield(targetPointer.getFirst(game, source)); + Permanent targetPermanent = getTargetPointer().getFirstTargetPermanentOrLKI(game, source); if (controller != null && targetPermanent != null) { int newPower = CardUtil.subtractWithOverflowCheck(targetPermanent.getToughness().getValue(), 1); int newToughness = CardUtil.addWithOverflowCheck(targetPermanent.getPower().getValue(), 1); diff --git a/Mage.Sets/src/mage/cards/s/SyrCarahTheBold.java b/Mage.Sets/src/mage/cards/s/SyrCarahTheBold.java index 1a7a682d00..688ab1d024 100644 --- a/Mage.Sets/src/mage/cards/s/SyrCarahTheBold.java +++ b/Mage.Sets/src/mage/cards/s/SyrCarahTheBold.java @@ -126,7 +126,7 @@ class SyrCarahTheBoldExileEffect extends OneShotEffect { String exileName = sourcePermanent.getIdName() + " "; controller.moveCardsToExile(card, source, game, true, source.getSourceId(), exileName); ContinuousEffect effect = new PlayFromNotOwnHandZoneTargetEffect(Duration.EndOfTurn); - effect.setTargetPointer(new FixedTarget(card.getId(), card.getZoneChangeCounter(game))); + effect.setTargetPointer(new FixedTarget(card, game)); game.addEffect(effect, source); return true; } diff --git a/Mage.Sets/src/mage/cards/t/TemptWithReflections.java b/Mage.Sets/src/mage/cards/t/TemptWithReflections.java index 8df6b4f317..3df0617fdc 100644 --- a/Mage.Sets/src/mage/cards/t/TemptWithReflections.java +++ b/Mage.Sets/src/mage/cards/t/TemptWithReflections.java @@ -59,7 +59,7 @@ class TemptWithReflectionsEffect extends OneShotEffect { @Override public boolean apply(Game game, Ability source) { - Permanent permanent = game.getPermanentOrLKIBattlefield(this.getTargetPointer().getFirst(game, source)); + Permanent permanent = getTargetPointer().getFirstTargetPermanentOrLKI(game, source); if (permanent != null) { Effect effect = new CreateTokenCopyTargetEffect(); effect.setTargetPointer(getTargetPointer()); diff --git a/Mage.Sets/src/mage/cards/t/TerashisGrasp.java b/Mage.Sets/src/mage/cards/t/TerashisGrasp.java index 5b9caf0c70..0ec0dd5987 100644 --- a/Mage.Sets/src/mage/cards/t/TerashisGrasp.java +++ b/Mage.Sets/src/mage/cards/t/TerashisGrasp.java @@ -56,7 +56,7 @@ public final class TerashisGrasp extends CardImpl { @Override public boolean apply(Game game, Ability source) { - Permanent targetPermanent = game.getPermanentOrLKIBattlefield(getTargetPointer().getFirst(game, source)); + Permanent targetPermanent = getTargetPointer().getFirstTargetPermanentOrLKI(game, source); if (targetPermanent != null) { int cost = targetPermanent.getConvertedManaCost(); Player player = game.getPlayer(source.getControllerId()); diff --git a/Mage.Sets/src/mage/cards/t/TezzeretMasterOfMetal.java b/Mage.Sets/src/mage/cards/t/TezzeretMasterOfMetal.java index f26c2ce66c..3e5f13e3c0 100644 --- a/Mage.Sets/src/mage/cards/t/TezzeretMasterOfMetal.java +++ b/Mage.Sets/src/mage/cards/t/TezzeretMasterOfMetal.java @@ -91,7 +91,7 @@ class TezzeretMasterOfMetalEffect extends OneShotEffect { List permanents = game.getBattlefield().getAllActivePermanents(filter, targetPointer.getFirst(game, source), game); for (Permanent permanent : permanents) { ContinuousEffect effect = new TezzeretMasterOfMetalControlEffect(source.getControllerId()); - effect.setTargetPointer(new FixedTarget(permanent.getId())); + effect.setTargetPointer(new FixedTarget(permanent, game)); game.addEffect(effect, source); } return true; diff --git a/Mage.Sets/src/mage/cards/t/TheScarabGod.java b/Mage.Sets/src/mage/cards/t/TheScarabGod.java index e8d7e44ae0..aa810cbebe 100644 --- a/Mage.Sets/src/mage/cards/t/TheScarabGod.java +++ b/Mage.Sets/src/mage/cards/t/TheScarabGod.java @@ -134,7 +134,7 @@ class TheScarabGodEffect2 extends OneShotEffect { if (controller != null && card != null) { controller.moveCards(card, Zone.EXILED, source, game); // Also if the move to exile is replaced, the copy takes place CreateTokenCopyTargetEffect effect = new CreateTokenCopyTargetEffect(source.getControllerId(), null, false, 1, false, false, null, 4, 4, false); - effect.setTargetPointer(new FixedTarget(card.getId(), card.getZoneChangeCounter(game))); + effect.setTargetPointer(new FixedTarget(card, game)); effect.setOnlySubType(SubType.ZOMBIE); effect.setOnlyColor(ObjectColor.BLACK); effect.apply(game, source); diff --git a/Mage.Sets/src/mage/cards/t/ThrillingEncore.java b/Mage.Sets/src/mage/cards/t/ThrillingEncore.java index 9a5335ceed..e010ab07cd 100644 --- a/Mage.Sets/src/mage/cards/t/ThrillingEncore.java +++ b/Mage.Sets/src/mage/cards/t/ThrillingEncore.java @@ -65,7 +65,7 @@ class ThrillingEncoreEffect extends OneShotEffect { Card card = mor.getCard(game); if (card != null && card.isCreature()) { Effect effect = new ReturnFromGraveyardToBattlefieldTargetEffect(); - effect.setTargetPointer(new FixedTarget(card.getId(), card.getZoneChangeCounter(game))); + effect.setTargetPointer(new FixedTarget(card, game)); effect.apply(game, source); } } diff --git a/Mage.Sets/src/mage/cards/t/TianaShipsCaretaker.java b/Mage.Sets/src/mage/cards/t/TianaShipsCaretaker.java index 832e96d5de..ec1e94aef8 100644 --- a/Mage.Sets/src/mage/cards/t/TianaShipsCaretaker.java +++ b/Mage.Sets/src/mage/cards/t/TianaShipsCaretaker.java @@ -130,7 +130,7 @@ class TianaShipsCaretakerEffect extends OneShotEffect { Card card = game.getCard(getTargetPointer().getFirst(game, source)); if (card != null && game.getState().getZone(card.getId()) == Zone.GRAVEYARD) { Effect effect = new ReturnFromGraveyardToHandTargetEffect(); - effect.setTargetPointer(new FixedTarget(card.getId(), card.getZoneChangeCounter(game))); + effect.setTargetPointer(new FixedTarget(card, game)); effect.setText("return that card to your hand at the beginning of the next end step"); game.addDelayedTriggeredAbility(new AtTheBeginOfNextEndStepDelayedTriggeredAbility(effect), source); return true; diff --git a/Mage.Sets/src/mage/cards/t/TibaltTheFiendBlooded.java b/Mage.Sets/src/mage/cards/t/TibaltTheFiendBlooded.java index d3a95cc41c..4817151c4a 100644 --- a/Mage.Sets/src/mage/cards/t/TibaltTheFiendBlooded.java +++ b/Mage.Sets/src/mage/cards/t/TibaltTheFiendBlooded.java @@ -118,11 +118,11 @@ class TibaltTheFiendBloodedThirdEffect extends OneShotEffect { permanent.untap(game); ContinuousEffect effect = new TibaltTheFiendBloodedControlEffect(source.getControllerId()); - effect.setTargetPointer(new FixedTarget(permanent.getId())); + effect.setTargetPointer(new FixedTarget(permanent, game)); game.addEffect(effect, source); effect = new GainAbilityTargetEffect(HasteAbility.getInstance(), Duration.EndOfTurn); - effect.setTargetPointer(new FixedTarget(permanent.getId())); + effect.setTargetPointer(new FixedTarget(permanent, game)); game.addEffect(effect, source); } return true; diff --git a/Mage.Sets/src/mage/cards/t/TouchOfMoonglove.java b/Mage.Sets/src/mage/cards/t/TouchOfMoonglove.java index f7353561b4..fe522bb656 100644 --- a/Mage.Sets/src/mage/cards/t/TouchOfMoonglove.java +++ b/Mage.Sets/src/mage/cards/t/TouchOfMoonglove.java @@ -74,7 +74,7 @@ class TouchOfMoongloveAddTriggerEffect extends OneShotEffect { @Override public boolean apply(Game game, Ability source) { - Permanent permanent = game.getPermanentOrLKIBattlefield(getTargetPointer().getFirst(game, source)); + Permanent permanent = getTargetPointer().getFirstTargetPermanentOrLKI(game, source); if (permanent != null) { DelayedTriggeredAbility delayedAbility = new TouchOfMoongloveDelayedTriggeredAbility(new MageObjectReference(permanent, game)); game.addDelayedTriggeredAbility(delayedAbility, source); diff --git a/Mage.Sets/src/mage/cards/t/Transmogrify.java b/Mage.Sets/src/mage/cards/t/Transmogrify.java index 1d338a60eb..4078021fd4 100644 --- a/Mage.Sets/src/mage/cards/t/Transmogrify.java +++ b/Mage.Sets/src/mage/cards/t/Transmogrify.java @@ -60,7 +60,7 @@ class TransmogrifyEffect extends OneShotEffect { @Override public boolean apply(Game game, Ability source) { - Permanent permanent = game.getPermanentOrLKIBattlefield(getTargetPointer().getFirst(game, source)); + Permanent permanent = getTargetPointer().getFirstTargetPermanentOrLKI(game, source); if (permanent != null) { Player player = game.getPlayer(permanent.getControllerId()); if (player != null) { diff --git a/Mage.Sets/src/mage/cards/t/TreasureNabber.java b/Mage.Sets/src/mage/cards/t/TreasureNabber.java index ba23895c9d..eb4f26045a 100644 --- a/Mage.Sets/src/mage/cards/t/TreasureNabber.java +++ b/Mage.Sets/src/mage/cards/t/TreasureNabber.java @@ -64,7 +64,7 @@ class TreasureNabberAbility extends TriggeredAbilityImpl { if (game.getOpponents(controllerId).contains(event.getPlayerId())) { Permanent permanent = game.getPermanent(event.getSourceId()); if (permanent != null && permanent.isArtifact()) { - getEffects().get(0).setTargetPointer(new FixedTarget(permanent.getId())); + getEffects().get(0).setTargetPointer(new FixedTarget(permanent, game)); return true; } } diff --git a/Mage.Sets/src/mage/cards/t/TsabosAssassin.java b/Mage.Sets/src/mage/cards/t/TsabosAssassin.java index f0b401a4d9..220405edbd 100644 --- a/Mage.Sets/src/mage/cards/t/TsabosAssassin.java +++ b/Mage.Sets/src/mage/cards/t/TsabosAssassin.java @@ -74,7 +74,7 @@ class TsabosAssasinEffect extends OneShotEffect { Condition condition = new MostCommonColorCondition(permanent.getColor(game)); if (condition.apply(game, source)) { Effect effect = new DestroyTargetEffect(); - effect.setTargetPointer(new FixedTarget(permanent.getId())); + effect.setTargetPointer(new FixedTarget(permanent, game)); return effect.apply(game, source); } } diff --git a/Mage.Sets/src/mage/cards/t/TwistAllegiance.java b/Mage.Sets/src/mage/cards/t/TwistAllegiance.java index 625aa01123..8b974cfcbe 100644 --- a/Mage.Sets/src/mage/cards/t/TwistAllegiance.java +++ b/Mage.Sets/src/mage/cards/t/TwistAllegiance.java @@ -70,11 +70,11 @@ class TwistAllegianceEffect extends OneShotEffect { if (permanent.isControlledBy(source.getControllerId()) || permanent.isControlledBy(targetOpponent.getId())) { UUID newController = permanent.isControlledBy(source.getControllerId()) ? targetOpponent.getId() : source.getControllerId(); ContinuousEffect effect = new GainControlTargetEffect(Duration.EndOfTurn, true, newController); - effect.setTargetPointer(new FixedTarget(permanent.getId())); + effect.setTargetPointer(new FixedTarget(permanent, game)); game.addEffect(effect, source); permanent.untap(game); effect = new GainAbilityTargetEffect(HasteAbility.getInstance(), Duration.EndOfTurn); - effect.setTargetPointer(new FixedTarget(permanent.getId())); + effect.setTargetPointer(new FixedTarget(permanent, game)); game.addEffect(effect, source); } } diff --git a/Mage.Sets/src/mage/cards/u/Unforge.java b/Mage.Sets/src/mage/cards/u/Unforge.java index f1f777176b..190f6de98d 100644 --- a/Mage.Sets/src/mage/cards/u/Unforge.java +++ b/Mage.Sets/src/mage/cards/u/Unforge.java @@ -61,7 +61,7 @@ class UnforgeEffect extends OneShotEffect{ @Override public boolean apply(Game game, Ability source) { - Permanent equipment = game.getPermanentOrLKIBattlefield(this.getTargetPointer().getFirst(game, source)); + Permanent equipment = getTargetPointer().getFirstTargetPermanentOrLKI(game, source); if(equipment != null){ Permanent creature = game.getPermanent(equipment.getAttachedTo()); if(creature != null){ diff --git a/Mage.Sets/src/mage/cards/u/UnstableShapeshifter.java b/Mage.Sets/src/mage/cards/u/UnstableShapeshifter.java index fff1570c3f..04e3696a36 100644 --- a/Mage.Sets/src/mage/cards/u/UnstableShapeshifter.java +++ b/Mage.Sets/src/mage/cards/u/UnstableShapeshifter.java @@ -73,7 +73,7 @@ class UnstableShapeshifterEffect extends OneShotEffect { @Override public boolean apply(Game game, Ability source) { Permanent permanent = game.getPermanent(source.getSourceId()); - Permanent targetCreature = game.getPermanentOrLKIBattlefield(getTargetPointer().getFirst(game, source)); + Permanent targetCreature = getTargetPointer().getFirstTargetPermanentOrLKI(game, source); if (targetCreature != null && permanent != null) { Permanent blueprintPermanent = game.copyPermanent(Duration.Custom, targetCreature, permanent.getId(), source, new EmptyApplyToPermanent()); blueprintPermanent.addAbility(new EntersBattlefieldAllTriggeredAbility(Zone.BATTLEFIELD, diff --git a/Mage.Sets/src/mage/cards/v/VancesBlastingCannons.java b/Mage.Sets/src/mage/cards/v/VancesBlastingCannons.java index ec03cc2a0d..4eb7fa8560 100644 --- a/Mage.Sets/src/mage/cards/v/VancesBlastingCannons.java +++ b/Mage.Sets/src/mage/cards/v/VancesBlastingCannons.java @@ -85,7 +85,7 @@ class VancesBlastingCannonsExileEffect extends OneShotEffect { controller.moveCardsToExile(card, source, game, true, source.getSourceId(), exileName); if (game.getState().getZone(card.getId()) == Zone.EXILED && !card.isLand()) { ContinuousEffect effect = new CastFromNonHandZoneTargetEffect(Duration.EndOfTurn); - effect.setTargetPointer(new FixedTarget(card.getId(), card.getZoneChangeCounter(game))); + effect.setTargetPointer(new FixedTarget(card, game)); game.addEffect(effect, source); } } diff --git a/Mage.Sets/src/mage/cards/v/Vendetta.java b/Mage.Sets/src/mage/cards/v/Vendetta.java index 3befedd303..0057abd3e2 100644 --- a/Mage.Sets/src/mage/cards/v/Vendetta.java +++ b/Mage.Sets/src/mage/cards/v/Vendetta.java @@ -69,7 +69,7 @@ class VendettaEffect extends OneShotEffect { @Override public boolean apply(Game game, Ability source) { Player player = game.getPlayer(source.getControllerId()); - Permanent target = game.getPermanentOrLKIBattlefield(this.getTargetPointer().getFirst(game, source)); + Permanent target = getTargetPointer().getFirstTargetPermanentOrLKI(game, source); if (player != null && target != null) { player.loseLife(target.getToughness().getValue(), game, false); return true; diff --git a/Mage.Sets/src/mage/cards/v/VorinclexVoiceOfHunger.java b/Mage.Sets/src/mage/cards/v/VorinclexVoiceOfHunger.java index 0397b488a8..1f3684a3c6 100644 --- a/Mage.Sets/src/mage/cards/v/VorinclexVoiceOfHunger.java +++ b/Mage.Sets/src/mage/cards/v/VorinclexVoiceOfHunger.java @@ -82,7 +82,7 @@ class VorinclexTriggeredAbility2 extends TriggeredAbilityImpl { if (game.getOpponents(getControllerId()).contains(event.getPlayerId())) { Permanent permanent = game.getPermanent(event.getSourceId()); if (permanent != null && permanent.isLand()) { - getEffects().get(0).setTargetPointer(new FixedTarget(permanent.getId())); + getEffects().get(0).setTargetPointer(new FixedTarget(permanent, game)); return true; } } diff --git a/Mage.Sets/src/mage/cards/w/WhenFluffyBunniesAttack.java b/Mage.Sets/src/mage/cards/w/WhenFluffyBunniesAttack.java index 0b868b021b..b921adc884 100644 --- a/Mage.Sets/src/mage/cards/w/WhenFluffyBunniesAttack.java +++ b/Mage.Sets/src/mage/cards/w/WhenFluffyBunniesAttack.java @@ -86,7 +86,7 @@ class WhenFluffyBunniesAttackEffect extends OneShotEffect { } } BoostTargetEffect effect = new BoostTargetEffect(unboostValue, unboostValue, Duration.EndOfTurn); - effect.setTargetPointer(new FixedTarget(permanent.getId())); + effect.setTargetPointer(new FixedTarget(permanent, game)); game.addEffect(effect, source); return true; } diff --git a/Mage.Sets/src/mage/cards/w/WildPair.java b/Mage.Sets/src/mage/cards/w/WildPair.java index ad3dab657c..0676c3ae30 100644 --- a/Mage.Sets/src/mage/cards/w/WildPair.java +++ b/Mage.Sets/src/mage/cards/w/WildPair.java @@ -75,7 +75,7 @@ class WildPairEffect extends OneShotEffect { public boolean apply(Game game, Ability source) { Player controller = game.getPlayer(source.getControllerId()); if (controller != null) { - Permanent permanent = game.getPermanentOrLKIBattlefield(getTargetPointer().getFirst(game, source)); + Permanent permanent = getTargetPointer().getFirstTargetPermanentOrLKI(game, source); if (permanent != null) { int totalPT = permanent.getPower().getValue() + permanent.getToughness().getValue(); FilterCreatureCard filter = new FilterCreatureCard("creature card with total power and toughness " + totalPT); diff --git a/Mage.Sets/src/mage/cards/y/YorvoLordOfGarenbrig.java b/Mage.Sets/src/mage/cards/y/YorvoLordOfGarenbrig.java index 2cfb09ad0e..a0f22942db 100644 --- a/Mage.Sets/src/mage/cards/y/YorvoLordOfGarenbrig.java +++ b/Mage.Sets/src/mage/cards/y/YorvoLordOfGarenbrig.java @@ -89,7 +89,7 @@ class YorvoLordOfGarenbrigEffect extends OneShotEffect { return false; } sourcePerm.addCounters(CounterType.P1P1.createInstance(), source, game); - Permanent permanent = ((FixedTarget) targetPointer).getTargetedPermanentOrLKIBattlefield(game); + Permanent permanent = getTargetPointer().getFirstTargetPermanentOrLKI(game, source); if (permanent == null) { return true; } diff --git a/Mage.Tests/src/test/java/org/mage/test/cards/abilities/keywords/ManifestTest.java b/Mage.Tests/src/test/java/org/mage/test/cards/abilities/keywords/ManifestTest.java index 82a81887b7..07e2c95045 100644 --- a/Mage.Tests/src/test/java/org/mage/test/cards/abilities/keywords/ManifestTest.java +++ b/Mage.Tests/src/test/java/org/mage/test/cards/abilities/keywords/ManifestTest.java @@ -123,6 +123,8 @@ public class ManifestTest extends CardTestPlayerBase { */ @Test public void testNylea() { + setStrictChooseMode(true); + addCard(Zone.BATTLEFIELD, playerB, "Island", 2); // Exile target creature. Its controller manifests the top card of their library {1}{U} addCard(Zone.HAND, playerB, "Reality Shift"); diff --git a/Mage.Tests/src/test/java/org/mage/test/cards/abilities/other/ImpelledGiantTest.java b/Mage.Tests/src/test/java/org/mage/test/cards/abilities/other/ImpelledGiantTest.java index 61255dd588..9a0ffce1b7 100644 --- a/Mage.Tests/src/test/java/org/mage/test/cards/abilities/other/ImpelledGiantTest.java +++ b/Mage.Tests/src/test/java/org/mage/test/cards/abilities/other/ImpelledGiantTest.java @@ -1,4 +1,3 @@ - package org.mage.test.cards.abilities.other; import mage.constants.PhaseStep; @@ -10,14 +9,20 @@ public class ImpelledGiantTest extends CardTestPlayerBase { @Test public void testGainsPower() { - addCard(Zone.BATTLEFIELD, playerA, "Impelled Giant"); - addCard(Zone.BATTLEFIELD, playerA, "Hurloon Minotaur"); + setStrictChooseMode(true); + // Trample + // Tap an untapped red creature you control other than Impelled Giant: Impelled Giant gets +X/+0 until end of turn, where X is the power of the creature tapped this way. + addCard(Zone.BATTLEFIELD, playerA, "Impelled Giant"); // Creature 3/3 + addCard(Zone.BATTLEFIELD, playerA, "Hurloon Minotaur"); // Creature 2/3 activateAbility(1, PhaseStep.PRECOMBAT_MAIN, playerA, "Tap an untapped red creature you control other than Impelled Giant"); + setChoice(playerA, "Hurloon Minotaur"); setStopAt(1, PhaseStep.BEGIN_COMBAT); execute(); + assertAllCommandsUsed(); + assertTapped("Hurloon Minotaur", true); assertPowerToughness(playerA, "Impelled Giant", 5, 3); } diff --git a/Mage.Tests/src/test/java/org/mage/test/cards/single/cmd/AcornCatapultTest.java b/Mage.Tests/src/test/java/org/mage/test/cards/single/cmd/AcornCatapultTest.java new file mode 100644 index 0000000000..ec15bbb2b0 --- /dev/null +++ b/Mage.Tests/src/test/java/org/mage/test/cards/single/cmd/AcornCatapultTest.java @@ -0,0 +1,72 @@ +/* + * To change this license header, choose License Headers in Project Properties. + * To change this template file, choose Tools | Templates + * and open the template in the editor. + */ +package org.mage.test.cards.single.cmd; + +import mage.constants.PhaseStep; +import mage.constants.Zone; +import org.junit.Test; +import org.mage.test.serverside.base.CardTestPlayerBase; + +/** + * + * @author LevelX2 + */ +public class AcornCatapultTest extends CardTestPlayerBase { + + @Test + public void testAcornCatapultCreature() { + setStrictChooseMode(true); + + addCard(Zone.BATTLEFIELD, playerA, "Mountain", 5); + // {1}, {T}: Acorn Catapult deals 1 damage to any target. + // That permanent's controller or that player creates a 1/1 green Squirrel creature token. + addCard(Zone.HAND, playerA, "Acorn Catapult"); //Artifact {4} + + // {1}{B}, {T}: Target player loses 1 life. + addCard(Zone.BATTLEFIELD, playerB, "Acolyte of Xathrid"); // Creature 0/1 + + castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerA, "Acorn Catapult"); + + activateAbility(1, PhaseStep.PRECOMBAT_MAIN, playerA, "{1}, {T}:", "Acolyte of Xathrid"); + + setStopAt(1, PhaseStep.BEGIN_COMBAT); + execute(); + + assertAllCommandsUsed(); + + assertPermanentCount(playerA, "Acorn Catapult", 1); + + assertGraveyardCount(playerB, "Acolyte of Xathrid", 1); + + assertPermanentCount(playerB, "Squirrel", 1); + } + + @Test + public void testAcornCatapultPlayer() { + setStrictChooseMode(true); + + addCard(Zone.BATTLEFIELD, playerA, "Mountain", 5); + // {1}, {T}: Acorn Catapult deals 1 damage to any target. + // That permanent's controller or that player creates a 1/1 green Squirrel creature token. + addCard(Zone.HAND, playerA, "Acorn Catapult"); //Artifact {4} + + castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerA, "Acorn Catapult"); + + activateAbility(1, PhaseStep.PRECOMBAT_MAIN, playerA, "{1}, {T}:", playerB); + + setStopAt(1, PhaseStep.BEGIN_COMBAT); + execute(); + + assertAllCommandsUsed(); + + assertPermanentCount(playerA, "Acorn Catapult", 1); + + assertLife(playerB, 19); + + assertPermanentCount(playerB, "Squirrel", 1); + + } +} diff --git a/Mage.Tests/src/test/java/org/mage/test/cards/single/cmd/FlusterstormTest.java b/Mage.Tests/src/test/java/org/mage/test/cards/single/cmd/FlusterstormTest.java index a4b07f6255..d306f63b02 100644 --- a/Mage.Tests/src/test/java/org/mage/test/cards/single/cmd/FlusterstormTest.java +++ b/Mage.Tests/src/test/java/org/mage/test/cards/single/cmd/FlusterstormTest.java @@ -6,6 +6,7 @@ import org.junit.Test; import org.mage.test.serverside.base.CardTestPlayerBase; public class FlusterstormTest extends CardTestPlayerBase { + @Test public void testThatFlusterstormGoesToGraveyard() { addCard(Zone.BATTLEFIELD, playerA, "Mountain", 1); diff --git a/Mage/src/main/java/mage/abilities/common/AttacksAllTriggeredAbility.java b/Mage/src/main/java/mage/abilities/common/AttacksAllTriggeredAbility.java index c290a39cc2..b5991cf2e4 100644 --- a/Mage/src/main/java/mage/abilities/common/AttacksAllTriggeredAbility.java +++ b/Mage/src/main/java/mage/abilities/common/AttacksAllTriggeredAbility.java @@ -77,7 +77,7 @@ public class AttacksAllTriggeredAbility extends TriggeredAbilityImpl { switch (setTargetPointer) { case PERMANENT: for (Effect effect : getEffects()) { - effect.setTargetPointer(new FixedTarget(permanent.getId())); + effect.setTargetPointer(new FixedTarget(permanent, game)); } break; case PLAYER: diff --git a/Mage/src/main/java/mage/abilities/common/LeavesBattlefieldAllTriggeredAbility.java b/Mage/src/main/java/mage/abilities/common/LeavesBattlefieldAllTriggeredAbility.java index 1017d1bd3b..83d6d92f95 100644 --- a/Mage/src/main/java/mage/abilities/common/LeavesBattlefieldAllTriggeredAbility.java +++ b/Mage/src/main/java/mage/abilities/common/LeavesBattlefieldAllTriggeredAbility.java @@ -67,7 +67,7 @@ public class LeavesBattlefieldAllTriggeredAbility extends TriggeredAbilityImpl { for (Effect effect : this.getEffects()) { switch (setTargetPointer) { case PERMANENT: - effect.setTargetPointer(new FixedTarget(permanent.getId())); + effect.setTargetPointer(new FixedTarget(permanent, game)); break; case PLAYER: effect.setTargetPointer(new FixedTarget(permanent.getControllerId())); diff --git a/Mage/src/main/java/mage/abilities/common/LicidAbility.java b/Mage/src/main/java/mage/abilities/common/LicidAbility.java index 7963a7808c..e5aae7688f 100644 --- a/Mage/src/main/java/mage/abilities/common/LicidAbility.java +++ b/Mage/src/main/java/mage/abilities/common/LicidAbility.java @@ -1,4 +1,3 @@ - package mage.abilities.common; import java.util.ArrayList; @@ -78,7 +77,7 @@ class LicidEffect extends OneShotEffect { if (licid != null) { UUID messageId = UUID.randomUUID(); LicidContinuousEffect effect = new LicidContinuousEffect(messageId); - effect.setTargetPointer(new FixedTarget(licid.getId())); + effect.setTargetPointer(new FixedTarget(licid, game)); game.addEffect(effect, source); new AttachEffect(Outcome.Neutral).apply(game, source); SpecialAction specialAction = new LicidSpecialAction(this.specialActionCost, messageId, licid.getIdName()); diff --git a/Mage/src/main/java/mage/abilities/common/PutCardIntoGraveFromAnywhereAllTriggeredAbility.java b/Mage/src/main/java/mage/abilities/common/PutCardIntoGraveFromAnywhereAllTriggeredAbility.java index aaf1597ab7..c23396919e 100644 --- a/Mage/src/main/java/mage/abilities/common/PutCardIntoGraveFromAnywhereAllTriggeredAbility.java +++ b/Mage/src/main/java/mage/abilities/common/PutCardIntoGraveFromAnywhereAllTriggeredAbility.java @@ -85,7 +85,7 @@ public class PutCardIntoGraveFromAnywhereAllTriggeredAbility extends TriggeredAb switch (setTargetPointer) { case CARD: for (Effect effect : getEffects()) { - effect.setTargetPointer(new FixedTarget(card.getId(), card.getZoneChangeCounter(game))); + effect.setTargetPointer(new FixedTarget(card, game)); } break; case PLAYER: diff --git a/Mage/src/main/java/mage/abilities/common/TapForManaAllTriggeredAbility.java b/Mage/src/main/java/mage/abilities/common/TapForManaAllTriggeredAbility.java index dd5caf60c2..570487225f 100644 --- a/Mage/src/main/java/mage/abilities/common/TapForManaAllTriggeredAbility.java +++ b/Mage/src/main/java/mage/abilities/common/TapForManaAllTriggeredAbility.java @@ -52,7 +52,7 @@ public class TapForManaAllTriggeredAbility extends TriggeredAbilityImpl { } switch(setTargetPointer) { case PERMANENT: - getEffects().get(0).setTargetPointer(new FixedTarget(permanent.getId())); + getEffects().get(0).setTargetPointer(new FixedTarget(permanent, game)); break; case PLAYER: getEffects().get(0).setTargetPointer(new FixedTarget(permanent.getControllerId())); diff --git a/Mage/src/main/java/mage/abilities/common/TapForManaAllTriggeredManaAbility.java b/Mage/src/main/java/mage/abilities/common/TapForManaAllTriggeredManaAbility.java index 608e2f358b..9949441de1 100644 --- a/Mage/src/main/java/mage/abilities/common/TapForManaAllTriggeredManaAbility.java +++ b/Mage/src/main/java/mage/abilities/common/TapForManaAllTriggeredManaAbility.java @@ -49,7 +49,7 @@ public class TapForManaAllTriggeredManaAbility extends TriggeredManaAbility { effect.setValue("mana", mEvent.getMana()); switch(setTargetPointer) { case PERMANENT: - effect.setTargetPointer(new FixedTarget(permanent.getId())); + effect.setTargetPointer(new FixedTarget(permanent, game)); break; case PLAYER: effect.setTargetPointer(new FixedTarget(permanent.getControllerId())); diff --git a/Mage/src/main/java/mage/abilities/common/TapLandForManaAllTriggeredManaAbility.java b/Mage/src/main/java/mage/abilities/common/TapLandForManaAllTriggeredManaAbility.java index d236c19ce5..eedcc0c7ce 100644 --- a/Mage/src/main/java/mage/abilities/common/TapLandForManaAllTriggeredManaAbility.java +++ b/Mage/src/main/java/mage/abilities/common/TapLandForManaAllTriggeredManaAbility.java @@ -38,7 +38,7 @@ public class TapLandForManaAllTriggeredManaAbility extends TriggeredManaAbility Permanent permanent = game.getPermanentOrLKIBattlefield(event.getSourceId()); if (permanent != null && permanent.isLand()) { if (setTargetPointer) { - getEffects().get(0).setTargetPointer(new FixedTarget(permanent.getId())); + getEffects().get(0).setTargetPointer(new FixedTarget(permanent, game)); } return true; } diff --git a/Mage/src/main/java/mage/abilities/effects/CastCardFromGraveyardThenExileItEffect.java b/Mage/src/main/java/mage/abilities/effects/CastCardFromGraveyardThenExileItEffect.java index c17f6fae73..cf38222a36 100644 --- a/Mage/src/main/java/mage/abilities/effects/CastCardFromGraveyardThenExileItEffect.java +++ b/Mage/src/main/java/mage/abilities/effects/CastCardFromGraveyardThenExileItEffect.java @@ -34,7 +34,7 @@ public class CastCardFromGraveyardThenExileItEffect extends OneShotEffect { Card card = game.getCard(this.getTargetPointer().getFirst(game, source)); if (card != null) { ContinuousEffect effect = new CastCardFromGraveyardEffect(); - effect.setTargetPointer(new FixedTarget(card.getId(), card.getZoneChangeCounter(game))); + effect.setTargetPointer(new FixedTarget(card, game)); game.addEffect(effect, source); effect = new ExileReplacementEffect(card.getId()); game.addEffect(effect, source); diff --git a/Mage/src/main/java/mage/abilities/effects/common/CreateTokenCopyTargetEffect.java b/Mage/src/main/java/mage/abilities/effects/common/CreateTokenCopyTargetEffect.java index 88820aa027..7ffcd7f0ee 100644 --- a/Mage/src/main/java/mage/abilities/effects/common/CreateTokenCopyTargetEffect.java +++ b/Mage/src/main/java/mage/abilities/effects/common/CreateTokenCopyTargetEffect.java @@ -1,5 +1,9 @@ package mage.abilities.effects.common; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; +import java.util.UUID; import mage.MageObject; import mage.ObjectColor; import mage.abilities.Ability; @@ -20,11 +24,6 @@ import mage.util.CardUtil; import mage.util.functions.ApplyToPermanent; import mage.util.functions.EmptyApplyToPermanent; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.List; -import java.util.UUID; - /** * @author LevelX2 */ @@ -71,8 +70,8 @@ public class CreateTokenCopyTargetEffect extends OneShotEffect { } /** - * @param playerId null the token is controlled/owned by the controller of - * the source ability + * @param playerId null the token is controlled/owned by the + * controller of the source ability * @param additionalCardType the token gains this card type in addition * @param hasHaste the token gains haste * @param number number of tokens to put into play @@ -133,7 +132,7 @@ public class CreateTokenCopyTargetEffect extends OneShotEffect { } Permanent permanent; if (useLKI) { - permanent = ((FixedTarget) getTargetPointer()).getTargetedPermanentOrLKIBattlefield(game); + permanent = getTargetPointer().getFirstTargetPermanentOrLKI(game, source); } else { permanent = game.getPermanentOrLKIBattlefield(targetId); } diff --git a/Mage/src/main/java/mage/abilities/effects/common/DamageTargetControllerEffect.java b/Mage/src/main/java/mage/abilities/effects/common/DamageTargetControllerEffect.java index 1309db75fd..18ccef09a6 100644 --- a/Mage/src/main/java/mage/abilities/effects/common/DamageTargetControllerEffect.java +++ b/Mage/src/main/java/mage/abilities/effects/common/DamageTargetControllerEffect.java @@ -49,7 +49,7 @@ public class DamageTargetControllerEffect extends OneShotEffect { @Override public boolean apply(Game game, Ability source) { - Permanent permanent = game.getPermanentOrLKIBattlefield(getTargetPointer().getFirst(game, source)); + Permanent permanent = getTargetPointer().getFirstTargetPermanentOrLKI(game, source); if (permanent != null) { Player targetController = game.getPlayer(permanent.getControllerId()); if (targetController != null) { diff --git a/Mage/src/main/java/mage/abilities/effects/common/ExileAdventureSpellEffect.java b/Mage/src/main/java/mage/abilities/effects/common/ExileAdventureSpellEffect.java index 9c664bbf25..d6a5c84953 100644 --- a/Mage/src/main/java/mage/abilities/effects/common/ExileAdventureSpellEffect.java +++ b/Mage/src/main/java/mage/abilities/effects/common/ExileAdventureSpellEffect.java @@ -1,5 +1,6 @@ package mage.abilities.effects.common; +import java.util.UUID; import mage.abilities.Ability; import mage.abilities.MageSingleton; import mage.abilities.effects.AsThoughEffectImpl; @@ -17,8 +18,6 @@ import mage.players.Player; import mage.target.targetpointer.FixedTarget; import mage.util.CardUtil; -import java.util.UUID; - /** * @author phulin */ @@ -58,7 +57,7 @@ public class ExileAdventureSpellEffect extends OneShotEffect implements MageSing Card parentCard = adventureSpellCard.getParentCard(); if (controller.moveCardsToExile(parentCard, source, game, true, exileId, "On an Adventure from " + controller.getName())) { ContinuousEffect effect = new AdventureCastFromExileEffect(); - effect.setTargetPointer(new FixedTarget(parentCard.getId(), game)); + effect.setTargetPointer(new FixedTarget(parentCard, game)); game.addEffect(effect, source); } } @@ -104,4 +103,4 @@ class AdventureCastFromExileEffect extends AsThoughEffectImpl { } return false; } -} \ No newline at end of file +} diff --git a/Mage/src/main/java/mage/abilities/effects/common/InfoEffect.java b/Mage/src/main/java/mage/abilities/effects/common/InfoEffect.java index 7ac754b609..c9ede321ca 100644 --- a/Mage/src/main/java/mage/abilities/effects/common/InfoEffect.java +++ b/Mage/src/main/java/mage/abilities/effects/common/InfoEffect.java @@ -39,7 +39,7 @@ public class InfoEffect extends OneShotEffect { // add simple static info to permanent's rules SimpleStaticAbility ability = new SimpleStaticAbility(Zone.BATTLEFIELD, new InfoEffect(info)); GainAbilityTargetEffect gainAbilityEffect = new GainAbilityTargetEffect(ability, Duration.WhileOnBattlefield); - gainAbilityEffect.setTargetPointer(new FixedTarget(permanent.getId())); + gainAbilityEffect.setTargetPointer(new FixedTarget(permanent, game)); game.addEffect(gainAbilityEffect, source); } } diff --git a/Mage/src/main/java/mage/abilities/effects/keyword/BolsterEffect.java b/Mage/src/main/java/mage/abilities/effects/keyword/BolsterEffect.java index 3bf6a6c9f8..595a00b8d8 100644 --- a/Mage/src/main/java/mage/abilities/effects/keyword/BolsterEffect.java +++ b/Mage/src/main/java/mage/abilities/effects/keyword/BolsterEffect.java @@ -1,4 +1,3 @@ - package mage.abilities.effects.keyword; import mage.abilities.Ability; @@ -78,7 +77,7 @@ public class BolsterEffect extends OneShotEffect { } if (selectedCreature != null) { Effect effect = new AddCountersTargetEffect(CounterType.P1P1.createInstance(amount.calculate(game, source, this))); - effect.setTargetPointer(new FixedTarget(selectedCreature.getId())); + effect.setTargetPointer(new FixedTarget(selectedCreature, game)); return effect.apply(game, source); } } diff --git a/Mage/src/main/java/mage/filter/predicate/other/FaceDownPredicate.java b/Mage/src/main/java/mage/filter/predicate/other/FaceDownPredicate.java index c6079cf9d4..9edc49598c 100644 --- a/Mage/src/main/java/mage/filter/predicate/other/FaceDownPredicate.java +++ b/Mage/src/main/java/mage/filter/predicate/other/FaceDownPredicate.java @@ -1,9 +1,10 @@ - package mage.filter.predicate.other; +import mage.abilities.keyword.MorphAbility; import mage.cards.Card; import mage.filter.predicate.Predicate; import mage.game.Game; +import mage.game.permanent.Permanent; /** * @author North @@ -13,7 +14,15 @@ public enum FaceDownPredicate implements Predicate { @Override public boolean apply(Card input, Game game) { - return input.isFaceDown(game); + if (game.inCheckPlayableState()) { + // Check for cost reduction of possible face down spell to cast + if (input != null && !(input instanceof Permanent)) { + return input.getAbilities().containsClass(MorphAbility.class); + } + return false; + } else { + return input.isFaceDown(game); + } } @Override diff --git a/Mage/src/main/java/mage/game/command/emblems/DarettiScrapSavantEmblem.java b/Mage/src/main/java/mage/game/command/emblems/DarettiScrapSavantEmblem.java index 85a51c0e9a..d9104aa345 100644 --- a/Mage/src/main/java/mage/game/command/emblems/DarettiScrapSavantEmblem.java +++ b/Mage/src/main/java/mage/game/command/emblems/DarettiScrapSavantEmblem.java @@ -93,7 +93,7 @@ class DarettiScrapSavantEffect extends OneShotEffect { Card card = game.getCard(getTargetPointer().getFirst(game, source)); if (card != null && game.getState().getZone(card.getId()) == Zone.GRAVEYARD) { Effect effect = new ReturnFromGraveyardToBattlefieldTargetEffect(); - effect.setTargetPointer(new FixedTarget(card.getId(), card.getZoneChangeCounter(game))); + effect.setTargetPointer(new FixedTarget(card, game)); effect.setText("return that card to the battlefield at the beginning of the next end step"); game.addDelayedTriggeredAbility(new AtTheBeginOfNextEndStepDelayedTriggeredAbility(Zone.COMMAND, effect, TargetController.ANY), source); return true; diff --git a/Mage/src/main/java/mage/game/command/emblems/LilianaDefiantNecromancerEmblem.java b/Mage/src/main/java/mage/game/command/emblems/LilianaDefiantNecromancerEmblem.java index de57aa1f3c..abdf853a60 100644 --- a/Mage/src/main/java/mage/game/command/emblems/LilianaDefiantNecromancerEmblem.java +++ b/Mage/src/main/java/mage/game/command/emblems/LilianaDefiantNecromancerEmblem.java @@ -53,7 +53,7 @@ class LilianaDefiantNecromancerEmblemEffect extends OneShotEffect { Card card = game.getCard(getTargetPointer().getFirst(game, source)); if (card != null) { Effect effect = new ReturnFromGraveyardToBattlefieldTargetEffect(); - effect.setTargetPointer(new FixedTarget(card.getId(), card.getZoneChangeCounter(game))); + effect.setTargetPointer(new FixedTarget(card, game)); effect.setText("return that card to the battlefield at the beginning of the next end step"); game.addDelayedTriggeredAbility(new AtTheBeginOfNextEndStepDelayedTriggeredAbility(Zone.COMMAND, effect, TargetController.ANY), source); return true; diff --git a/Mage/src/main/java/mage/game/command/planes/AgyremPlane.java b/Mage/src/main/java/mage/game/command/planes/AgyremPlane.java index 400c1473c3..09812ac170 100644 --- a/Mage/src/main/java/mage/game/command/planes/AgyremPlane.java +++ b/Mage/src/main/java/mage/game/command/planes/AgyremPlane.java @@ -93,7 +93,7 @@ class AgyremEffect extends OneShotEffect { Card card = game.getCard(getTargetPointer().getFirst(game, source)); if (card != null) { Effect effect = new ReturnToBattlefieldUnderOwnerControlTargetEffect(false, false); - effect.setTargetPointer(new FixedTarget(card.getId(), card.getZoneChangeCounter(game))); + effect.setTargetPointer(new FixedTarget(card, game)); effect.setText("return that card to the battlefield under its owner's control at the beginning of the next end step"); game.addDelayedTriggeredAbility(new AtTheBeginOfNextEndStepDelayedTriggeredAbility(effect, TargetController.ANY), source); return true; @@ -123,7 +123,7 @@ class AgyremEffect2 extends OneShotEffect { Card card = game.getCard(getTargetPointer().getFirst(game, source)); if (card != null) { Effect effect = new ReturnFromGraveyardToHandTargetEffect(); - effect.setTargetPointer(new FixedTarget(card.getId(), card.getZoneChangeCounter(game))); + effect.setTargetPointer(new FixedTarget(card, game)); effect.setText("return it to its owner's hand at the beginning of the next end step"); game.addDelayedTriggeredAbility(new AtTheBeginOfNextEndStepDelayedTriggeredAbility(effect, TargetController.ANY), source); return true; diff --git a/Mage/src/main/java/mage/target/targetpointer/FirstTargetPointer.java b/Mage/src/main/java/mage/target/targetpointer/FirstTargetPointer.java index b35a440dfa..d3c535e7fb 100644 --- a/Mage/src/main/java/mage/target/targetpointer/FirstTargetPointer.java +++ b/Mage/src/main/java/mage/target/targetpointer/FirstTargetPointer.java @@ -5,8 +5,10 @@ import java.util.HashMap; import java.util.List; import java.util.Map; import java.util.UUID; +import mage.MageObject; import mage.abilities.Ability; import mage.cards.Card; +import mage.constants.Zone; import mage.game.Game; import mage.game.permanent.Permanent; @@ -94,4 +96,25 @@ public class FirstTargetPointer implements TargetPointer { } + @Override + public Permanent getFirstTargetPermanentOrLKI(Game game, Ability source) { + UUID targetId = source.getFirstTarget(); + Permanent permanent; + if (zoneChangeCounter.containsKey(targetId)) { + permanent = game.getPermanent(targetId); + if (permanent != null && permanent.getZoneChangeCounter(game) == zoneChangeCounter.get(targetId)) { + return permanent; + } + MageObject mageObject = game.getLastKnownInformation(targetId, Zone.BATTLEFIELD, zoneChangeCounter.get(targetId)); + if (mageObject instanceof Permanent) { + return (Permanent) mageObject; + } + } else { + permanent = game.getPermanent(targetId); + if (permanent == null) { + permanent = (Permanent) game.getLastKnownInformation(targetId, Zone.BATTLEFIELD); + } + } + return permanent; + } } diff --git a/Mage/src/main/java/mage/target/targetpointer/FixedTarget.java b/Mage/src/main/java/mage/target/targetpointer/FixedTarget.java index d125bcc84b..b6c7871b92 100644 --- a/Mage/src/main/java/mage/target/targetpointer/FixedTarget.java +++ b/Mage/src/main/java/mage/target/targetpointer/FixedTarget.java @@ -1,5 +1,10 @@ package mage.target.targetpointer; +import java.util.ArrayList; +import java.util.Collections; +import java.util.List; +import java.util.UUID; +import mage.MageObject; import mage.MageObjectReference; import mage.abilities.Ability; import mage.cards.Card; @@ -7,11 +12,6 @@ import mage.constants.Zone; import mage.game.Game; import mage.game.permanent.Permanent; -import java.util.ArrayList; -import java.util.Collections; -import java.util.List; -import java.util.UUID; - public class FixedTarget implements TargetPointer { private final UUID targetId; @@ -28,10 +28,11 @@ public class FixedTarget implements TargetPointer { } /** - * Target counter is immediatly initialised with current zoneChangeCounter value from the GameState - * Sets fixed the currect zone chnage counter + * Target counter is immediatly initialised with current zoneChangeCounter + * value from the GameState Sets fixed the currect zone chnage counter + * * @param card used to get the objectId - * @param game + * @param game */ public FixedTarget(Card card, Game game) { this.targetId = card.getId(); @@ -129,18 +130,23 @@ public class FixedTarget implements TargetPointer { return zoneChangeCounter; } - public Permanent getTargetedPermanentOrLKIBattlefield(Game game) { - Permanent permanent = game.getPermanentOrLKIBattlefield(targetId); - if (permanent != null && permanent.getZoneChangeCounter(game) != zoneChangeCounter) { - permanent = (Permanent) game.getLastKnownInformation(targetId, Zone.BATTLEFIELD, zoneChangeCounter); - } - return permanent; - } - @Override public FixedTarget getFixedTarget(Game game, Ability source) { init(game, source); return this; } + @Override + public Permanent getFirstTargetPermanentOrLKI(Game game, Ability source) { + Permanent permanent = game.getPermanent(targetId); + if (permanent != null && permanent.getZoneChangeCounter(game) == zoneChangeCounter) { + return permanent; + } + MageObject mageObject = game.getLastKnownInformation(targetId, Zone.BATTLEFIELD, zoneChangeCounter); + if (mageObject instanceof Permanent) { + return (Permanent) mageObject; + } + return null; + } + } diff --git a/Mage/src/main/java/mage/target/targetpointer/FixedTargets.java b/Mage/src/main/java/mage/target/targetpointer/FixedTargets.java index 620c796d4d..ccef9d4d40 100644 --- a/Mage/src/main/java/mage/target/targetpointer/FixedTargets.java +++ b/Mage/src/main/java/mage/target/targetpointer/FixedTargets.java @@ -5,17 +5,18 @@ */ package mage.target.targetpointer; -import mage.MageObjectReference; -import mage.abilities.Ability; -import mage.cards.Card; -import mage.cards.Cards; -import mage.game.Game; -import mage.game.permanent.Permanent; - import java.util.ArrayList; import java.util.List; import java.util.Set; import java.util.UUID; +import mage.MageObject; +import mage.MageObjectReference; +import mage.abilities.Ability; +import mage.cards.Card; +import mage.cards.Cards; +import mage.constants.Zone; +import mage.game.Game; +import mage.game.permanent.Permanent; /** * @author LevelX2 @@ -116,4 +117,34 @@ public class FixedTargets implements TargetPointer { } return null; } + + @Override + public Permanent getFirstTargetPermanentOrLKI(Game game, Ability source) { + UUID targetId = null; + int zoneChangeCounter = Integer.MIN_VALUE; + if (!targets.isEmpty()) { + MageObjectReference mor = targets.get(0); + targetId = mor.getSourceId(); + zoneChangeCounter = mor.getZoneChangeCounter(); + } else if (!targetsNotInitialized.isEmpty()) { + targetId = targetsNotInitialized.get(0); + } + if (targetId != null) { + Permanent permanent = game.getPermanent(targetId); + if (permanent != null + && (zoneChangeCounter == Integer.MIN_VALUE || permanent.getZoneChangeCounter(game) == zoneChangeCounter)) { + return permanent; + } + MageObject mageObject; + if (zoneChangeCounter == Integer.MIN_VALUE) { + mageObject = game.getLastKnownInformation(targetId, Zone.BATTLEFIELD); + } else { + mageObject = game.getLastKnownInformation(targetId, Zone.BATTLEFIELD, zoneChangeCounter); + } + if (mageObject instanceof Permanent) { + return (Permanent) mageObject; + } + } + return null; + } } diff --git a/Mage/src/main/java/mage/target/targetpointer/SecondTargetPointer.java b/Mage/src/main/java/mage/target/targetpointer/SecondTargetPointer.java index a1dcc24f1c..bbb54aa65e 100644 --- a/Mage/src/main/java/mage/target/targetpointer/SecondTargetPointer.java +++ b/Mage/src/main/java/mage/target/targetpointer/SecondTargetPointer.java @@ -1,9 +1,12 @@ package mage.target.targetpointer; import java.util.*; +import mage.MageObject; import mage.abilities.Ability; import mage.cards.Card; +import mage.constants.Zone; import mage.game.Game; +import mage.game.permanent.Permanent; public class SecondTargetPointer implements TargetPointer { @@ -81,4 +84,30 @@ public class SecondTargetPointer implements TargetPointer { } return null; } + + @Override + public Permanent getFirstTargetPermanentOrLKI(Game game, Ability source) { + if (source.getTargets().size() > 1) { + Permanent permanent; + UUID targetId = source.getTargets().get(1).getFirstTarget(); + if (zoneChangeCounter.containsKey(targetId)) { + permanent = game.getPermanent(targetId); + if (permanent != null && permanent.getZoneChangeCounter(game) == zoneChangeCounter.get(targetId)) { + return permanent; + } + MageObject mageObject = game.getLastKnownInformation(targetId, Zone.BATTLEFIELD, zoneChangeCounter.get(targetId)); + if (mageObject instanceof Permanent) { + return (Permanent) mageObject; + } + + } else { + permanent = game.getPermanent(targetId); + if (permanent == null) { + permanent = (Permanent) game.getLastKnownInformation(targetId, Zone.BATTLEFIELD); + } + } + return permanent; + } + return null; + } } diff --git a/Mage/src/main/java/mage/target/targetpointer/TargetPointer.java b/Mage/src/main/java/mage/target/targetpointer/TargetPointer.java index 6dd021c9ac..c55e6a290b 100644 --- a/Mage/src/main/java/mage/target/targetpointer/TargetPointer.java +++ b/Mage/src/main/java/mage/target/targetpointer/TargetPointer.java @@ -5,6 +5,7 @@ import java.util.List; import java.util.UUID; import mage.abilities.Ability; import mage.game.Game; +import mage.game.permanent.Permanent; public interface TargetPointer extends Serializable { @@ -17,4 +18,20 @@ public interface TargetPointer extends Serializable { TargetPointer copy(); FixedTarget getFixedTarget(Game game, Ability source); + + /** + * Retrieves the permanent according the first targetId and + * zoneChangeCounter if set.
+ * Retrieves also the LKI if the permanent is no longer onto the + * battlefield.
+ * This should not be used for true targeted objects, because they are not + * retrieved using LKI (608.2b).
+ * This is only used if the the target pointer is used to transfer + * information about a related permanent (often from triggered abilities). + * + * @param game + * @param source + * @return permanent + */ + Permanent getFirstTargetPermanentOrLKI(Game game, Ability source); } diff --git a/Mage/src/main/java/mage/target/targetpointer/ThirdTargetPointer.java b/Mage/src/main/java/mage/target/targetpointer/ThirdTargetPointer.java index b493d20aed..31639c3dbb 100644 --- a/Mage/src/main/java/mage/target/targetpointer/ThirdTargetPointer.java +++ b/Mage/src/main/java/mage/target/targetpointer/ThirdTargetPointer.java @@ -10,13 +10,16 @@ import java.util.HashMap; import java.util.List; import java.util.Map; import java.util.UUID; +import mage.MageObject; import mage.abilities.Ability; import mage.cards.Card; +import mage.constants.Zone; import mage.game.Game; +import mage.game.permanent.Permanent; /** * - * @author Ludwig.Hirth + * @author LevelX2 */ public class ThirdTargetPointer implements TargetPointer { @@ -95,4 +98,30 @@ public class ThirdTargetPointer implements TargetPointer { return null; } + + @Override + public Permanent getFirstTargetPermanentOrLKI(Game game, Ability source) { + if (source.getTargets().size() > 2) { + Permanent permanent; + UUID targetId = source.getTargets().get(2).getFirstTarget(); + if (zoneChangeCounter.containsKey(targetId)) { + permanent = game.getPermanent(targetId); + if (permanent != null && permanent.getZoneChangeCounter(game) == zoneChangeCounter.get(targetId)) { + return permanent; + } + MageObject mageObject = game.getLastKnownInformation(targetId, Zone.BATTLEFIELD, zoneChangeCounter.get(targetId)); + if (mageObject instanceof Permanent) { + return (Permanent) mageObject; + } + + } else { + permanent = game.getPermanent(targetId); + if (permanent == null) { + permanent = (Permanent) game.getLastKnownInformation(targetId, Zone.BATTLEFIELD); + } + } + return permanent; + } + return null; + } }