Search in sources :

Example 31 with ExileZone

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

the class MindreaverExileEffect method canTarget.

@Override
public boolean canTarget(UUID id, Ability source, Game game) {
    Spell spell = game.getSpell(id);
    ExileZone exileZone = game.getExile().getExileZone(CardUtil.getExileZoneId(game, source));
    return super.canTarget(id, source, game) && spell != null && exileZone != null && !exileZone.isEmpty() && exileZone.getCards(game).stream().filter(Objects::nonNull).anyMatch(card -> CardUtil.haveSameNames(spell, card));
}
Also used : CounterTargetEffect(mage.abilities.effects.common.CounterTargetEffect) SubType(mage.constants.SubType) Player(mage.players.Player) CardType(mage.constants.CardType) Spell(mage.game.stack.Spell) TargetSpell(mage.target.TargetSpell) HeroicAbility(mage.abilities.keyword.HeroicAbility) SimpleActivatedAbility(mage.abilities.common.SimpleActivatedAbility) SacrificeSourceCost(mage.abilities.costs.common.SacrificeSourceCost) Cards(mage.cards.Cards) Outcome(mage.constants.Outcome) OneShotEffect(mage.abilities.effects.OneShotEffect) CardUtil(mage.util.CardUtil) TargetPlayer(mage.target.TargetPlayer) UUID(java.util.UUID) MageInt(mage.MageInt) CardsImpl(mage.cards.CardsImpl) CardSetInfo(mage.cards.CardSetInfo) FilterSpell(mage.filter.FilterSpell) Objects(java.util.Objects) ManaCostsImpl(mage.abilities.costs.mana.ManaCostsImpl) Game(mage.game.Game) ExileZone(mage.game.ExileZone) CardImpl(mage.cards.CardImpl) Ability(mage.abilities.Ability) Objects(java.util.Objects) ExileZone(mage.game.ExileZone) Spell(mage.game.stack.Spell) TargetSpell(mage.target.TargetSpell) FilterSpell(mage.filter.FilterSpell)

Example 32 with ExileZone

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

the class PalaceJailerReturnExiledPermanentsEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Player controller = game.getPlayer(source.getControllerId());
    MageObject sourceObject = source.getSourceObject(game);
    if (sourceObject != null && controller != null) {
        UUID exileZone = CardUtil.getExileZoneId(game, source.getSourceId(), source.getSourceObjectZoneChangeCounter());
        if (exileZone != null) {
            ExileZone exile = game.getExile().getExileZone(exileZone);
            if (exile != null) {
                controller.moveCards(new LinkedHashSet<>(exile.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) UUID(java.util.UUID)

Example 33 with ExileZone

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

the class OtherworldlyJourneyEntersBattlefieldEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Permanent permanent = game.getPermanent(source.getFirstTarget());
    if (permanent != null) {
        if (permanent.moveToExile(source.getSourceId(), "Otherworldly Journey", source, game)) {
            ExileZone exile = game.getExile().getExileZone(source.getSourceId());
            // only if permanent is in exile (tokens would be stop to exist)
            if (exile != null && !exile.isEmpty()) {
                Card card = game.getCard(permanent.getId());
                if (card != null) {
                    // create delayed triggered ability
                    DelayedTriggeredAbility delayedAbility = new AtTheBeginOfNextEndStepDelayedTriggeredAbility(new OtherworldlyJourneyReturnFromExileEffect(new MageObjectReference(card, game)));
                    game.addDelayedTriggeredAbility(delayedAbility, source);
                }
            }
            return true;
        }
    }
    return false;
}
Also used : AtTheBeginOfNextEndStepDelayedTriggeredAbility(mage.abilities.common.delayed.AtTheBeginOfNextEndStepDelayedTriggeredAbility) Permanent(mage.game.permanent.Permanent) TargetCreaturePermanent(mage.target.common.TargetCreaturePermanent) DelayedTriggeredAbility(mage.abilities.DelayedTriggeredAbility) AtTheBeginOfNextEndStepDelayedTriggeredAbility(mage.abilities.common.delayed.AtTheBeginOfNextEndStepDelayedTriggeredAbility) ExileZone(mage.game.ExileZone) MageObjectReference(mage.MageObjectReference) Card(mage.cards.Card)

Example 34 with ExileZone

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

the class SerpentsSoulJarWatcher method applies.

@Override
public boolean applies(UUID sourceId, Ability source, UUID affectedControllerId, Game game) {
    if (!SerpentsSoulJarWatcher.checkPermission(affectedControllerId, source, game)) {
        return false;
    }
    ExileZone exileZone = game.getExile().getExileZone(CardUtil.getExileZoneId(game, source));
    if (exileZone == null || !exileZone.contains(sourceId)) {
        return false;
    }
    Card card = game.getCard(sourceId);
    return card != null && card.isCreature(game) && !card.isLand(game);
}
Also used : ExileZone(mage.game.ExileZone) Card(mage.cards.Card)

Example 35 with ExileZone

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

the class TombOfTheDuskRoseEffect 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) {
        ExileZone exileZone = game.getExile().getExileZone(exileId);
        if (exileZone != null) {
            TargetCard targetCard = new TargetCard(Zone.EXILED, StaticFilters.FILTER_CARD_CREATURE);
            controller.chooseTarget(outcome, exileZone, targetCard, source, game);
            Card card = game.getCard(targetCard.getFirstTarget());
            if (card != null) {
                controller.moveCards(card, Zone.BATTLEFIELD, source, game);
            }
        }
        return true;
    }
    return false;
}
Also used : Player(mage.players.Player) MageObject(mage.MageObject) ExileZone(mage.game.ExileZone) TargetCard(mage.target.TargetCard) UUID(java.util.UUID) TargetCard(mage.target.TargetCard) 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