* Improved some FixedTarget initializations.

This commit is contained in:
LevelX2 2020-08-31 10:54:59 +02:00
parent 50668a548f
commit 61315ec741
5 changed files with 95 additions and 13 deletions

View file

@ -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);
}

View file

@ -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;

View file

@ -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 Collectors first ability triggers when a creature
* enters the battlefield, use the creatures 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);
}
}

View file

@ -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;
}

View file

@ -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;