Search in sources :

Example 16 with ExileZone

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

the class JestersScepterCounterEffect 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) FilterCard(mage.filter.FilterCard)

Example 17 with ExileZone

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

the class JelevaNephaliasWatcher method apply.

@Override
public boolean apply(Game game, Ability source) {
    Player controller = game.getPlayer(source.getControllerId());
    if (controller != null) {
        ExileZone exileZone = game.getExile().getExileZone(CardUtil.getCardExileZoneId(game, source));
        if (exileZone != null && exileZone.count(new FilterInstantOrSorceryCard(), game) > 0) {
            if (controller.chooseUse(outcome, "Cast an instant or sorcery card from " + "exile without paying its mana cost?", source, game)) {
                TargetCardInExile target = new TargetCardInExile(new FilterInstantOrSorceryCard(), CardUtil.getCardExileZoneId(game, source));
                if (controller.choose(Outcome.PlayForFree, exileZone, target, game)) {
                    Card card = game.getCard(target.getFirstTarget());
                    if (card != null) {
                        game.getState().setValue("PlayFromNotOwnHandZone" + card.getId(), Boolean.TRUE);
                        Boolean cardWasCast = controller.cast(controller.chooseAbilityForCast(card, game, true), game, true, new ApprovingObject(source, game));
                        game.getState().setValue("PlayFromNotOwnHandZone" + card.getId(), null);
                        return cardWasCast;
                    }
                }
            }
        }
        return true;
    }
    return false;
}
Also used : Player(mage.players.Player) ApprovingObject(mage.ApprovingObject) FilterInstantOrSorceryCard(mage.filter.common.FilterInstantOrSorceryCard) TargetCardInExile(mage.target.common.TargetCardInExile) ExileZone(mage.game.ExileZone) FilterInstantOrSorceryCard(mage.filter.common.FilterInstantOrSorceryCard) Card(mage.cards.Card)

Example 18 with ExileZone

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

the class PatchworkCrawlerEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Permanent permanent = source.getSourcePermanentIfItStillExists(game);
    ExileZone exileZone = game.getExile().getExileZone(CardUtil.getExileZoneId(game, source));
    if (permanent == null || exileZone == null || exileZone.isEmpty()) {
        return false;
    }
    for (Card card : exileZone.getCards(StaticFilters.FILTER_CARD_CREATURE, game)) {
        for (Ability ability : card.getAbilities(game)) {
            if (ability instanceof ActivatedAbility) {
                permanent.addAbility(ability, source.getSourceId(), game);
            }
        }
    }
    return true;
}
Also used : SimpleActivatedAbility(mage.abilities.common.SimpleActivatedAbility) SimpleStaticAbility(mage.abilities.common.SimpleStaticAbility) ActivatedAbility(mage.abilities.ActivatedAbility) Ability(mage.abilities.Ability) Permanent(mage.game.permanent.Permanent) SimpleActivatedAbility(mage.abilities.common.SimpleActivatedAbility) ActivatedAbility(mage.abilities.ActivatedAbility) ExileZone(mage.game.ExileZone) Card(mage.cards.Card)

Example 19 with ExileZone

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

the class ParallaxWaveEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    MageObject sourceObject = source.getSourceObject(game);
    Player controller = game.getPlayer(source.getControllerId());
    if (sourceObject != null && controller != null) {
        int zoneChangeCounter = (sourceObject instanceof PermanentToken) ? source.getSourceObjectZoneChangeCounter() : source.getSourceObjectZoneChangeCounter() - 1;
        UUID exileZoneId = CardUtil.getExileZoneId(game, source.getSourceId(), zoneChangeCounter);
        if (exileZoneId != null) {
            ExileZone exileZone = game.getExile().getExileZone(exileZoneId);
            if (exileZone != null) {
                return controller.moveCards(exileZone.getCards(game), Zone.BATTLEFIELD, source, game, false, false, true, null);
            }
            return true;
        }
    }
    return false;
}
Also used : Player(mage.players.Player) MageObject(mage.MageObject) ExileZone(mage.game.ExileZone) PermanentToken(mage.game.permanent.PermanentToken) UUID(java.util.UUID)

Example 20 with ExileZone

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

the class GusthasScepterPutExiledCardsInOwnersGraveyard method apply.

@Override
public boolean apply(Game game, Ability source) {
    Player controller = game.getPlayer(source.getControllerId());
    if (controller == null) {
        return false;
    }
    ExileZone exileZone = game.getExile().getExileZone(CardUtil.getExileZoneId(game, source));
    return exileZone != null && controller.moveCards(exileZone.getCards(game), Zone.GRAVEYARD, source, game);
}
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