use of mage.game.ExileZone in project mage by magefree.
the class ColdStorageEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Player player = game.getPlayer(source.getControllerId());
ExileZone exileZone = game.getExile().getExileZone(CardUtil.getExileZoneId(game, source));
return player != null && exileZone != null && !exileZone.isEmpty() && player.moveCards(exileZone, Zone.BATTLEFIELD, source, game);
}
use of mage.game.ExileZone 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.ExileZone in project mage by magefree.
the class CreepingInnEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Player player = game.getPlayer(source.getControllerId());
Permanent permanent = source.getSourcePermanentOrLKI(game);
if (player != null && permanent != null) {
UUID exileId = CardUtil.getExileZoneId(game, source);
TargetCardInGraveyard target = new TargetCardInGraveyard(0, 1, StaticFilters.FILTER_CARD_CREATURE_YOUR_GRAVEYARD);
target.setNotTarget(true);
if (target.canChoose(source.getSourceId(), player.getId(), game)) {
if (player.choose(Outcome.Exile, target, source.getId(), game)) {
Card cardChosen = game.getCard(target.getFirstTarget());
if (cardChosen != null) {
int lifeAmount = 0;
player.moveCardsToExile(cardChosen, source, game, true, exileId, permanent.getName());
ExileZone exile = game.getExile().getExileZone(exileId);
if (exile != null) {
for (UUID cardId : exile) {
lifeAmount++;
}
}
for (UUID playerId : game.getOpponents(source.getControllerId())) {
game.getPlayer(playerId).loseLife(lifeAmount, game, source, false);
}
player.gainLife(lifeAmount, game, source);
}
}
}
return true;
}
return false;
}
use of mage.game.ExileZone in project mage by magefree.
the class AuthorOfShadowsEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Player controller = game.getPlayer(source.getControllerId());
if (controller == null) {
return false;
}
Cards cards = new CardsImpl();
game.getOpponents(source.getControllerId()).stream().map(game::getPlayer).filter(Objects::nonNull).map(Player::getGraveyard).forEach(cards::addAll);
cards.removeIf(Objects::isNull);
if (cards.isEmpty()) {
return false;
}
controller.moveCards(cards, Zone.EXILED, source, game);
cards.retainZone(Zone.EXILED, game);
if (cards.isEmpty()) {
return false;
}
TargetCard target = new TargetCardInExile(StaticFilters.FILTER_CARD_A_NON_LAND);
target.setNotTarget(true);
controller.choose(outcome, cards, target, game);
Card card = game.getCard(target.getFirstTarget());
if (card == null) {
return true;
}
// use same player's zone for all Author of Shadows instances
String exileZoneName = controller.getName() + " - Author of Shadows - cast with any color";
UUID exileZoneId = CardUtil.getExileZoneId(exileZoneName, game);
ExileZone exileZone = game.getExile().createZone(exileZoneId, exileZoneName);
game.getExile().moveToAnotherZone(card, game, exileZone);
CardUtil.makeCardPlayable(game, source, card, Duration.Custom, true);
return true;
}
use of mage.game.ExileZone in project mage by magefree.
the class BottledCloisterReturnEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Player player = game.getPlayer(source.getControllerId());
ExileZone exileZone = game.getExile().getExileZone(CardUtil.getExileZoneId(game, source));
if (player == null || exileZone == null || exileZone.isEmpty()) {
return false;
}
Cards cards = new CardsImpl(exileZone.getCards(game));
cards.removeIf(uuid -> !player.getId().equals(game.getOwnerId(uuid)));
player.moveCards(cards, Zone.HAND, source, game);
player.drawCards(1, source, game);
return true;
}
Aggregations