Skip to content

Commit

Permalink
test framework: allow direct addEmblem (#11164)
Browse files Browse the repository at this point in the history
  • Loading branch information
Susucre committed Sep 18, 2023
1 parent 877651d commit a3f787b
Show file tree
Hide file tree
Showing 2 changed files with 77 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
package org.mage.test.cards.emblems;

import mage.abilities.keyword.FlyingAbility;
import mage.constants.PhaseStep;
import mage.constants.Zone;
import mage.game.command.Emblem;
import mage.game.command.emblems.ChandraTorchOfDefianceEmblem;
import mage.game.command.emblems.ElspethSunsChampionEmblem;
import org.junit.Test;
import org.mage.test.serverside.base.CardTestPlayerBase;

/**
* @author Susucr
*/
public class AddEmblemTest extends CardTestPlayerBase {

/**
* Emblem
* Creatures you control get +2/+2 and have flying.
*/
private static final Emblem elspethSunChampionEmblem = new ElspethSunsChampionEmblem();

/**
* Emblem
* Whenever you cast a spell, this emblem deals 5 damage to any target.
*/
private static final Emblem chandraTorchOfDefianceEmblem = new ChandraTorchOfDefianceEmblem();

@Test
public void test_ElpethSunChampionEmblem() {
setStrictChooseMode(true);

addEmblem(playerA, elspethSunChampionEmblem);
addCard(Zone.BATTLEFIELD, playerA, "Grizzly Bears"); // 2/2 vanilla

setStopAt(1, PhaseStep.UPKEEP);
execute();

assertPowerToughness(playerA, "Grizzly Bears", 2 + 2, 2 + 2);
assertAbility(playerA, "Grizzly Bears", FlyingAbility.getInstance(), true);
assertCommandZoneCount(playerA, elspethSunChampionEmblem.getName(), 1);
}

@Test
public void test_ChandraTorchOfDefianceEmblem() {
setStrictChooseMode(true);

addEmblem(playerA, chandraTorchOfDefianceEmblem);
addCard(Zone.HAND, playerA, "Memnite", 2); // 1/1 for {0} vanilla

castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerA, "Memnite");
addTarget(playerA, playerB); // emblem trigger
waitStackResolved(1, PhaseStep.PRECOMBAT_MAIN, playerA);
castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerA, "Memnite");
addTarget(playerA, playerB); // emblem trigger

setStopAt(1, PhaseStep.BEGIN_COMBAT);
execute();

assertPermanentCount(playerA, "Memnite", 2);
assertLife(playerB, 20 - 5 - 5);
assertCommandZoneCount(playerA, chandraTorchOfDefianceEmblem.getName(), 1);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
import mage.filter.predicate.mageobject.NamePredicate;
import mage.game.*;
import mage.game.command.CommandObject;
import mage.game.command.Emblem;
import mage.game.match.MatchOptions;
import mage.game.permanent.Permanent;
import mage.game.permanent.PermanentCard;
Expand Down Expand Up @@ -703,6 +704,18 @@ public void addPlane(Player player, Planes plane) {
assertTrue("Can't put plane to game: " + plane.getClassName(), SystemUtil.putPlaneToGame(currentGame, player, plane.getClassName()));
}

public void addEmblem(Player player, Emblem emblem) {
Emblem newEmblem = emblem.copy();
newEmblem.setControllerId(player.getId());
newEmblem.assignNewId();
newEmblem.getAbilities().newId();
for (Ability ability : newEmblem.getAbilities()) {
ability.setSourceId(newEmblem.getId());
}

currentGame.getState().addCommandObject(newEmblem);
}

/**
* Returns card list container for specified game zone and player.
*
Expand Down

0 comments on commit a3f787b

Please sign in to comment.