From 61315ec74107a24e4717e40c29e36fe73ec6f65f Mon Sep 17 00:00:00 2001 From: LevelX2 Date: Mon, 31 Aug 2020 10:54:59 +0200 Subject: [PATCH] * Improved some FixedTarget initializations. --- .../src/mage/cards/j/JaceCunningCastaway.java | 2 +- Mage.Sets/src/mage/cards/p/PeltCollector.java | 2 +- .../cards/single/grn/PeltCollectorTest.java | 91 +++++++++++++++++++ .../emblems/VenserTheSojournerEmblem.java | 10 +- .../JaceCunningCastawayIllusionToken.java | 3 +- 5 files changed, 95 insertions(+), 13 deletions(-) create mode 100644 Mage.Tests/src/test/java/org/mage/test/cards/single/grn/PeltCollectorTest.java diff --git a/Mage.Sets/src/mage/cards/j/JaceCunningCastaway.java b/Mage.Sets/src/mage/cards/j/JaceCunningCastaway.java index 38841f6747..ec38cad3e7 100644 --- a/Mage.Sets/src/mage/cards/j/JaceCunningCastaway.java +++ b/Mage.Sets/src/mage/cards/j/JaceCunningCastaway.java @@ -150,7 +150,7 @@ class JaceCunningCastawayCopyEffect extends OneShotEffect { return false; } CreateTokenCopyTargetEffect effect = new CreateTokenCopyTargetEffect(source.getControllerId(), null, false, 2); - effect.setTargetPointer(new FixedTarget(source.getSourceId(), game)); + effect.setTargetPointer(new FixedTarget(permanent, game)); effect.setIsntLegendary(true); return effect.apply(game, source); } diff --git a/Mage.Sets/src/mage/cards/p/PeltCollector.java b/Mage.Sets/src/mage/cards/p/PeltCollector.java index bd267e7b5b..918fbce86c 100644 --- a/Mage.Sets/src/mage/cards/p/PeltCollector.java +++ b/Mage.Sets/src/mage/cards/p/PeltCollector.java @@ -93,7 +93,7 @@ class PeltCollectorAbility extends TriggeredAbilityImpl { if (isPowerGreater(sourceCreature, triggeringCreature) && triggeringCreature.isCreature() && triggeringCreature.isControlledBy(this.getControllerId())) { - this.getEffects().get(0).setTargetPointer(new FixedTarget(event.getTargetId())); + this.getEffects().setTargetPointer(new FixedTarget(triggeringCreature, game)); return true; } return false; diff --git a/Mage.Tests/src/test/java/org/mage/test/cards/single/grn/PeltCollectorTest.java b/Mage.Tests/src/test/java/org/mage/test/cards/single/grn/PeltCollectorTest.java new file mode 100644 index 0000000000..5a8e50c453 --- /dev/null +++ b/Mage.Tests/src/test/java/org/mage/test/cards/single/grn/PeltCollectorTest.java @@ -0,0 +1,91 @@ +package org.mage.test.cards.single.grn; + +import mage.abilities.keyword.TrampleAbility; +import mage.constants.PhaseStep; +import mage.constants.Zone; +import mage.filter.Filter; +import org.junit.Test; +import org.mage.test.serverside.base.CardTestPlayerBase; + +/** + * + * @author LevelX2 + */ +public class PeltCollectorTest extends CardTestPlayerBase { + + @Test + public void test_Simple() { + setStrictChooseMode(true); + + addCard(Zone.BATTLEFIELD, playerA, "Forest", 1); + addCard(Zone.BATTLEFIELD, playerA, "Plains", 2); + // Whenever another creature you control enters the battlefield or dies, if that creature's power is greater than Pelt Collector's, put a +1/+1 counter on Pelt Collector. + // As long as Pelt Collector has three or more +1/+1 counters on it, it has trample. + addCard(Zone.HAND, playerA, "Pelt Collector", 1); // Creature {G} + addCard(Zone.HAND, playerA, "Silvercoat Lion", 1); // Creature {1}{W} + + addCard(Zone.BATTLEFIELD, playerB, "Pelt Collector", 1);// Creature {G} + + castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerA, "Pelt Collector"); + castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerA, "Silvercoat Lion"); + + setStopAt(1, PhaseStep.BEGIN_COMBAT); + + execute(); + + assertAllCommandsUsed(); + + assertPowerToughness(playerB, "Pelt Collector", 1, 1); + + assertPowerToughness(playerA, "Silvercoat Lion", 2, 2); + assertPowerToughness(playerA, "Pelt Collector", 2, 2); + assertAbility(playerA, "Pelt Collector", TrampleAbility.getInstance(), false); + assertAbility(playerB, "Pelt Collector", TrampleAbility.getInstance(), false); + + } + + /** + * To determine if Pelt Collector’s first ability triggers when a creature + * enters the battlefield, use the creature’s power after applying any + * static abilities (such as that of Trostani Discordant) that modify its + * power. + */ + @Test + public void test_TrostaniDiscordant() { + setStrictChooseMode(true); + + addCard(Zone.BATTLEFIELD, playerA, "Forest", 2); + addCard(Zone.BATTLEFIELD, playerA, "Plains", 3); + // Whenever another creature you control enters the battlefield or dies, if that creature's power is greater than Pelt Collector's, put a +1/+1 counter on Pelt Collector. + // As long as Pelt Collector has three or more +1/+1 counters on it, it has trample. + addCard(Zone.HAND, playerA, "Pelt Collector", 1); // Creature {G} + addCard(Zone.HAND, playerA, "Silvercoat Lion", 1); // Creature {1}{W} + // Other creatures you control get +1/+1. + // When Trostani Discordant enters the battlefield, create two 1/1 white Soldier creature tokens with lifelink. + // At the beginning of your end step, each player gains control of all creatures they own. + addCard(Zone.HAND, playerA, "Trostani Discordant", 1); // Creature {3}{G}{W} /1/4) + + addCard(Zone.BATTLEFIELD, playerB, "Pelt Collector", 1);// Creature {G} + + castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerA, "Trostani Discordant"); + + castSpell(3, PhaseStep.PRECOMBAT_MAIN, playerA, "Pelt Collector"); + castSpell(3, PhaseStep.PRECOMBAT_MAIN, playerA, "Silvercoat Lion"); + + setStopAt(3, PhaseStep.BEGIN_COMBAT); + + execute(); + + assertAllCommandsUsed(); + + assertPowerToughness(playerB, "Pelt Collector", 1, 1); + + assertPowerToughness(playerA, "Soldier", 2, 2, Filter.ComparisonScope.All); + + assertPowerToughness(playerA, "Silvercoat Lion", 3, 3); + assertPowerToughness(playerA, "Pelt Collector", 3, 3); + assertAbility(playerA, "Pelt Collector", TrampleAbility.getInstance(), false); + assertAbility(playerB, "Pelt Collector", TrampleAbility.getInstance(), false); + + } +} diff --git a/Mage/src/main/java/mage/game/command/emblems/VenserTheSojournerEmblem.java b/Mage/src/main/java/mage/game/command/emblems/VenserTheSojournerEmblem.java index 127efd8d93..d83899e6c3 100644 --- a/Mage/src/main/java/mage/game/command/emblems/VenserTheSojournerEmblem.java +++ b/Mage/src/main/java/mage/game/command/emblems/VenserTheSojournerEmblem.java @@ -14,7 +14,6 @@ import mage.game.events.GameEvent.EventType; import mage.game.stack.Spell; import mage.target.Target; import mage.target.TargetPermanent; -import mage.target.targetpointer.FixedTarget; /** * @@ -44,7 +43,6 @@ class VenserTheSojournerSpellCastTriggeredAbility extends TriggeredAbilityImpl { * If true, the source that triggered the ability will be set as target to * effect. */ - protected boolean rememberSource = false; public VenserTheSojournerSpellCastTriggeredAbility(Effect effect, boolean optional) { super(Zone.COMMAND, effect, optional); @@ -54,7 +52,6 @@ class VenserTheSojournerSpellCastTriggeredAbility extends TriggeredAbilityImpl { public VenserTheSojournerSpellCastTriggeredAbility(final VenserTheSojournerSpellCastTriggeredAbility ability) { super(ability); filter = ability.filter; - this.rememberSource = ability.rememberSource; } @Override @@ -66,12 +63,7 @@ class VenserTheSojournerSpellCastTriggeredAbility extends TriggeredAbilityImpl { public boolean checkTrigger(GameEvent event, Game game) { if (event.getPlayerId().equals(this.getControllerId())) { Spell spell = game.getStack().getSpell(event.getTargetId()); - if (spell != null && filter.match(spell, game)) { - if (rememberSource) { - this.getEffects().get(0).setTargetPointer(new FixedTarget(spell.getId())); - } - return true; - } + return spell != null && filter.match(spell, game); } return false; } diff --git a/Mage/src/main/java/mage/game/permanent/token/JaceCunningCastawayIllusionToken.java b/Mage/src/main/java/mage/game/permanent/token/JaceCunningCastawayIllusionToken.java index d4dd3a6c8a..e1b6839f28 100644 --- a/Mage/src/main/java/mage/game/permanent/token/JaceCunningCastawayIllusionToken.java +++ b/Mage/src/main/java/mage/game/permanent/token/JaceCunningCastawayIllusionToken.java @@ -11,7 +11,6 @@ import mage.constants.Zone; import mage.game.Game; import mage.game.events.GameEvent; import mage.game.stack.Spell; -import mage.target.targetpointer.FixedTarget; /** * @@ -35,6 +34,7 @@ public final class JaceCunningCastawayIllusionToken extends TokenImpl { super(token); } + @Override public JaceCunningCastawayIllusionToken copy() { return new JaceCunningCastawayIllusionToken(this); } @@ -64,7 +64,6 @@ class IllusionTokenTriggeredAbility extends TriggeredAbilityImpl { public boolean checkTrigger(GameEvent event, Game game) { MageObject eventSourceObject = game.getObject(event.getSourceId()); if (event.getTargetId().equals(this.getSourceId()) && eventSourceObject instanceof Spell) { - getEffects().get(0).setTargetPointer(new FixedTarget(event.getPlayerId())); return true; } return false;