Merge pull request #2866 from goesta/BouncingCrewedVehicleTest

Bouncing crewed vehicle test
This commit is contained in:
ingmargoudt 2017-02-15 23:55:11 +01:00 committed by GitHub
commit 7d655ce745
2 changed files with 49 additions and 10 deletions

View file

@ -81,4 +81,27 @@ public class CrewTest extends CardTestPlayerBase {
assertType("Smuggler's Copter", CardType.CREATURE, "Vehicle"); assertType("Smuggler's Copter", CardType.CREATURE, "Vehicle");
} }
@Test
public void testThatBouncingACrewedVehicleWillUncrewIt() {
addCard(Zone.BATTLEFIELD, playerA, "Smuggler's Copter", 1);
addCard(Zone.BATTLEFIELD, playerA, "Speedway Fanatic", 1);
addCard(Zone.BATTLEFIELD, playerA, "Island", 7);
addCard(Zone.HAND, playerA, "Evacuation", 1);
activateAbility(1, PhaseStep.PRECOMBAT_MAIN, playerA, "Crew 1");
setChoice(playerA, "Speedway Fanatic");
// Return all creatures to there owners hands
castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerA, "Evacuation");
// (Re)Cast Smugglers Copter
castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerA, "Smuggler's Copter");
setStopAt(1, PhaseStep.BEGIN_COMBAT);
execute();
// Only crewed vehicles have card type creature
assertNotType("Smuggler's Copter", CardType.CREATURE);
}
} }

View file

@ -703,22 +703,24 @@ public abstract class CardTestPlayerAPIImpl extends MageTestPlayerBase implement
* @param subType a subtype to test for * @param subType a subtype to test for
*/ */
public void assertType(String cardName, CardType type, String subType) throws AssertionError { public void assertType(String cardName, CardType type, String subType) throws AssertionError {
Permanent found = null; Permanent found = getPermanent(cardName);
for (Permanent permanent : currentGame.getBattlefield().getAllActivePermanents()) {
if (permanent.getName().equals(cardName)) {
found = permanent;
break;
}
}
Assert.assertNotNull("There is no such permanent on the battlefield, cardName=" + cardName, found);
Assert.assertTrue("(Battlefield) card type not found (" + cardName + ':' + type + ')', found.getCardType().contains(type)); Assert.assertTrue("(Battlefield) card type not found (" + cardName + ':' + type + ')', found.getCardType().contains(type));
if (subType != null) { if (subType != null) {
Assert.assertTrue("(Battlefield) card sub-type not equal (" + cardName + ':' + subType + ')', found.getSubtype(currentGame).contains(subType)); Assert.assertTrue("(Battlefield) card sub-type not equal (" + cardName + ':' + subType + ')', found.getSubtype(currentGame).contains(subType));
} }
} }
/**
* Assert whether a permanent is not a specified type
*
* @param cardName Name of the permanent that should be checked.
* @param type A type to test for
*/
public void assertNotType(String cardName, CardType type) throws AssertionError {
Permanent found = getPermanent(cardName);
Assert.assertFalse("(Battlefield) card type found (" + cardName + ':' + type + ')', found.getCardType().contains(type));
}
/** /**
* Assert whether a permanent is tapped or not * Assert whether a permanent is tapped or not
* *
@ -922,6 +924,20 @@ public abstract class CardTestPlayerAPIImpl extends MageTestPlayerBase implement
Assert.assertEquals("message", currentGame.getState().getActivePlayerId(), player.getId()); Assert.assertEquals("message", currentGame.getState().getActivePlayerId(), player.getId());
} }
public Permanent getPermanent(String cardName) {
Permanent found = null;
for (Permanent permanent : currentGame.getBattlefield().getAllActivePermanents()) {
if (permanent.getName().equals(cardName)) {
found = permanent;
break;
}
}
Assert.assertNotNull("Couldn't find a card with specified name: " + cardName, found);
return found;
}
public Permanent getPermanent(String cardName, Player player) { public Permanent getPermanent(String cardName, Player player) {
return getPermanent(cardName, player.getId()); return getPermanent(cardName, player.getId());
} }