Search in sources :

Example 11 with ExileZone

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

the class ColfenorsUrnCondition method apply.

@Override
public boolean apply(Game game, Ability source) {
    Player controller = game.getPlayer(source.getControllerId());
    Permanent permanent = (Permanent) source.getSourceObjectIfItStillExists(game);
    if (controller != null && permanent != null) {
        UUID exileId = CardUtil.getCardExileZoneId(game, source);
        ExileZone exile = game.getExile().getExileZone(exileId);
        if (permanent.sacrifice(source, game)) {
            controller.moveCards(exile.getCards(game), Zone.BATTLEFIELD, source, game);
        }
        return true;
    }
    return false;
}
Also used : Player(mage.players.Player) Permanent(mage.game.permanent.Permanent) FilterCreaturePermanent(mage.filter.common.FilterCreaturePermanent) ExileZone(mage.game.ExileZone) UUID(java.util.UUID)

Example 12 with ExileZone

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

the class ColfenorsPlansLookAtCardEffect method applies.

@Override
public boolean applies(UUID objectId, Ability source, UUID affectedControllerId, Game game) {
    if (affectedControllerId.equals(source.getControllerId())) {
        Card card = game.getCard(objectId);
        if (card != null) {
            MageObject sourceObject = game.getObject(source.getSourceId());
            if (sourceObject == null) {
                return false;
            }
            UUID exileId = CardUtil.getCardExileZoneId(game, source);
            ExileZone exile = game.getExile().getExileZone(exileId);
            return exile != null && exile.contains(objectId);
        }
    }
    return false;
}
Also used : MageObject(mage.MageObject) ExileZone(mage.game.ExileZone) UUID(java.util.UUID) Card(mage.cards.Card)

Example 13 with ExileZone

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

the class ColfenorsPlansLookAtCardEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Player controller = game.getPlayer(source.getControllerId());
    if (controller != null) {
        Cards toExile = new CardsImpl(controller.getLibrary().getTopCards(game, 7));
        UUID exileId = CardUtil.getCardExileZoneId(game, source);
        controller.moveCardsToExile(toExile.getCards(game), source, game, false, exileId, CardUtil.createObjectRealtedWindowTitle(source, game, null));
        ExileZone exileZone = game.getExile().getExileZone(exileId);
        if (exileZone != null) {
            for (Card card : exileZone.getCards(game)) {
                if (card != null) {
                    card.setFaceDown(true, game);
                }
            }
        }
        return true;
    }
    return false;
}
Also used : Player(mage.players.Player) ExileZone(mage.game.ExileZone) UUID(java.util.UUID) Cards(mage.cards.Cards) CardsImpl(mage.cards.CardsImpl) Card(mage.cards.Card)

Example 14 with ExileZone

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

the class GisaGloriousResurrectorReturnEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Player player = game.getPlayer(source.getControllerId());
    Ability exiledWithSource = (Ability) game.getState().getValue("GisaGloriousResurrectorExile" + source.getSourceId().toString() + game.getState().getZoneChangeCounter(source.getSourceId()));
    if (exiledWithSource == null) {
        return false;
    }
    ExileZone exileZone = game.getExile().getExileZone(CardUtil.getExileZoneId(game, exiledWithSource));
    if (player == null || exileZone == null || exileZone.isEmpty()) {
        return false;
    }
    Cards cards = new CardsImpl(exileZone.getCards(StaticFilters.FILTER_CARD_CREATURE, game));
    if (cards.isEmpty()) {
        return false;
    }
    player.moveCards(cards, Zone.BATTLEFIELD, source, game);
    cards.retainZone(Zone.BATTLEFIELD, game);
    if (cards.isEmpty()) {
        return false;
    }
    game.addEffect(new GainAbilityTargetEffect(new DecayedAbility(), Duration.Custom).setTargetPointer(new FixedTargets(cards, game)), source);
    return true;
}
Also used : SimpleStaticAbility(mage.abilities.common.SimpleStaticAbility) BeginningOfUpkeepTriggeredAbility(mage.abilities.common.BeginningOfUpkeepTriggeredAbility) DecayedAbility(mage.abilities.keyword.DecayedAbility) Ability(mage.abilities.Ability) Player(mage.players.Player) FixedTargets(mage.target.targetpointer.FixedTargets) GainAbilityTargetEffect(mage.abilities.effects.common.continuous.GainAbilityTargetEffect) ExileZone(mage.game.ExileZone) DecayedAbility(mage.abilities.keyword.DecayedAbility) Cards(mage.cards.Cards) CardsImpl(mage.cards.CardsImpl)

Example 15 with ExileZone

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

the class GrinningTotemPutIntoGraveyardEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Player controller = game.getPlayer(source.getControllerId());
    ExileZone zone = game.getExile().getExileZone(exileZoneId);
    if (controller != null && zone != null) {
        return controller.moveCards(zone, Zone.GRAVEYARD, source, game);
    }
    return false;
}
Also used : Player(mage.players.Player) ExileZone(mage.game.ExileZone)

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