Search in sources :

Example 81 with ExileZone

use of mage.game.ExileZone in project mage by magefree.

the class ParallelThoughtsReplacementEffect method replaceEvent.

@Override
public boolean replaceEvent(GameEvent event, Ability source, Game game) {
    Player controller = game.getPlayer(source.getControllerId());
    ExileZone exileZone = game.getExile().getExileZone(CardUtil.getCardExileZoneId(game, source));
    Set<Card> cards = exileZone != null ? exileZone.getCards(game) : null;
    if (controller != null && cards != null && !cards.isEmpty()) {
        if (controller.chooseUse(outcome, "Draw a card from the pile you exiled instead drawing from your library?", source, game)) {
            Card card = cards.iterator().next();
            if (card != null) {
                controller.moveCards(card, Zone.HAND, source, game);
            }
            return true;
        }
    }
    return false;
}
Also used : Player(mage.players.Player) ExileZone(mage.game.ExileZone) FilterCard(mage.filter.FilterCard)

Example 82 with ExileZone

use of mage.game.ExileZone in project mage by magefree.

the class PhantomSteedEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    ExileZone exileZone = game.getState().getExile().getExileZone(CardUtil.getExileZoneId(game, source));
    if (exileZone == null || exileZone.isEmpty()) {
        return false;
    }
    for (Card card : exileZone.getCards(game)) {
        EmptyToken token = new EmptyToken();
        CardUtil.copyTo(token).from(card, game);
        token.addSubType(SubType.ILLUSION);
        token.putOntoBattlefield(1, game, source, source.getControllerId(), true, true);
        List<Permanent> permanents = token.getLastAddedTokenIds().stream().map(game::getPermanent).filter(Objects::nonNull).collect(Collectors.toList());
        game.addDelayedTriggeredAbility(new AtTheEndOfCombatDelayedTriggeredAbility(new ExileTargetEffect("Sacrifice that token at end of combat").setTargetPointer(new FixedTargets(permanents, game))), source);
    }
    return true;
}
Also used : Permanent(mage.game.permanent.Permanent) TargetPermanent(mage.target.TargetPermanent) FixedTargets(mage.target.targetpointer.FixedTargets) ExileZone(mage.game.ExileZone) AtTheEndOfCombatDelayedTriggeredAbility(mage.abilities.common.delayed.AtTheEndOfCombatDelayedTriggeredAbility) Card(mage.cards.Card) EmptyToken(mage.game.permanent.token.EmptyToken) ExileTargetEffect(mage.abilities.effects.common.ExileTargetEffect)

Example 83 with ExileZone

use of mage.game.ExileZone in project mage by magefree.

the class TheaterOfHorrorsCastEffect method applies.

@Override
public boolean applies(UUID objectId, Ability source, UUID affectedControllerId, Game game) {
    Card theCard = game.getCard(objectId);
    if (theCard == null) {
        return false;
    }
    // for split cards and mdfc
    objectId = theCard.getMainCard().getId();
    PlayerLostLifeWatcher watcher = game.getState().getWatcher(PlayerLostLifeWatcher.class);
    if (watcher != null && game.isActivePlayer(source.getControllerId()) && watcher.getAllOppLifeLost(source.getControllerId(), game) > 0 && affectedControllerId.equals(source.getControllerId()) && game.getState().getZone(objectId) == Zone.EXILED) {
        ExileZone zone = game.getExile().getExileZone(CardUtil.getCardExileZoneId(game, source));
        return zone != null && zone.contains(objectId);
    }
    return false;
}
Also used : PlayerLostLifeWatcher(mage.watchers.common.PlayerLostLifeWatcher) ExileZone(mage.game.ExileZone) Card(mage.cards.Card)

Example 84 with ExileZone

use of mage.game.ExileZone in project mage by magefree.

the class WallOfMourningReturnEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Player player = game.getPlayer(source.getControllerId());
    if (player == null) {
        return false;
    }
    ExileZone exileZone = game.getExile().getExileZone(CardUtil.getExileZoneId(game, source));
    if (exileZone == null || exileZone.isEmpty()) {
        return false;
    }
    return player.moveCards(exileZone.getRandom(game), Zone.HAND, source, game);
}
Also used : Player(mage.players.Player) ExileZone(mage.game.ExileZone)

Example 85 with ExileZone

use of mage.game.ExileZone in project mage by magefree.

the class BaneAlleyBrokerLookAtCardEffect method applies.

@Override
public boolean applies(UUID objectId, Ability source, UUID affectedControllerId, Game game) {
    if (!source.isControlledBy(affectedControllerId)) {
        return false;
    }
    Card card = game.getCard(objectId);
    ExileZone exile = game.getExile().getExileZone(CardUtil.getExileZoneId(game, source));
    return card != null && exile != null && exile.getCards(game).contains(card);
}
Also used : ExileZone(mage.game.ExileZone) TargetCard(mage.target.TargetCard) Card(mage.cards.Card)

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