Test and fix for Soulbound with ExileAndReturnBack effect

This commit is contained in:
magenoxx 2012-05-26 21:57:53 +04:00
parent 06a185a3a5
commit def0260b9d
3 changed files with 29 additions and 4 deletions

View file

@ -5,6 +5,8 @@ import mage.abilities.Abilities;
import mage.abilities.AbilitiesImpl; import mage.abilities.AbilitiesImpl;
import mage.abilities.keyword.LifelinkAbility; import mage.abilities.keyword.LifelinkAbility;
import mage.filter.Filter; import mage.filter.Filter;
import mage.game.permanent.Permanent;
import org.junit.Assert;
import org.junit.Test; import org.junit.Test;
import org.mage.test.serverside.base.CardTestPlayerBase; import org.mage.test.serverside.base.CardTestPlayerBase;
@ -352,17 +354,25 @@ public class SoulbondKeywordTest extends CardTestPlayerBase {
@Test @Test
public void testExileAndReturnBack() { public void testExileAndReturnBack() {
addCard(Constants.Zone.HAND, playerA, "Elite Vanguard"); addCard(Constants.Zone.HAND, playerA, "Elite Vanguard");
addCard(Constants.Zone.HAND, playerA, "Cloudshift");
addCard(Constants.Zone.BATTLEFIELD, playerA, "Trusted Forcemage"); addCard(Constants.Zone.BATTLEFIELD, playerA, "Trusted Forcemage");
addCard(Constants.Zone.BATTLEFIELD, playerA, "Plains", 2); addCard(Constants.Zone.BATTLEFIELD, playerA, "Plains", 2);
castSpell(1, Constants.PhaseStep.PRECOMBAT_MAIN, playerA, "Elite Vanguard"); castSpell(1, Constants.PhaseStep.PRECOMBAT_MAIN, playerA, "Elite Vanguard");
setChoice(playerA, "Yes");
castSpell(1, Constants.PhaseStep.POSTCOMBAT_MAIN, playerA, "Cloudshift", "Trusted Forcemage"); castSpell(1, Constants.PhaseStep.POSTCOMBAT_MAIN, playerA, "Cloudshift", "Trusted Forcemage");
setChoice(playerA, "No");
setStopAt(1, Constants.PhaseStep.BEGIN_COMBAT); setStopAt(1, Constants.PhaseStep.END_TURN);
execute(); execute();
assertPermanentCount(playerA, "Trusted Forcemage", 1); assertPermanentCount(playerA, "Trusted Forcemage", 1);
assertPowerToughness(playerA, "Trusted Forcemage", 3, 3); assertPowerToughness(playerA, "Trusted Forcemage", 2, 2);
assertPowerToughness(playerA, "Elite Vanguard", 3, 2); assertPowerToughness(playerA, "Elite Vanguard", 2, 1);
Permanent trustedForcemange = getPermanent("Trusted Forcemage", playerA.getId());
Permanent eliteVanguard = getPermanent("Elite Vanguard", playerA.getId());
Assert.assertTrue(trustedForcemange.getPairedCard() == null);
Assert.assertTrue(eliteVanguard.getPairedCard() == null);
} }
} }

View file

@ -202,6 +202,21 @@ public class TestPlayer extends ComputerPlayer<TestPlayer> {
} }
return super.choose(outcome, target, sourceId, game, options); return super.choose(outcome, target, sourceId, game, options);
} }
@Override
public boolean chooseUse(Constants.Outcome outcome, String message, Game game) {
if (!choices.isEmpty()) {
if (choices.get(0).equals("No")) {
choices.remove(0);
return false;
}
if (choices.get(0).equals("Yes")) {
choices.remove(0);
return true;
}
}
return true;
}
protected Permanent findPermanent(FilterPermanent filter, UUID controllerId, Game game) { protected Permanent findPermanent(FilterPermanent filter, UUID controllerId, Game game) {
List<Permanent> permanents = game.getBattlefield().getAllActivePermanents(filter, controllerId, game); List<Permanent> permanents = game.getBattlefield().getAllActivePermanents(filter, controllerId, game);

View file

@ -861,7 +861,7 @@ public abstract class GameImpl<T extends GameImpl<T>> implements Game, Serializa
//702.93e.: ...another player gains control //702.93e.: ...another player gains control
// ...or the creature it's paired with leaves the battlefield. // ...or the creature it's paired with leaves the battlefield.
Permanent paired = getPermanent(perm.getPairedCard()); Permanent paired = getPermanent(perm.getPairedCard());
if (paired == null || !perm.getControllerId().equals(paired.getControllerId())) { if (paired == null || !perm.getControllerId().equals(paired.getControllerId()) || paired.getPairedCard() == null) {
perm.setPairedCard(null); perm.setPairedCard(null);
if (paired != null) { if (paired != null) {
paired.setPairedCard(null); paired.setPairedCard(null);