mirror of
https://github.com/magefree/mage.git
synced 2025-12-22 03:22:00 -08:00
Fixed initialisation of targetPointer in BoostEquippedEffect (fixes #790).
This commit is contained in:
parent
2d1755be2e
commit
8d7087d859
5 changed files with 105 additions and 22 deletions
|
|
@ -5,6 +5,7 @@ import mage.abilities.keyword.IntimidateAbility;
|
|||
import mage.abilities.keyword.LifelinkAbility;
|
||||
import mage.constants.PhaseStep;
|
||||
import mage.constants.Zone;
|
||||
import mage.counters.CounterType;
|
||||
import mage.game.permanent.Permanent;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
|
|
@ -73,7 +74,8 @@ public class CloudshiftTest extends CardTestPlayerBase {
|
|||
addCard(Zone.BATTLEFIELD, playerA, "Plains", 4);
|
||||
addCard(Zone.BATTLEFIELD, playerA, "Silvercoat Lion");
|
||||
addCard(Zone.BATTLEFIELD, playerA, "Bonesplitter");
|
||||
|
||||
|
||||
// Exile target creature you control, then return that card to the battlefield under your control.
|
||||
addCard(Zone.HAND, playerA, "Cloudshift");
|
||||
|
||||
activateAbility(1, PhaseStep.PRECOMBAT_MAIN, playerA, "Equip {1}", "Silvercoat Lion");
|
||||
|
|
@ -147,4 +149,82 @@ public class CloudshiftTest extends CardTestPlayerBase {
|
|||
assertLife(playerA, 27); // 5 from the first with Giant Growth + 2 from the second bear.
|
||||
}
|
||||
|
||||
/*
|
||||
I had a Stoneforge Mystic equipped with a Umesawa's Jitte. I activated Jitte 4 times to make
|
||||
Stoneforge Mystic 9/10. My opponent put into play a Flickerwisp with his AEther Vial and
|
||||
targeted my Stoneforge Mystic. At the end of my turn, Stoneforge Mystic came back as a 9/10,
|
||||
before going down to 1/2 normally once my turn ended.
|
||||
*/
|
||||
@Test
|
||||
public void testDontApplyEffectToNewInstanceOfPreviousEquipedPermanent() {
|
||||
addCard(Zone.BATTLEFIELD, playerA, "Plains", 4);
|
||||
addCard(Zone.BATTLEFIELD, playerA, "Silvercoat Lion");
|
||||
addCard(Zone.BATTLEFIELD, playerA, "Umezawa's Jitte");
|
||||
|
||||
// Exile target creature you control, then return that card to the battlefield under your control.
|
||||
addCard(Zone.HAND, playerA, "Cloudshift");
|
||||
|
||||
activateAbility(1, PhaseStep.PRECOMBAT_MAIN, playerA, "Equip {2}", "Silvercoat Lion");
|
||||
|
||||
attack(3, playerA, "Silvercoat Lion");
|
||||
|
||||
activateAbility(3, PhaseStep.END_COMBAT, playerA, "Remove a charge counter from {this}: Choose one —<br>&bull Equipped creature gets");
|
||||
setModeChoice(playerA, "1");
|
||||
castSpell(3, PhaseStep.END_COMBAT, playerA, "Cloudshift", "Silvercoat Lion", "Remove a charge counter from");
|
||||
|
||||
setStopAt(3, PhaseStep.POSTCOMBAT_MAIN);
|
||||
execute();
|
||||
|
||||
Permanent Umezawa = getPermanent("Umezawa's Jitte", playerA.getId());
|
||||
Permanent silvercoatLion = getPermanent("Silvercoat Lion", playerA.getId());
|
||||
|
||||
assertLife(playerA, 20);
|
||||
assertLife(playerB, 18);
|
||||
assertCounterCount("Umezawa's Jitte", CounterType.CHARGE, 1);
|
||||
assertPermanentCount(playerA,"Silvercoat Lion", 1);
|
||||
assertGraveyardCount(playerA,"Cloudshift", 1);
|
||||
Assert.assertTrue(silvercoatLion.getAttachments().isEmpty());
|
||||
Assert.assertTrue("Umezawa must not be connected to Silvercoat Lion",Umezawa.getAttachedTo() == null);
|
||||
assertPowerToughness(playerA, "Silvercoat Lion", 2, 2);
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testDontApplyEffectToNewInstanceOfPreviousEquipedPermanentFlickerwisp() {
|
||||
addCard(Zone.BATTLEFIELD, playerA, "Plains", 4);
|
||||
addCard(Zone.BATTLEFIELD, playerA, "Silvercoat Lion");
|
||||
addCard(Zone.BATTLEFIELD, playerA, "Umezawa's Jitte");
|
||||
|
||||
|
||||
addCard(Zone.BATTLEFIELD, playerB, "Plains", 3);
|
||||
// Flying
|
||||
// When Flickerwisp enters the battlefield, exile another target permanent. Return that
|
||||
// card to the battlefield under its owner's control at the beginning of the next end step.
|
||||
addCard(Zone.HAND, playerB, "Flickerwisp");
|
||||
|
||||
activateAbility(1, PhaseStep.PRECOMBAT_MAIN, playerA, "Equip {2}", "Silvercoat Lion");
|
||||
|
||||
attack(3, playerA, "Silvercoat Lion");
|
||||
|
||||
activateAbility(4, PhaseStep.DRAW, playerA, "Remove a charge counter from {this}: Choose one —<br>&bull Equipped creature gets");
|
||||
setModeChoice(playerA, "1");
|
||||
castSpell(4, PhaseStep.PRECOMBAT_MAIN, playerB, "Flickerwisp");
|
||||
addTarget(playerB, "Silvercoat Lion");
|
||||
|
||||
setStopAt(4, PhaseStep.END_TURN);
|
||||
execute();
|
||||
|
||||
Permanent Umezawa = getPermanent("Umezawa's Jitte", playerA.getId());
|
||||
Permanent silvercoatLion = getPermanent("Silvercoat Lion", playerA.getId());
|
||||
|
||||
assertLife(playerA, 20);
|
||||
assertLife(playerB, 18);
|
||||
assertCounterCount("Umezawa's Jitte", CounterType.CHARGE, 1);
|
||||
assertPermanentCount(playerA,"Silvercoat Lion", 1);
|
||||
assertPermanentCount(playerB,"Flickerwisp", 1);
|
||||
Assert.assertTrue(silvercoatLion.getAttachments().isEmpty());
|
||||
Assert.assertTrue("Umezawa must not be connected to Silvercoat Lion",Umezawa.getAttachedTo() == null);
|
||||
assertPowerToughness(playerA, "Silvercoat Lion", 2, 2);
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -125,7 +125,7 @@ public class TestPlayer extends ComputerPlayer {
|
|||
if (action.getAction().startsWith("activate:")) {
|
||||
String command = action.getAction();
|
||||
command = command.substring(command.indexOf("activate:") + 9);
|
||||
String[] groups = command.split(";");
|
||||
String[] groups = command.split("\\$");
|
||||
if (!checkSpellOnStackCondition(groups, game) || !checkSpellOnTopOfStackCondition(groups, game)) {
|
||||
break;
|
||||
}
|
||||
|
|
@ -148,7 +148,7 @@ public class TestPlayer extends ComputerPlayer {
|
|||
if (action.getAction().startsWith("manaActivate:")) {
|
||||
String command = action.getAction();
|
||||
command = command.substring(command.indexOf("manaActivate:") + 13);
|
||||
String[] groups = command.split(";");
|
||||
String[] groups = command.split("$");
|
||||
List<Permanent> manaPerms = this.getAvailableManaProducers(game);
|
||||
for (Permanent perm: manaPerms) {
|
||||
for (Ability manaAbility: perm.getAbilities().getAvailableManaAbilities(Zone.BATTLEFIELD, game)) {
|
||||
|
|
@ -176,7 +176,7 @@ public class TestPlayer extends ComputerPlayer {
|
|||
if (action.getAction().startsWith("addCounters:")) {
|
||||
String command = action.getAction();
|
||||
command = command.substring(command.indexOf("addCounters:") + 12);
|
||||
String[] groups = command.split(";");
|
||||
String[] groups = command.split("$");
|
||||
for (Permanent permanent : game.getBattlefield().getAllActivePermanents()) {
|
||||
if (permanent.getName().equals(groups[0])) {
|
||||
Counter counter = new Counter(groups[1], Integer.parseInt(groups[2]));
|
||||
|
|
@ -204,7 +204,7 @@ public class TestPlayer extends ComputerPlayer {
|
|||
}
|
||||
String command = action.getAction();
|
||||
command = command.substring(command.indexOf("attack:") + 7);
|
||||
String[] groups = command.split(";");
|
||||
String[] groups = command.split("$");
|
||||
for (int i = 1; i < groups.length; i++) {
|
||||
String group = groups[i];
|
||||
if (group.startsWith("planeswalker=")) {
|
||||
|
|
@ -234,7 +234,7 @@ public class TestPlayer extends ComputerPlayer {
|
|||
if (action.getTurnNum() == game.getTurnNum() && action.getAction().startsWith("block:")) {
|
||||
String command = action.getAction();
|
||||
command = command.substring(command.indexOf("block:") + 6);
|
||||
String[] groups = command.split(";");
|
||||
String[] groups = command.split("$");
|
||||
FilterCreatureForCombatBlock filterBlocker = new FilterCreatureForCombatBlock();
|
||||
filterBlocker.add(new NamePredicate(groups[0]));
|
||||
filterBlocker.add(Predicates.not(new BlockingPredicate()));
|
||||
|
|
|
|||
|
|
@ -697,11 +697,11 @@ public abstract class CardTestPlayerAPIImpl extends MageTestPlayerBase implement
|
|||
}
|
||||
|
||||
public void castSpell(int turnNum, PhaseStep step, TestPlayer player, String cardName, Player target) {
|
||||
player.addAction(turnNum, step, "activate:Cast " + cardName + ";targetPlayer=" + target.getName());
|
||||
player.addAction(turnNum, step, "activate:Cast " + cardName + "$targetPlayer=" + target.getName());
|
||||
}
|
||||
|
||||
public void castSpell(int turnNum, PhaseStep step, TestPlayer player, String cardName, String targetName) {
|
||||
player.addAction(turnNum, step, "activate:Cast " + cardName + ";target=" + targetName);
|
||||
player.addAction(turnNum, step, "activate:Cast " + cardName + "$target=" + targetName);
|
||||
}
|
||||
|
||||
public enum StackClause {
|
||||
|
|
@ -736,19 +736,19 @@ public abstract class CardTestPlayerAPIImpl extends MageTestPlayerBase implement
|
|||
*/
|
||||
public void castSpell(int turnNum, PhaseStep step, TestPlayer player, String cardName, String targetName, String spellOnStack, StackClause clause) {
|
||||
if (StackClause.WHILE_ON_STACK.equals(clause)) {
|
||||
player.addAction(turnNum, step, "activate:Cast " + cardName + ";target=" + targetName + ";spellOnStack=" + spellOnStack);
|
||||
player.addAction(turnNum, step, "activate:Cast " + cardName + "$target=" + targetName + "$spellOnStack=" + spellOnStack);
|
||||
} else {
|
||||
player.addAction(turnNum, step, "activate:Cast " + cardName + ";target=" + targetName + ";!spellOnStack=" + spellOnStack);
|
||||
player.addAction(turnNum, step, "activate:Cast " + cardName + "$target=" + targetName + "$!spellOnStack=" + spellOnStack);
|
||||
}
|
||||
}
|
||||
|
||||
public void castSpell(int turnNum, PhaseStep step, TestPlayer player, String cardName, String targetName, String spellOnStack, String spellOnTopOfStack) {
|
||||
String action = "activate:Cast " + cardName + ";target=" + targetName;
|
||||
String action = "activate:Cast " + cardName + "$target=" + targetName;
|
||||
if (spellOnStack != null && !spellOnStack.isEmpty()) {
|
||||
action += ";spellOnStack=" + spellOnStack;
|
||||
action += "$spellOnStack=" + spellOnStack;
|
||||
}
|
||||
if (spellOnTopOfStack != null && !spellOnTopOfStack.isEmpty()) {
|
||||
action += ";spellOnTopOfStack=" + spellOnTopOfStack;
|
||||
action += "$spellOnTopOfStack=" + spellOnTopOfStack;
|
||||
}
|
||||
player.addAction(turnNum, step, action);
|
||||
}
|
||||
|
|
@ -762,26 +762,26 @@ public abstract class CardTestPlayerAPIImpl extends MageTestPlayerBase implement
|
|||
}
|
||||
|
||||
public void activateAbility(int turnNum, PhaseStep step, TestPlayer player, String ability, Player target) {
|
||||
player.addAction(turnNum, step, "activate:" + ability + ";targetPlayer=" + target.getName());
|
||||
player.addAction(turnNum, step, "activate:" + ability + "$targetPlayer=" + target.getName());
|
||||
}
|
||||
|
||||
public void activateAbility(int turnNum, PhaseStep step, TestPlayer player, String ability, String targetName) {
|
||||
player.addAction(turnNum, step, "activate:" + ability + ";target=" + targetName);
|
||||
player.addAction(turnNum, step, "activate:" + ability + "$target=" + targetName);
|
||||
}
|
||||
|
||||
public void activateAbility(int turnNum, PhaseStep step, TestPlayer player, String ability, String targetName, String spellOnStack) {
|
||||
StringBuilder sb = new StringBuilder("activate:").append(ability);
|
||||
if (targetName != null && !targetName.isEmpty()) {
|
||||
sb.append(";target=" ).append(targetName);
|
||||
sb.append("$target=" ).append(targetName);
|
||||
}
|
||||
if (spellOnStack != null && !spellOnStack.isEmpty()) {
|
||||
sb.append(";spellOnStack=").append(spellOnStack);
|
||||
sb.append("$spellOnStack=").append(spellOnStack);
|
||||
}
|
||||
player.addAction(turnNum, step, sb.toString());
|
||||
}
|
||||
|
||||
public void addCounters(int turnNum, PhaseStep step, TestPlayer player, String cardName, CounterType type, int count) {
|
||||
player.addAction(turnNum, step, "addCounters:" + cardName + ";" + type.getName() + ";" + count);
|
||||
player.addAction(turnNum, step, "addCounters:" + cardName + "$" + type.getName() + "$" + count);
|
||||
}
|
||||
|
||||
public void attack(int turnNum, TestPlayer player, String attacker) {
|
||||
|
|
@ -789,11 +789,11 @@ public abstract class CardTestPlayerAPIImpl extends MageTestPlayerBase implement
|
|||
}
|
||||
|
||||
public void attack(int turnNum, TestPlayer player, String attacker, String planeswalker) {
|
||||
player.addAction(turnNum, PhaseStep.DECLARE_ATTACKERS, new StringBuilder("attack:").append(attacker).append(";planeswalker=").append(planeswalker).toString());
|
||||
player.addAction(turnNum, PhaseStep.DECLARE_ATTACKERS, new StringBuilder("attack:").append(attacker).append("$planeswalker=").append(planeswalker).toString());
|
||||
}
|
||||
|
||||
public void block(int turnNum, TestPlayer player, String blocker, String attacker) {
|
||||
player.addAction(turnNum, PhaseStep.DECLARE_BLOCKERS, "block:"+blocker+";"+attacker);
|
||||
player.addAction(turnNum, PhaseStep.DECLARE_BLOCKERS, "block:"+blocker+"$"+attacker);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue