* Vivien, Arkbow Ranger - Fixed target handling of +1 ability.

This commit is contained in:
LevelX2 2020-01-10 15:49:55 +01:00
parent e91639a478
commit 2a0723b7cd
2 changed files with 90 additions and 6 deletions

View file

@ -21,9 +21,7 @@ import mage.target.common.TargetCreatureOrPlaneswalker;
import mage.target.common.TargetCreaturePermanentAmount;
import java.util.UUID;
import mage.filter.common.FilterCreaturePermanent;
import mage.game.Game;
import mage.target.common.TargetCreaturePermanent;
import mage.target.targetadjustment.TargetAdjuster;
/**
@ -45,8 +43,12 @@ public final class VivienArkbowRanger extends CardImpl {
TrampleAbility.getInstance(), Duration.EndOfTurn,
"They gain trample until end of turn"
));
ability.addTarget(new TargetCreaturePermanent(0, 2, new FilterCreaturePermanent(), false));
ability.setTargetAdjuster(VivienArkbowRangerAdjuster.instance);
TargetCreaturePermanentAmount target = new TargetCreaturePermanentAmount(2);
target.setMinNumberOfTargets(0);
target.setMaxNumberOfTargets(2);
ability.addTarget(target);
// ability.setTargetAdjuster(VivienArkbowRangerAdjuster.instance);
this.addAbility(ability);
// 3: Target creature you control deals damage equal to its power to target creature or planeswalker.
@ -77,7 +79,7 @@ public final class VivienArkbowRanger extends CardImpl {
@Override
public void adjustTargets(Ability ability, Game game) {
// if targets are available, switch over to a working target method
if (game.getBattlefield().getAllActivePermanents(new FilterCreaturePermanent(), game).size() > 0) {
if (game.getBattlefield().getAllActivePermanents(StaticFilters.FILTER_PERMANENT_CREATURE, game).size() > 0) {
ability.getTargets().clear();
ability.addTarget(new TargetCreaturePermanentAmount(2));
}

View file

@ -5,6 +5,7 @@
*/
package org.mage.test.cards.planeswalker;
import mage.abilities.keyword.TrampleAbility;
import mage.constants.PhaseStep;
import mage.constants.Zone;
import mage.counters.CounterType;
@ -18,7 +19,8 @@ import org.mage.test.serverside.base.CardTestPlayerBase;
public class VivienTest extends CardTestPlayerBase {
@Test
public void VivienArkbowRangerAbility1NoTargetsTest() {
public void testVivienArkbowRangerAbility1NoTargets() {
setStrictChooseMode(true);
// +1: Distribute two +1/+1 counters among up to two target creatures. They gain trample until end of turn.
// 3: Target creature you control deals damage equal to its power to target creature or planeswalker.
// 5: You may choose a creature card you own from outside the game, reveal it, and put it into your hand.
@ -37,4 +39,84 @@ public class VivienTest extends CardTestPlayerBase {
}
@Test
public void testVivienArkbowRangerAbility1OnePossibleTarget() {
setStrictChooseMode(true);
// +1: Distribute two +1/+1 counters among up to two target creatures. They gain trample until end of turn.
// 3: Target creature you control deals damage equal to its power to target creature or planeswalker.
// 5: You may choose a creature card you own from outside the game, reveal it, and put it into your hand.
addCard(Zone.HAND, playerA, "Vivien, Arkbow Ranger"); // Planeswalker {1}{G}{G}{G} - starts with 4 Loyality counters
addCard(Zone.BATTLEFIELD, playerA, "Forest", 4);
addCard(Zone.BATTLEFIELD, playerB, "Silvercoat Lion");
castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerA, "Vivien, Arkbow Ranger");
activateAbility(1, PhaseStep.PRECOMBAT_MAIN, playerA, "+1: Distribute");
setStopAt(1, PhaseStep.BEGIN_COMBAT);
execute();
assertPermanentCount(playerA, "Vivien, Arkbow Ranger", 1);
assertCounterCount("Vivien, Arkbow Ranger", CounterType.LOYALTY, 5);
assertPowerToughness(playerB, "Silvercoat Lion", 2, 2);
}
@Test
public void testVivienArkbowRangerAbility1OneOwnPossibleTarget() {
// +1: Distribute two +1/+1 counters among up to two target creatures. They gain trample until end of turn.
// 3: Target creature you control deals damage equal to its power to target creature or planeswalker.
// 5: You may choose a creature card you own from outside the game, reveal it, and put it into your hand.
addCard(Zone.HAND, playerA, "Vivien, Arkbow Ranger"); // Planeswalker {1}{G}{G}{G} - starts with 4 Loyality counters
addCard(Zone.BATTLEFIELD, playerA, "Forest", 4);
addCard(Zone.BATTLEFIELD, playerA, "Silvercoat Lion");
castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerA, "Vivien, Arkbow Ranger");
activateAbility(1, PhaseStep.PRECOMBAT_MAIN, playerA, "+1: Distribute");
addTargetAmount(playerA, "Silvercoat Lion", 2);
setStopAt(1, PhaseStep.BEGIN_COMBAT);
execute();
assertPermanentCount(playerA, "Vivien, Arkbow Ranger", 1);
assertCounterCount("Vivien, Arkbow Ranger", CounterType.LOYALTY, 5);
assertPowerToughness(playerA, "Silvercoat Lion", 4, 4);
}
@Test
public void testVivienArkbowRangerAbility1TwoOwnPossibleTarget() {
// +1: Distribute two +1/+1 counters among up to two target creatures. They gain trample until end of turn.
// 3: Target creature you control deals damage equal to its power to target creature or planeswalker.
// 5: You may choose a creature card you own from outside the game, reveal it, and put it into your hand.
addCard(Zone.HAND, playerA, "Vivien, Arkbow Ranger"); // Planeswalker {1}{G}{G}{G} - starts with 4 Loyality counters
addCard(Zone.BATTLEFIELD, playerA, "Forest", 4);
addCard(Zone.BATTLEFIELD, playerA, "Silvercoat Lion");
addCard(Zone.BATTLEFIELD, playerA, "Pillarfield Ox");
castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerA, "Vivien, Arkbow Ranger");
activateAbility(1, PhaseStep.PRECOMBAT_MAIN, playerA, "+1: Distribute");
addTargetAmount(playerA, "Silvercoat Lion", 1);
addTargetAmount(playerA, "Pillarfield Ox", 1);
setStopAt(1, PhaseStep.BEGIN_COMBAT);
execute();
assertPermanentCount(playerA, "Vivien, Arkbow Ranger", 1);
assertCounterCount("Vivien, Arkbow Ranger", CounterType.LOYALTY, 5);
assertPowerToughness(playerA, "Silvercoat Lion", 3, 3);
assertPowerToughness(playerA, "Pillarfield Ox", 3, 5);
assertAbility(playerA, "Silvercoat Lion", TrampleAbility.getInstance(), true);
assertAbility(playerA, "Pillarfield Ox", TrampleAbility.getInstance(), true);
}
}