Merge origin/master

This commit is contained in:
LevelX2 2014-08-15 01:27:24 +02:00
commit dc072fb423
4 changed files with 49 additions and 4 deletions

View file

@ -125,4 +125,24 @@ public class CloudshiftTest extends CardTestPlayerBase {
}
@Test
public void testThatCardIsHandledAsNewInstanceAfterCloudshift() {
addCard(Zone.BATTLEFIELD, playerA, "Trostani, Selesnya's Voice");
addCard(Zone.BATTLEFIELD, playerA, "Forest", 4);
addCard(Zone.BATTLEFIELD, playerA, "Plains", 4);
addCard(Zone.HAND, playerA, "Grizzly Bears");
addCard(Zone.HAND, playerA, "Giant Growth");
addCard(Zone.HAND, playerA, "Cloudshift");
castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerA, "Grizzly Bears");
castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerA, "Giant Growth", "Grizzly Bears", "you gain life equal to that creature's toughness");
castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerA, "Cloudshift", "Grizzly Bears", null, "you gain life equal to that creature's toughness");
setStopAt(1, PhaseStep.POSTCOMBAT_MAIN);
execute();
assertLife(playerA, 27);
}
}

View file

@ -119,7 +119,7 @@ public class PersistTest extends CardTestPlayerBase {
castSpell(1, PhaseStep.POSTCOMBAT_MAIN, playerB, "Lightning Bolt", "Safehold Elite");
// choose triggered ability order
playerA.addChoice("When enchanted creature dies, put X 1/1 red and white Soldier creature token with haste onto the battlefield, where X is its power.");
castSpell(1, PhaseStep.POSTCOMBAT_MAIN, playerB, "Lightning Bolt", "Safehold Elite", "When enchanted creature dies, put X 1/1 red and white Soldier creature token with haste onto the battlefield, where X is its power");
//castSpell(1, PhaseStep.POSTCOMBAT_MAIN, playerB, "Lightning Bolt", "Safehold Elite", "When enchanted creature dies, put X 1/1 red and white Soldier creature token with haste onto the battlefield, where X is its power");
setStopAt(1, PhaseStep.END_TURN);
execute();

View file

@ -115,7 +115,7 @@ public class TestPlayer extends ComputerPlayer {
String command = action.getAction();
command = command.substring(command.indexOf("activate:") + 9);
String[] groups = command.split(";");
if (!checkSpellOnStackCondition(groups, game)) {
if (!checkSpellOnStackCondition(groups, game) || !checkSpellOnTopOfStackCondition(groups, game)) {
break;
}
for (Ability ability: this.getPlayable(game, true)) {
@ -371,7 +371,21 @@ public class TestPlayer extends ComputerPlayer {
if (groups.length > 2 && groups[2].startsWith("spellOnStack=")) {
String spellOnStack = groups[2].substring(13);
for (StackObject stackObject: game.getStack()) {
if (stackObject.getStackAbility().toString().equals(spellOnStack)) {
if (stackObject.getStackAbility().toString().indexOf(spellOnStack) >= 0) {
return true;
}
}
return false;
}
return true;
}
private boolean checkSpellOnTopOfStackCondition(String[] groups, Game game) {
if (groups.length > 2 && groups[2].startsWith("spellOnTopOfStack=")) {
String spellOnTopOFStack = groups[2].substring(18);
if (game.getStack().size() > 0) {
StackObject stackObject = game.getStack().getFirst();
if (stackObject != null && stackObject.getStackAbility().toString().indexOf(spellOnTopOFStack) >= 0) {
return true;
}
}
@ -384,7 +398,7 @@ public class TestPlayer extends ComputerPlayer {
boolean result = true;
for (int i = 1; i < groups.length; i++) {
String group = groups[i];
if (group.startsWith("spellOnStack")) {
if (group.startsWith("spellOnStack") || group.startsWith("spellOnTopOfStack")) {
break;
}
if (ability instanceof SpellAbility && ((SpellAbility) ability).getSpellAbilityType().equals(SpellAbilityType.SPLIT_FUSED)) {

View file

@ -671,6 +671,17 @@ public abstract class CardTestPlayerAPIImpl extends MageTestPlayerBase implement
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;
if (spellOnStack != null && !spellOnStack.isEmpty()) {
action += ";spellOnStack=" + spellOnStack;
}
if (spellOnTopOfStack != null && !spellOnTopOfStack.isEmpty()) {
action += ";spellOnTopOfStack=" + spellOnTopOfStack;
}
player.addAction(turnNum, step, action);
}
public void activateAbility(int turnNum, PhaseStep step, TestPlayer player, String ability) {
player.addAction(turnNum, step, "activate:" + ability);
}