* Fixed bug in DamagedBatchEvent (fixes #7241). Fixed some spelling in test classes.

This commit is contained in:
LevelX2 2020-12-17 17:39:17 +01:00
parent 991019088f
commit d39575c24e
7 changed files with 55 additions and 56 deletions

View file

@ -41,11 +41,10 @@ public final class PromiseOfTomorrow extends CardImpl {
// At the beginning of each end step, if you control no creatures, sacrifice Promise of Tomorrow and return all cards exiled with it to the battlefield under your control. // At the beginning of each end step, if you control no creatures, sacrifice Promise of Tomorrow and return all cards exiled with it to the battlefield under your control.
BeginningOfEndStepTriggeredAbility returnAbility = new BeginningOfEndStepTriggeredAbility(new SacrificeSourceEffect(), TargetController.ANY, false); BeginningOfEndStepTriggeredAbility returnAbility = new BeginningOfEndStepTriggeredAbility(new SacrificeSourceEffect(), TargetController.ANY, false);
returnAbility.addEffect(new ReturnFromExileForSourceEffect(Zone.BATTLEFIELD)); returnAbility.addEffect(new ReturnFromExileForSourceEffect(Zone.BATTLEFIELD));
Ability ability = new ConditionalInterveningIfTriggeredAbility( this.addAbility(new ConditionalInterveningIfTriggeredAbility(
returnAbility, condition, "At the beginning of each end step, if you control no creatures, " + returnAbility, condition, "At the beginning of each end step, if you control no creatures, " +
"sacrifice {this} and return all cards exiled with it to the battlefield under your control." "sacrifice {this} and return all cards exiled with it to the battlefield under your control."
); ));
this.addAbility(ability);
} }
private PromiseOfTomorrow(final PromiseOfTomorrow card) { private PromiseOfTomorrow(final PromiseOfTomorrow card) {

View file

@ -31,8 +31,8 @@ public class PromiseOfTomorrowTest extends CardTestCommander4Players {
checkExileCount("after die", 1, PhaseStep.PRECOMBAT_MAIN, playerA, "Balduvian Bears", 2); checkExileCount("after die", 1, PhaseStep.PRECOMBAT_MAIN, playerA, "Balduvian Bears", 2);
// must return // must return
checkPermanentCount("after return", 2, PhaseStep.PRECOMBAT_MAIN, playerA, "Balduvian Bears", 2);
checkGraveyardCount("after return", 2, PhaseStep.PRECOMBAT_MAIN, playerA, "Promise of Tomorrow", 1); checkGraveyardCount("after return", 2, PhaseStep.PRECOMBAT_MAIN, playerA, "Promise of Tomorrow", 1);
checkPermanentCount("after return", 2, PhaseStep.PRECOMBAT_MAIN, playerA, "Balduvian Bears", 2);
setStrictChooseMode(true); setStrictChooseMode(true);
setStopAt(2, PhaseStep.END_TURN); setStopAt(2, PhaseStep.END_TURN);

View file

@ -67,7 +67,7 @@ public class UnpredictableCycloneTest extends CardTestPlayerBase {
showAvailableAbilities("before", 1, PhaseStep.PRECOMBAT_MAIN, playerA); showAvailableAbilities("before", 1, PhaseStep.PRECOMBAT_MAIN, playerA);
activateAbility(1, PhaseStep.PRECOMBAT_MAIN, playerA, "Cycling"); activateAbility(1, PhaseStep.PRECOMBAT_MAIN, playerA, "Cycling");
setChoice(playerA, "Thought Reflection"); // apply doubling first setChoice(playerA, "Thought Reflection"); // apply doubling first
setChoice(playerA, "Yes", 2); // cast founded library cards setChoice(playerA, "Yes", 2); // cast found library cards
setStrictChooseMode(true); setStrictChooseMode(true);
setStopAt(1, PhaseStep.END_TURN); setStopAt(1, PhaseStep.END_TURN);
@ -92,10 +92,10 @@ public class UnpredictableCycloneTest extends CardTestPlayerBase {
activateAbility(1, PhaseStep.PRECOMBAT_MAIN, playerA, "Cycling"); activateAbility(1, PhaseStep.PRECOMBAT_MAIN, playerA, "Cycling");
// from first cycle call // from first cycle call
setChoice(playerA, "Thought Reflection", 2); // 3 triggers: 2x doubling + 1x cycle setChoice(playerA, "Thought Reflection", 2); // 3 triggers: 2x doubling + 1x cycle
setChoice(playerA, "Yes", 2); // cast founded library cards for 2x doubling triggers setChoice(playerA, "Yes", 2); // cast found library cards for 2x doubling triggers
// from triggered cycle // from triggered cycle
setChoice(playerA, "Thought Reflection", 1); // 2 triggers: 1x doubling + 1x cycle setChoice(playerA, "Thought Reflection", 1); // 2 triggers: 1x doubling + 1x cycle
setChoice(playerA, "Yes", 2); // cast founded library cards for 2x doubling triggers setChoice(playerA, "Yes", 2); // cast found library cards for 2x doubling triggers
setStrictChooseMode(true); setStrictChooseMode(true);
setStopAt(1, PhaseStep.END_TURN); setStopAt(1, PhaseStep.END_TURN);
@ -120,7 +120,7 @@ public class UnpredictableCycloneTest extends CardTestPlayerBase {
castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerA, "Plagiarize", playerB); castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerA, "Plagiarize", playerB);
activateAbility(1, PhaseStep.POSTCOMBAT_MAIN, playerB, "Cycling"); activateAbility(1, PhaseStep.POSTCOMBAT_MAIN, playerB, "Cycling");
setChoice(playerA, "Yes"); // cast founded library card setChoice(playerA, "Yes"); // cast found library card
setStrictChooseMode(true); setStrictChooseMode(true);
setStopAt(1, PhaseStep.END_TURN); setStopAt(1, PhaseStep.END_TURN);

View file

@ -1257,31 +1257,31 @@ public class TestPlayer implements Player {
private void assertAbility(PlayerAction action, Game game, Player player, String permanentName, String abilityClass, boolean mustHave) { private void assertAbility(PlayerAction action, Game game, Player player, String permanentName, String abilityClass, boolean mustHave) {
Permanent perm = findPermanentWithAssert(action, game, player, permanentName); Permanent perm = findPermanentWithAssert(action, game, player, permanentName);
boolean founded = false; boolean found = false;
for (Ability ability : perm.getAbilities(game)) { for (Ability ability : perm.getAbilities(game)) {
if (ability.getClass().getName().equals(abilityClass)) { if (ability.getClass().getName().equals(abilityClass)) {
founded = true; found = true;
break; break;
} }
} }
if (mustHave) { if (mustHave) {
Assert.assertEquals(action.getActionName() + " - permanent " + permanentName + " must have the ability " + abilityClass, true, founded); Assert.assertEquals(action.getActionName() + " - permanent " + permanentName + " must have the ability " + abilityClass, true, found);
} else { } else {
Assert.assertEquals(action.getActionName() + " - permanent " + permanentName + " must not have the ability " + abilityClass, false, founded); Assert.assertEquals(action.getActionName() + " - permanent " + permanentName + " must not have the ability " + abilityClass, false, found);
} }
} }
private void assertPlayableAbility(PlayerAction action, Game game, Player player, String abilityStartText, boolean mustHave) { private void assertPlayableAbility(PlayerAction action, Game game, Player player, String abilityStartText, boolean mustHave) {
boolean founded = false; boolean found = false;
for (Ability ability : computerPlayer.getPlayable(game, true)) { for (Ability ability : computerPlayer.getPlayable(game, true)) {
if (ability.toString().startsWith(abilityStartText)) { if (ability.toString().startsWith(abilityStartText)) {
founded = true; found = true;
break; break;
} }
} }
if (mustHave && !founded) { if (mustHave && !found) {
printStart("Available mana for " + computerPlayer.getName()); printStart("Available mana for " + computerPlayer.getName());
printMana(game, computerPlayer.getManaAvailable(game)); printMana(game, computerPlayer.getManaAvailable(game));
printStart(action.getActionName()); printStart(action.getActionName());
@ -1290,7 +1290,7 @@ public class TestPlayer implements Player {
Assert.fail("Must have playable ability, but not found: " + abilityStartText); Assert.fail("Must have playable ability, but not found: " + abilityStartText);
} }
if (!mustHave && founded) { if (!mustHave && found) {
printStart("Available mana for " + computerPlayer.getName()); printStart("Available mana for " + computerPlayer.getName());
printMana(game, computerPlayer.getManaAvailable(game)); printMana(game, computerPlayer.getManaAvailable(game));
printStart(action.getActionName()); printStart(action.getActionName());
@ -1301,82 +1301,82 @@ public class TestPlayer implements Player {
} }
private void assertPermanentCount(PlayerAction action, Game game, Player player, String permanentName, int count) { private void assertPermanentCount(PlayerAction action, Game game, Player player, String permanentName, int count) {
int foundedCount = 0; int foundCount = 0;
for (Permanent perm : game.getBattlefield().getAllPermanents()) { for (Permanent perm : game.getBattlefield().getAllPermanents()) {
if (hasObjectTargetNameOrAlias(perm, permanentName) && perm.getControllerId().equals(player.getId())) { if (hasObjectTargetNameOrAlias(perm, permanentName) && perm.getControllerId().equals(player.getId())) {
foundedCount++; foundCount++;
} }
} }
if (foundedCount != count) { if (foundCount != count) {
printStart("Permanents of " + player.getName()); printStart("Permanents of " + player.getName());
printPermanents(game, game.getBattlefield().getAllActivePermanents(player.getId())); printPermanents(game, game.getBattlefield().getAllActivePermanents(player.getId()));
printEnd(); printEnd();
Assert.fail(action.getActionName() + " - permanent " + permanentName + " must exists in " + count + " instances, but founded " + foundedCount); Assert.fail(action.getActionName() + " - permanent " + permanentName + " must exists in " + count + " instances, but found " + foundCount);
} }
} }
private void assertPermanentTapped(PlayerAction action, Game game, Player player, String permanentName, boolean tapped, int count) { private void assertPermanentTapped(PlayerAction action, Game game, Player player, String permanentName, boolean tapped, int count) {
int foundedCount = 0; int foundCount = 0;
for (Permanent perm : game.getBattlefield().getAllPermanents()) { for (Permanent perm : game.getBattlefield().getAllPermanents()) {
if (hasObjectTargetNameOrAlias(perm, permanentName) if (hasObjectTargetNameOrAlias(perm, permanentName)
&& perm.getControllerId().equals(player.getId()) && perm.getControllerId().equals(player.getId())
&& perm.isTapped() == tapped) { && perm.isTapped() == tapped) {
foundedCount++; foundCount++;
} }
} }
if (foundedCount != count) { if (foundCount != count) {
printStart("Permanents of " + player.getName()); printStart("Permanents of " + player.getName());
printPermanents(game, game.getBattlefield().getAllActivePermanents(player.getId())); printPermanents(game, game.getBattlefield().getAllActivePermanents(player.getId()));
printEnd(); printEnd();
Assert.fail(action.getActionName() + " - must have " + count + (tapped ? " tapped " : " untapped ") Assert.fail(action.getActionName() + " - must have " + count + (tapped ? " tapped " : " untapped ")
+ "permanents with name " + permanentName + ", but founded " + foundedCount); + "permanents with name " + permanentName + ", but found " + foundCount);
} }
} }
private void assertPermanentCounters(PlayerAction action, Game game, Player player, String permanentName, CounterType counterType, int count) { private void assertPermanentCounters(PlayerAction action, Game game, Player player, String permanentName, CounterType counterType, int count) {
int foundedCount = 0; int foundCount = 0;
for (Permanent perm : game.getBattlefield().getAllPermanents()) { for (Permanent perm : game.getBattlefield().getAllPermanents()) {
if (hasObjectTargetNameOrAlias(perm, permanentName) && perm.getControllerId().equals(player.getId())) { if (hasObjectTargetNameOrAlias(perm, permanentName) && perm.getControllerId().equals(player.getId())) {
foundedCount = perm.getCounters(game).getCount(counterType); foundCount = perm.getCounters(game).getCount(counterType);
} }
} }
Assert.assertEquals(action.getActionName() + " - permanent " + permanentName + " must have " + count + " " + counterType.toString(), count, foundedCount); Assert.assertEquals(action.getActionName() + " - permanent " + permanentName + " must have " + count + " " + counterType.toString(), count, foundCount);
} }
private void assertExileCount(PlayerAction action, Game game, Player player, String permanentName, int count) { private void assertExileCount(PlayerAction action, Game game, Player player, String permanentName, int count) {
int foundedCount = 0; int foundCount = 0;
for (Card card : game.getExile().getAllCards(game)) { for (Card card : game.getExile().getAllCards(game)) {
if (hasObjectTargetNameOrAlias(card, permanentName) && card.isOwnedBy(player.getId())) { if (hasObjectTargetNameOrAlias(card, permanentName) && card.isOwnedBy(player.getId())) {
foundedCount++; foundCount++;
} }
} }
Assert.assertEquals(action.getActionName() + " - card " + permanentName + " must exists in exile zone with " + count + " instances", count, foundedCount); Assert.assertEquals(action.getActionName() + " - card " + permanentName + " must exists in exile zone with " + count + " instances", count, foundCount);
} }
private void assertGraveyardCount(PlayerAction action, Game game, Player player, String permanentName, int count) { private void assertGraveyardCount(PlayerAction action, Game game, Player player, String permanentName, int count) {
int foundedCount = 0; int foundCount = 0;
for (Card card : player.getGraveyard().getCards(game)) { for (Card card : player.getGraveyard().getCards(game)) {
if (hasObjectTargetNameOrAlias(card, permanentName) && card.isOwnedBy(player.getId())) { if (hasObjectTargetNameOrAlias(card, permanentName) && card.isOwnedBy(player.getId())) {
foundedCount++; foundCount++;
} }
} }
Assert.assertEquals(action.getActionName() + " - card " + permanentName + " must exists in graveyard zone with " + count + " instances", count, foundedCount); Assert.assertEquals(action.getActionName() + " - card " + permanentName + " must exists in graveyard zone with " + count + " instances", count, foundCount);
} }
private void assertLibraryCount(PlayerAction action, Game game, Player player, String permanentName, int count) { private void assertLibraryCount(PlayerAction action, Game game, Player player, String permanentName, int count) {
int foundedCount = 0; int foundCount = 0;
for (Card card : player.getLibrary().getCards(game)) { for (Card card : player.getLibrary().getCards(game)) {
if (hasObjectTargetNameOrAlias(card, permanentName)) { if (hasObjectTargetNameOrAlias(card, permanentName)) {
foundedCount++; foundCount++;
} }
} }
Assert.assertEquals(action.getActionName() + " - card " + permanentName + " must exists in library with " + count + " instances", count, foundedCount); Assert.assertEquals(action.getActionName() + " - card " + permanentName + " must exists in library with " + count + " instances", count, foundCount);
} }
private void assertHandCount(PlayerAction action, Game game, Player player, int count) { private void assertHandCount(PlayerAction action, Game game, Player player, int count) {
@ -1436,18 +1436,18 @@ public class TestPlayer implements Player {
Permanent perm = findPermanentWithAssert(action, game, player, permanentName); Permanent perm = findPermanentWithAssert(action, game, player, permanentName);
boolean founded = false; boolean found = false;
for (CardType ct : perm.getCardType()) { for (CardType ct : perm.getCardType()) {
if (ct.equals(type)) { if (ct.equals(type)) {
founded = true; found = true;
break; break;
} }
} }
if (mustHave) { if (mustHave) {
Assert.assertEquals(action.getActionName() + " - permanent " + permanentName + " must have type " + type, true, founded); Assert.assertEquals(action.getActionName() + " - permanent " + permanentName + " must have type " + type, true, found);
} else { } else {
Assert.assertEquals(action.getActionName() + " - permanent " + permanentName + " must have not type " + type, false, founded); Assert.assertEquals(action.getActionName() + " - permanent " + permanentName + " must have not type " + type, false, found);
} }
} }
@ -1455,18 +1455,18 @@ public class TestPlayer implements Player {
Permanent perm = findPermanentWithAssert(action, game, player, permanentName); Permanent perm = findPermanentWithAssert(action, game, player, permanentName);
boolean founded = false; boolean found = false;
for (SubType st : perm.getSubtype(game)) { for (SubType st : perm.getSubtype(game)) {
if (st.equals(subType)) { if (st.equals(subType)) {
founded = true; found = true;
break; break;
} }
} }
if (mustHave) { if (mustHave) {
Assert.assertEquals(action.getActionName() + " - permanent " + permanentName + " must have subtype " + subType, true, founded); Assert.assertEquals(action.getActionName() + " - permanent " + permanentName + " must have subtype " + subType, true, found);
} else { } else {
Assert.assertEquals(action.getActionName() + " - permanent " + permanentName + " must have not subtype " + subType, false, founded); Assert.assertEquals(action.getActionName() + " - permanent " + permanentName + " must have not subtype " + subType, false, found);
} }
} }
@ -1505,13 +1505,13 @@ public class TestPlayer implements Player {
} }
private void assertStackObject(PlayerAction action, Game game, String stackAbilityName, int needAmount) { private void assertStackObject(PlayerAction action, Game game, String stackAbilityName, int needAmount) {
long foundedAmount = game.getStack() long foundAmount = game.getStack()
.stream() .stream()
.filter(stack -> stack.getStackAbility().toString().startsWith(stackAbilityName)) .filter(stack -> stack.getStackAbility().toString().startsWith(stackAbilityName))
.count(); .count();
if (needAmount != foundedAmount) { if (needAmount != foundAmount) {
printStack(game); printStack(game);
Assert.fail(action.getActionName() + " - stack must have " + needAmount + " objects with ability [" + stackAbilityName + "] but have " + foundedAmount); Assert.fail(action.getActionName() + " - stack must have " + needAmount + " objects with ability [" + stackAbilityName + "] but have " + foundAmount);
} }
} }

View file

@ -186,14 +186,14 @@ public class BoosterGenerationTest extends MageTestBase {
List<CardInfo> setOrzaList = MastersEditionIV.getInstance().getSpecialLand(); List<CardInfo> setOrzaList = MastersEditionIV.getInstance().getSpecialLand();
Assert.assertEquals("Urza special lands must have 4 variation for each of 3 card", 3 * 4, setOrzaList.size()); Assert.assertEquals("Urza special lands must have 4 variation for each of 3 card", 3 * 4, setOrzaList.size());
List<String> foundedUrzaList = new ArrayList<>(); List<String> foundUrzaList = new ArrayList<>();
for (CardInfo cardInfo : setOrzaList) { for (CardInfo cardInfo : setOrzaList) {
Assert.assertTrue("card " + cardInfo.getName() + " must be in urza's list", needUrzaList.contains(cardInfo.getName())); Assert.assertTrue("card " + cardInfo.getName() + " must be in urza's list", needUrzaList.contains(cardInfo.getName()));
foundedUrzaList.add(cardInfo.getName()); foundUrzaList.add(cardInfo.getName());
} }
for (String needName : needUrzaList) { for (String needName : needUrzaList) {
Assert.assertTrue("can't find need card " + needName + " in special land list", foundedUrzaList.contains(needName)); Assert.assertTrue("can't find need card " + needName + " in special land list", foundUrzaList.contains(needName));
} }
} }

View file

@ -99,7 +99,7 @@ public class ReturnFromExileForSourceEffect extends OneShotEffect {
ExileZone exile = game.getExile().getExileZone(exileId); ExileZone exile = game.getExile().getExileZone(exileId);
if (exile != null) { // null is valid if source left battlefield before enters the battlefield effect resolved if (exile != null) { // null is valid if source left battlefield before enters the battlefield effect resolved
if (returnToZone == Zone.BATTLEFIELD) { if (Zone.BATTLEFIELD.equals(returnToZone)) {
controller.moveCards(exile.getCards(game), returnToZone, source, game, false, false, true, null); controller.moveCards(exile.getCards(game), returnToZone, source, game, false, false, true, null);
} else { } else {
controller.moveCards(exile, returnToZone, source, game); controller.moveCards(exile, returnToZone, source, game);
@ -110,19 +110,19 @@ public class ReturnFromExileForSourceEffect extends OneShotEffect {
private void updateText() { private void updateText() {
StringBuilder sb = new StringBuilder(); StringBuilder sb = new StringBuilder();
sb.append("return the exiled " + this.returnName + " "); sb.append("return the exiled ").append(this.returnName).append(" ");
switch (returnToZone) { switch (returnToZone) {
case BATTLEFIELD: case BATTLEFIELD:
sb.append("to the battlefield under " + this.returnControlName + " control"); sb.append("to the battlefield under ").append(this.returnControlName).append(" control");
if (tapped) { if (tapped) {
sb.append(" tapped"); sb.append(" tapped");
} }
break; break;
case HAND: case HAND:
sb.append("to " + this.returnControlName + " hand"); sb.append("to ").append(this.returnControlName).append(" hand");
break; break;
case GRAVEYARD: case GRAVEYARD:
sb.append("to " + this.returnControlName + " graveyard"); sb.append("to ").append(this.returnControlName).append(" graveyard");
break; break;
} }
staticText = sb.toString(); staticText = sb.toString();

View file

@ -12,7 +12,7 @@ public abstract class DamagedBatchEvent extends GameEvent {
private final Set<DamagedEvent> events = new HashSet<>(); private final Set<DamagedEvent> events = new HashSet<>();
public DamagedBatchEvent(EventType type, Class<? extends DamagedEvent> damageClazz) { public DamagedBatchEvent(EventType type, Class<? extends DamagedEvent> damageClazz) {
super(GameEvent.EventType.DAMAGED_PLAYER_BATCH, null, null, null); super(type, null, null, null);
this.damageClazz = damageClazz; this.damageClazz = damageClazz;
} }