Search in sources :

Example 21 with ExileZone

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

the class IxalansBindingReplacementEffect method applies.

@Override
public boolean applies(GameEvent event, Ability source, Game game) {
    Permanent sourcePermanent = game.getPermanent(source.getSourceId());
    if (event.getPlayerId().equals(source.getControllerId())) {
        return false;
    }
    Card card = game.getCard(event.getSourceId());
    if (sourcePermanent != null && card != null) {
        UUID exileZone = CardUtil.getExileZoneId(game, source.getSourceId(), source.getSourceObjectZoneChangeCounter());
        if (exileZone != null) {
            ExileZone exile = game.getExile().getExileZone(exileZone);
            if (exile == null) {
                // try without ZoneChangeCounter - that is useful for tokens
                exileZone = CardUtil.getCardExileZoneId(game, source);
                if (exileZone != null) {
                    exile = game.getExile().getExileZone(exileZone);
                }
            }
            if (exile != null) {
                for (Card e : exile.getCards(game)) {
                    if (CardUtil.haveSameNames(e, card)) {
                        return true;
                    }
                }
            }
        }
    }
    return false;
}
Also used : FilterNonlandPermanent(mage.filter.common.FilterNonlandPermanent) Permanent(mage.game.permanent.Permanent) TargetPermanent(mage.target.TargetPermanent) ExileZone(mage.game.ExileZone) UUID(java.util.UUID) Card(mage.cards.Card)

Example 22 with ExileZone

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

the class NecromancersConvenantEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Player controller = game.getPlayer(source.getControllerId());
    Player player = game.getPlayer(source.getFirstTarget());
    if (controller == null || player == null) {
        return false;
    }
    Set<Card> cards = player.getGraveyard().getCards(new FilterCreatureCard(), game);
    UUID exileId = CardUtil.getCardExileZoneId(game, source);
    // a previous refactor removed the exile code.  Just putting it back.
    controller.moveCardsToExile(cards, source, game, true, exileId, "Necromancer's Convenant");
    ExileZone exileZone = game.getState().getExile().getExileZone(exileId);
    if (exileZone != null) {
        int count = exileZone.getCards(game).size();
        return count > 0 && new ZombieToken().putOntoBattlefield(count, game, source, controller.getId());
    }
    return false;
}
Also used : TargetPlayer(mage.target.TargetPlayer) Player(mage.players.Player) FilterCreatureCard(mage.filter.common.FilterCreatureCard) ZombieToken(mage.game.permanent.token.ZombieToken) ExileZone(mage.game.ExileZone) UUID(java.util.UUID) FilterCreatureCard(mage.filter.common.FilterCreatureCard) Card(mage.cards.Card)

Example 23 with ExileZone

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

the class ProfaneProcessionEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Player controller = game.getPlayer(source.getControllerId());
    UUID exileId = CardUtil.getCardExileZoneId(game, source);
    MageObject sourceObject = source.getSourceObject(game);
    if (controller != null && exileId != null && sourceObject != null) {
        new ExileTargetEffect(exileId, sourceObject.getIdName()).setTargetPointer(targetPointer).apply(game, source);
        game.getState().processAction(game);
        ExileZone exileZone = game.getExile().getExileZone(exileId);
        if (exileZone != null && exileZone.size() > 2) {
            new TransformSourceEffect().apply(game, source);
        }
        return true;
    }
    return false;
}
Also used : Player(mage.players.Player) TransformSourceEffect(mage.abilities.effects.common.TransformSourceEffect) MageObject(mage.MageObject) ExileZone(mage.game.ExileZone) UUID(java.util.UUID) ExileTargetEffect(mage.abilities.effects.common.ExileTargetEffect)

Example 24 with ExileZone

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

the class RonaDiscipleOfGixExileEffect method applies.

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

Example 25 with ExileZone

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

the class SkyclaveApparitionEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Permanent permanentLeftBattlefield = (Permanent) getValue("permanentLeftBattlefield");
    ExileZone exile = game.getExile().getExileZone(CardUtil.getExileZoneId(game, source.getSourceId(), permanentLeftBattlefield.getZoneChangeCounter(game)));
    if (exile == null || exile.isEmpty()) {
        return false;
    }
    // From ZNR Release Notes:
    // https://magic.wizards.com/en/articles/archive/feature/zendikar-rising-release-notes-2020-09-10
    // If Skyclave Apparition's first ability exiled more than one card owned by a single player,
    // that player creates a token with power and toughness equal to the sum of those cards' converted mana costs.
    // If the first ability exiled cards owned by more than one player, each of those players creates a token
    // with power and toughness equal to the sum of the converted mana costs of all cards exiled by the first ability.
    Set<UUID> owners = new HashSet<>();
    int totalCMC = exile.getCards(game).stream().filter(Objects::nonNull).map(card -> owners.add(card.getOwnerId()) ? card : card).mapToInt(MageObject::getManaValue).sum();
    for (UUID playerId : owners) {
        new CustomIllusionToken(totalCMC).putOntoBattlefield(1, game, source, playerId);
    }
    return true;
}
Also used : FilterNonlandPermanent(mage.filter.common.FilterNonlandPermanent) FilterPermanent(mage.filter.FilterPermanent) Permanent(mage.game.permanent.Permanent) TargetPermanent(mage.target.TargetPermanent) ExileZone(mage.game.ExileZone) CustomIllusionToken(mage.game.permanent.token.CustomIllusionToken) UUID(java.util.UUID) HashSet(java.util.HashSet)

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