Search in sources :

Example 41 with ExileZone

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

the class UnderworldSentinelEffect 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.getSourceId(), source.getSourceObjectZoneChangeCounter()));
    return exileZone != null && controller.moveCards(exileZone, Zone.BATTLEFIELD, source, game);
}
Also used : Player(mage.players.Player) ExileZone(mage.game.ExileZone)

Example 42 with ExileZone

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

the class InducedAmnesiaReturnEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Player controller = game.getPlayer(source.getControllerId());
    ExileZone exileZone = game.getExile().getExileZone(CardUtil.getExileZoneId(game, source));
    return controller != null && exileZone != null && !exileZone.isEmpty() && controller.moveCards(exileZone, Zone.HAND, source, game);
}
Also used : TargetPlayer(mage.target.TargetPlayer) Player(mage.players.Player) ExileZone(mage.game.ExileZone)

Example 43 with ExileZone

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

the class MirrorGolemEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Permanent sourceObject = game.getPermanent(source.getSourceId());
    ExileZone exileZone = game.getExile().getExileZone(CardUtil.getCardExileZoneId(game, source.getSourceId()));
    if (sourceObject == null || sourceObject.getImprinted() == null) {
        return false;
    }
    for (UUID imprinted : sourceObject.getImprinted()) {
        if (imprinted != null && exileZone.contains(imprinted)) {
            Card card = game.getCard(imprinted);
            if (card != null) {
                for (CardType cardType : card.getCardType(game)) {
                    FilterCard filterCard;
                    if (cardType.equals(CardType.SORCERY)) {
                        filterCard = new FilterCard("sorceries");
                    } else if (cardType.equals(CardType.TRIBAL)) {
                        filterCard = new FilterCard("tribal");
                    } else {
                        filterCard = new FilterCard(cardType.toString() + "s");
                    }
                    filterCard.add(cardType.getPredicate());
                    sourceObject.addAbility(new ProtectionAbility(filterCard), source.getSourceId(), game);
                }
            }
        }
    }
    return true;
}
Also used : FilterCard(mage.filter.FilterCard) Permanent(mage.game.permanent.Permanent) ProtectionAbility(mage.abilities.keyword.ProtectionAbility) ExileZone(mage.game.ExileZone) UUID(java.util.UUID) FilterCard(mage.filter.FilterCard) Card(mage.cards.Card)

Example 44 with ExileZone

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

the class PraetorsGraspRevealEffect method applies.

@Override
public boolean applies(UUID objectId, Ability source, UUID affectedControllerId, Game game) {
    if (objectId.equals(cardId) && affectedControllerId.equals(source.getControllerId())) {
        Player controller = game.getPlayer(source.getControllerId());
        UUID exileId = CardUtil.getExileZoneId(cardId.toString() + game.getState().getZoneChangeCounter(cardId), game);
        if (exileId != null && controller != null) {
            ExileZone exileZone = game.getExile().getExileZone(exileId);
            if (exileZone != null && exileZone.contains(cardId)) {
                return true;
            } else {
                discard();
            }
        }
    }
    return false;
}
Also used : Player(mage.players.Player) ExileZone(mage.game.ExileZone) UUID(java.util.UUID)

Example 45 with ExileZone

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

the class SearchTheCityExiledCardToHandEffect method checkTrigger.

@Override
public boolean checkTrigger(GameEvent event, Game game) {
    if (event.getPlayerId().equals(this.getControllerId())) {
        String cardName = "";
        if (event.getType() == GameEvent.EventType.SPELL_CAST) {
            Spell spell = game.getStack().getSpell(event.getTargetId());
            if (spell != null) {
                cardName = spell.getName();
            }
        }
        if (event.getType() == GameEvent.EventType.LAND_PLAYED) {
            Card card = game.getCard(event.getTargetId());
            if (card != null) {
                cardName = card.getName();
            }
        }
        if (!cardName.isEmpty()) {
            ExileZone searchTheCityExileZone = game.getExile().getExileZone(this.getSourceId());
            FilterCard filter = new FilterCard();
            filter.add(new NamePredicate(cardName));
            if (searchTheCityExileZone.count(filter, game) > 0) {
                this.getEffects().get(0).setValue("cardName", cardName);
                return true;
            }
        }
    }
    return false;
}
Also used : FilterCard(mage.filter.FilterCard) NamePredicate(mage.filter.predicate.mageobject.NamePredicate) ExileZone(mage.game.ExileZone) Spell(mage.game.stack.Spell) 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