use of mage.game.permanent.PermanentToken in project mage by magefree.
the class OneOrMoreTest method test_ChooseModes_AsCardOrder.
/**
* Sublime Epiphany can bounce and
* copy the same creature. This is because legality of targets is checked
* only as the spell begins to resolve, not in between modes, and because
* the games can use last known info of the legal target.
*/
@Test
public void test_ChooseModes_AsCardOrder() {
addCard(Zone.BATTLEFIELD, playerA, "Island", 6);
// Choose one or more —
// 1 • Counter target spell
// 2 • Counter target activated or triggered ability.
// 3 • Return target nonland permanent to its owner's hand.
// 4 • Create a token that's a copy of target creature you control.
// 5 • Target player draws a card.
// Instant {4}{U}{U}
addCard(Zone.HAND, playerA, "Sublime Epiphany");
addCard(Zone.BATTLEFIELD, playerA, "Silvercoat Lion");
castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerA, "Sublime Epiphany");
setModeChoice(playerA, "3");
setModeChoice(playerA, "4");
setModeChoice(playerA, "5");
// for 3
addTarget(playerA, "Silvercoat Lion");
// for 4
addTarget(playerA, "Silvercoat Lion");
// for 5
addTarget(playerA, playerB);
setModeChoice(playerA, null);
setStrictChooseMode(true);
setStopAt(1, PhaseStep.BEGIN_COMBAT);
execute();
assertAllCommandsUsed();
assertHandCount(playerB, 1);
assertHandCount(playerA, "Silvercoat Lion", 1);
assertPowerToughness(playerA, "Silvercoat Lion", 2, 2);
Permanent perm = getPermanent("Silvercoat Lion");
Assert.assertTrue("Silvercoat Lion has to be a Token", perm instanceof PermanentToken);
}
use of mage.game.permanent.PermanentToken in project mage by magefree.
the class CardView method fillEmpty.
private void fillEmpty(Card card, boolean controlled) {
this.name = "Face Down";
this.displayName = name;
this.displayFullName = name;
this.rules = new ArrayList<>();
this.power = "";
this.toughness = "";
this.loyalty = "";
this.startingLoyalty = "";
this.cardTypes = new ArrayList<>();
this.subTypes = new SubTypes();
this.superTypes = EnumSet.noneOf(SuperType.class);
this.color = new ObjectColor();
this.frameColor = new ObjectColor();
this.frameStyle = FrameStyle.M15_NORMAL;
this.manaCostLeftStr = "";
this.manaCostRightStr = "";
this.manaValue = 0;
// the controller can see more information (e.g. enlarged image) than other players for face down cards (e.g. Morph played face down)
if (!controlled) {
this.rarity = Rarity.COMMON;
this.expansionSetCode = "";
this.cardNumber = "0";
} else {
this.rarity = card.getRarity();
}
if (card != null) {
if (card instanceof Permanent) {
this.mageObjectType = MageObjectType.PERMANENT;
} else if (card.isCopy()) {
this.mageObjectType = MageObjectType.COPY_CARD;
} else {
this.mageObjectType = MageObjectType.CARD;
}
if (card instanceof PermanentToken) {
this.mageObjectType = MageObjectType.TOKEN;
}
if (card instanceof Spell) {
this.mageObjectType = MageObjectType.SPELL;
}
}
}
use of mage.game.permanent.PermanentToken in project mage by magefree.
the class CollisionOfRealmsEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
List<Player> players = new ArrayList<>();
for (UUID playerId : game.getState().getPlayersInRange(source.getControllerId(), game)) {
Player player = game.getPlayer(playerId);
if (player == null) {
continue;
}
List<Permanent> permanents = game.getBattlefield().getActivePermanents(StaticFilters.FILTER_CONTROLLED_CREATURE, playerId, game);
boolean hasNonToken = permanents.stream().filter(permanent -> !(permanent instanceof PermanentToken)).anyMatch(permanent -> permanent.isCreature(game));
player.putCardsOnBottomOfLibrary(new CardsImpl(permanents), game, source, false);
player.shuffleLibrary(source, game);
if (hasNonToken) {
players.add(player);
}
}
for (Player player : players) {
Cards cards = new CardsImpl();
Card creature = revealUntilCreature(cards, player, game);
player.revealCards(source, cards, game);
if (creature != null) {
player.moveCards(creature, Zone.BATTLEFIELD, source, game);
}
cards.retainZone(Zone.LIBRARY, game);
player.putCardsOnBottomOfLibrary(cards, game, source, false);
}
return true;
}
use of mage.game.permanent.PermanentToken in project mage by magefree.
the class DayOfTheDragonsLeavesEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Player controller = game.getPlayer(source.getControllerId());
MageObject sourceObject = source.getSourceObject(game);
if (controller != null) {
for (Permanent dragon : game.getBattlefield().getActivePermanents(filter, source.getControllerId(), game)) {
if (dragon != null) {
dragon.sacrifice(source, game);
}
}
int zoneChangeCounter = source.getSourceObjectZoneChangeCounter();
if (zoneChangeCounter > 0 && !(sourceObject instanceof PermanentToken)) {
zoneChangeCounter--;
}
ExileZone exile = game.getExile().getExileZone(CardUtil.getExileZoneId(game, source.getSourceId(), zoneChangeCounter));
if (exile != null) {
controller.moveCards(exile, Zone.BATTLEFIELD, source, game);
}
return true;
}
return false;
}
use of mage.game.permanent.PermanentToken in project mage by magefree.
the class AetherspoutsEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
game.getPlayerList();
Player controller = game.getPlayer(source.getControllerId());
if (controller != null) {
PlayerList playerList = game.getPlayerList().copy();
playerList.setCurrent(game.getActivePlayerId());
Player player = game.getPlayer(game.getActivePlayerId());
Player activePlayer = player;
do {
List<Permanent> permanentsToTop = new ArrayList<>();
List<Permanent> permanentsToBottom = new ArrayList<>();
for (Permanent permanent : game.getState().getBattlefield().getActivePermanents(new FilterAttackingCreature(), player.getId(), source.getSourceId(), game)) {
if (permanent.isOwnedBy(player.getId())) {
if (player.chooseUse(outcome, "Put " + permanent.getLogName() + " to the top? (else it goes to bottom)", source, game)) {
permanentsToTop.add(permanent);
game.informPlayers(permanent.getLogName() + " goes to the top of " + player.getLogName() + "'s library");
} else {
permanentsToBottom.add(permanent);
game.informPlayers(permanent.getLogName() + " goes to the bottom of " + player.getLogName() + "'s library");
}
}
}
// cards to top
Cards cards = new CardsImpl();
List<Permanent> toLibrary = new ArrayList<>();
for (Permanent permanent : permanentsToTop) {
if (permanent instanceof PermanentToken) {
toLibrary.add(permanent);
} else {
Card card = game.getCard(permanent.getId());
if (card != null) {
cards.add(card);
}
}
}
TargetCard target = new TargetCard(Zone.BATTLEFIELD, new FilterCard("order to put on the top of library (last choosen will be the top most)"));
while (cards.size() > 1) {
if (!player.canRespond()) {
return false;
}
player.choose(Outcome.Neutral, cards, target, game);
Card card = cards.get(target.getFirstTarget(), game);
if (card != null) {
cards.remove(card);
Permanent permanent = game.getPermanent(card.getId());
if (permanent != null) {
toLibrary.add(permanent);
}
}
target.clearChosen();
}
if (cards.size() == 1) {
Card card = cards.get(cards.iterator().next(), game);
Permanent permanent = game.getPermanent(card.getId());
if (permanent != null) {
toLibrary.add(permanent);
}
}
// move all permanents to lib at the same time
for (Permanent permanent : toLibrary) {
player.moveCardToLibraryWithInfo(permanent, source, game, Zone.BATTLEFIELD, true, false);
}
// cards to bottom
cards.clear();
toLibrary.clear();
for (Permanent permanent : permanentsToBottom) {
if (permanent instanceof PermanentToken) {
toLibrary.add(permanent);
} else {
Card card = game.getCard(permanent.getId());
if (card != null) {
cards.add(card);
}
}
}
target = new TargetCard(Zone.BATTLEFIELD, new FilterCard("order to put on bottom of library (last choosen will be bottommost card)"));
while (player.canRespond() && cards.size() > 1) {
player.choose(Outcome.Neutral, cards, target, game);
Card card = cards.get(target.getFirstTarget(), game);
if (card != null) {
cards.remove(card);
Permanent permanent = game.getPermanent(card.getId());
if (permanent != null) {
toLibrary.add(permanent);
}
}
target.clearChosen();
}
if (cards.size() == 1) {
Card card = cards.get(cards.iterator().next(), game);
Permanent permanent = game.getPermanent(card.getId());
if (permanent != null) {
toLibrary.add(permanent);
}
}
// move all permanents to lib at the same time
for (Permanent permanent : toLibrary) {
player.moveCardToLibraryWithInfo(permanent, source, game, Zone.BATTLEFIELD, false, false);
}
player = playerList.getNext(game, false);
} while (player != null && !player.getId().equals(game.getActivePlayerId()) && activePlayer.canRespond());
return true;
}
return false;
}
Aggregations