Search in sources :

Example 86 with ExileZone

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);
}
Also used : Player(mage.players.Player) ExileZone(mage.game.ExileZone)

Example 87 with ExileZone

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;
}
Also used : Player(mage.players.Player) FilterPermanent(mage.filter.FilterPermanent) Permanent(mage.game.permanent.Permanent) MageObject(mage.MageObject) ExileZone(mage.game.ExileZone) PermanentToken(mage.game.permanent.PermanentToken)

Example 88 with ExileZone

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;
}
Also used : Player(mage.players.Player) TargetCardInGraveyard(mage.target.common.TargetCardInGraveyard) Permanent(mage.game.permanent.Permanent) ExileZone(mage.game.ExileZone) UUID(java.util.UUID) Card(mage.cards.Card)

Example 89 with ExileZone

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;
}
Also used : Player(mage.players.Player) mage.cards(mage.cards) Objects(java.util.Objects) TargetCardInExile(mage.target.common.TargetCardInExile) ExileZone(mage.game.ExileZone) TargetCard(mage.target.TargetCard) UUID(java.util.UUID) TargetCard(mage.target.TargetCard)

Example 90 with ExileZone

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;
}
Also used : Player(mage.players.Player) ExileZone(mage.game.ExileZone) Cards(mage.cards.Cards) CardsImpl(mage.cards.CardsImpl)

Aggregations

ExileZone (mage.game.ExileZone)92 Player (mage.players.Player)61 UUID (java.util.UUID)44 Card (mage.cards.Card)44 MageObject (mage.MageObject)24 Permanent (mage.game.permanent.Permanent)23 FilterCard (mage.filter.FilterCard)15 HashSet (java.util.HashSet)11 ApprovingObject (mage.ApprovingObject)9 CardsImpl (mage.cards.CardsImpl)9 TargetCard (mage.target.TargetCard)9 Cards (mage.cards.Cards)7 MageObjectReference (mage.MageObjectReference)6 Ability (mage.abilities.Ability)5 Spell (mage.game.stack.Spell)5 SimpleStaticAbility (mage.abilities.common.SimpleStaticAbility)3 TransformSourceEffect (mage.abilities.effects.common.TransformSourceEffect)3 TargetPlayer (mage.target.TargetPlayer)3 Objects (java.util.Objects)2 Set (java.util.Set)2