Search in sources :

Example 46 with ExileZone

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

the class TroveWardenEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Player controller = game.getPlayer(source.getControllerId());
    Permanent permanent = (Permanent) getValue("permanentLeftBattlefield");
    if (controller == null || permanent == null) {
        return false;
    }
    ExileZone exileZone = game.getExile().getExileZone(CardUtil.getExileZoneId(game, permanent.getId(), permanent.getZoneChangeCounter(game)));
    if (exileZone == null) {
        return true;
    }
    return controller.moveCards(exileZone.getCards(game), Zone.BATTLEFIELD, source, game, false, false, true, null);
}
Also used : Player(mage.players.Player) Permanent(mage.game.permanent.Permanent) ExileZone(mage.game.ExileZone)

Example 47 with ExileZone

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

the class AdventureCardSpellAbility method canActivate.

@Override
public ActivationStatus canActivate(UUID playerId, Game game) {
    ExileZone adventureExileZone = game.getExile().getExileZone(ExileAdventureSpellEffect.adventureExileId(playerId, game));
    Card spellCard = game.getCard(this.getSourceId());
    if (spellCard instanceof AdventureCardSpell) {
        Card card = ((AdventureCardSpell) spellCard).getParentCard();
        if (adventureExileZone != null && adventureExileZone.contains(card.getId())) {
            return ActivationStatus.getFalse();
        }
    }
    return super.canActivate(playerId, game);
}
Also used : ExileZone(mage.game.ExileZone)

Example 48 with ExileZone

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

the class TibaltCosmicImpostorPlayFromExileEffect method applies.

@Override
public boolean applies(UUID objectId, Ability source, UUID affectedControllerId, Game game) {
    Emblem tibaltEmblem = (Emblem) game.getEmblem(source.getSourceId());
    if (tibaltEmblem == null) {
        return false;
    }
    // the exile zone of the Tibalt, Cosmic Impostor that spawned the emblem only
    UUID exileId = CardUtil.getExileZoneId(tibaltEmblem.getSourceObject().getId().toString(), game);
    if (exileId == null) {
        return false;
    }
    ExileZone exile = game.getState().getExile().getExileZone(exileId);
    if (exile == null) {
        return false;
    }
    if (exile.isEmpty()) {
        return false;
    }
    Card cardInExile = game.getCard(objectId);
    if (cardInExile == null) {
        return false;
    }
    UUID mainCardId = cardInExile.getMainCard().getId();
    if (exile.contains(mainCardId) && affectedControllerId.equals(source.getControllerId()) && game.getState().getZone(mainCardId).equals(Zone.EXILED)) {
        CardUtil.makeCardPlayable(game, source, cardInExile, Duration.Custom, true);
        return true;
    }
    return false;
}
Also used : Emblem(mage.game.command.Emblem) ExileZone(mage.game.ExileZone) UUID(java.util.UUID) Card(mage.cards.Card)

Example 49 with ExileZone

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

the class EndlessSandsEffect 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));
    return player != null && exileZone != null && player.moveCards(exileZone.getCards(game), Zone.BATTLEFIELD, source, game, false, false, true, null);
}
Also used : Player(mage.players.Player) ExileZone(mage.game.ExileZone)

Example 50 with ExileZone

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

the class TargetCardInMuseVesselExile method canTarget.

@Override
public boolean canTarget(UUID id, Ability source, Game game) {
    Card card = game.getCard(id);
    if (card != null && game.getState().getZone(card.getId()) == Zone.EXILED) {
        ExileZone exile = null;
        Card sourceCard = game.getCard(source.getSourceId());
        if (sourceCard != null) {
            UUID exileId = CardUtil.getCardExileZoneId(game, source);
            exile = game.getExile().getExileZone(exileId);
        }
        if (exile != null && exile.contains(id)) {
            return filter.match(card, source.getControllerId(), game);
        }
    }
    return false;
}
Also used : ExileZone(mage.game.ExileZone) UUID(java.util.UUID) FilterCard(mage.filter.FilterCard) 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