Search in sources :

Example 1 with GainSuspendEffect

use of mage.abilities.effects.common.continuous.GainSuspendEffect in project mage by magefree.

the class SuspendEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Player controller = game.getPlayer(source.getControllerId());
    Permanent permanent = game.getPermanent(source.getFirstTarget());
    if (controller == null || permanent == null) {
        return false;
    }
    Card card = permanent.getMainCard();
    if (!controller.moveCards(permanent, Zone.EXILED, source, game) || game.getState().getZone(card.getId()) != Zone.EXILED) {
        return true;
    }
    UUID exileId = SuspendAbility.getSuspendExileId(controller.getId(), game);
    if (!controller.moveCardToExileWithInfo(card, exileId, "Suspended cards of " + controller.getLogName(), source, game, Zone.HAND, true)) {
        return true;
    }
    card.addCounters(CounterType.TIME.createInstance(2), source.getControllerId(), source, game);
    if (!card.getAbilities(game).containsClass(SuspendAbility.class)) {
        game.addEffect(new GainSuspendEffect(new MageObjectReference(card, game)), source);
    }
    game.informPlayers(controller.getLogName() + " suspends 2 - " + card.getName());
    return true;
}
Also used : Player(mage.players.Player) Permanent(mage.game.permanent.Permanent) TargetCreaturePermanent(mage.target.common.TargetCreaturePermanent) SuspendAbility(mage.abilities.keyword.SuspendAbility) UUID(java.util.UUID) GainSuspendEffect(mage.abilities.effects.common.continuous.GainSuspendEffect) MageObjectReference(mage.MageObjectReference) Card(mage.cards.Card)

Example 2 with GainSuspendEffect

use of mage.abilities.effects.common.continuous.GainSuspendEffect in project mage by magefree.

the class EpochrasiteEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Player controller = game.getPlayer(source.getControllerId());
    Card card = game.getCard(source.getSourceId());
    if (controller == null || card == null) {
        return false;
    }
    card = card.getMainCard();
    if (game.getState().getZone(card.getId()) != Zone.GRAVEYARD) {
        return false;
    }
    UUID exileId = SuspendAbility.getSuspendExileId(controller.getId(), game);
    controller.moveCardToExileWithInfo(card, exileId, "Suspended cards of " + controller.getName(), source, game, Zone.GRAVEYARD, true);
    card.addCounters(CounterType.TIME.createInstance(3), source.getControllerId(), source, game);
    game.addEffect(new GainSuspendEffect(new MageObjectReference(card, game)), source);
    return true;
}
Also used : Player(mage.players.Player) UUID(java.util.UUID) GainSuspendEffect(mage.abilities.effects.common.continuous.GainSuspendEffect) MageObjectReference(mage.MageObjectReference) Card(mage.cards.Card)

Example 3 with GainSuspendEffect

use of mage.abilities.effects.common.continuous.GainSuspendEffect in project mage by magefree.

the class JhoiraOfTheGhituSuspendEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Player controller = game.getPlayer(source.getControllerId());
    if (controller == null) {
        return false;
    }
    List<Card> cards = new ArrayList<>();
    for (Cost cost : source.getCosts()) {
        if (cost instanceof ExileFromHandCost) {
            cards = ((ExileFromHandCost) cost).getCards();
        }
    }
    if (cards != null && !cards.isEmpty()) {
        // always one card to exile
        Card card = game.getCard(cards.get(0).getId());
        if (card == null) {
            return false;
        }
        card = card.getMainCard();
        boolean hasSuspend = card.getAbilities(game).containsClass(SuspendAbility.class);
        UUID exileId = SuspendAbility.getSuspendExileId(controller.getId(), game);
        if (controller.moveCardToExileWithInfo(card, exileId, "Suspended cards of " + controller.getName(), source, game, Zone.HAND, true)) {
            card.addCounters(CounterType.TIME.createInstance(4), source.getControllerId(), source, game);
            if (!hasSuspend) {
                game.addEffect(new GainSuspendEffect(new MageObjectReference(card, game)), source);
            }
            game.informPlayers(controller.getLogName() + " suspends 4 - " + card.getName());
            return true;
        }
    }
    return false;
}
Also used : Player(mage.players.Player) ExileFromHandCost(mage.abilities.costs.common.ExileFromHandCost) ArrayList(java.util.ArrayList) UUID(java.util.UUID) GainSuspendEffect(mage.abilities.effects.common.continuous.GainSuspendEffect) ExileFromHandCost(mage.abilities.costs.common.ExileFromHandCost) Cost(mage.abilities.costs.Cost) GenericManaCost(mage.abilities.costs.mana.GenericManaCost) MageObjectReference(mage.MageObjectReference) FilterNonlandCard(mage.filter.common.FilterNonlandCard) Card(mage.cards.Card)

Example 4 with GainSuspendEffect

use of mage.abilities.effects.common.continuous.GainSuspendEffect in project mage by magefree.

the class DelayEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Player controller = game.getPlayer(source.getControllerId());
    Spell spell = game.getStack().getSpell(getTargetPointer().getFirst(game, source));
    if (controller != null && spell != null) {
        Effect effect = new CounterTargetWithReplacementEffect(Zone.EXILED);
        effect.setTargetPointer(targetPointer);
        Card card = game.getCard(spell.getSourceId());
        if (card != null && effect.apply(game, source) && game.getState().getZone(card.getId()) == Zone.EXILED) {
            boolean hasSuspend = card.getAbilities(game).containsClass(SuspendAbility.class);
            UUID exileId = SuspendAbility.getSuspendExileId(controller.getId(), game);
            if (controller.moveCardToExileWithInfo(card, exileId, "Suspended cards of " + controller.getLogName(), source, game, Zone.HAND, true)) {
                card.addCounters(CounterType.TIME.createInstance(3), source.getControllerId(), source, game);
                if (!hasSuspend) {
                    game.addEffect(new GainSuspendEffect(new MageObjectReference(card, game)), source);
                }
                game.informPlayers(controller.getLogName() + " suspends 3 - " + card.getName());
            }
        }
        return true;
    }
    return false;
}
Also used : Player(mage.players.Player) CounterTargetWithReplacementEffect(mage.abilities.effects.common.CounterTargetWithReplacementEffect) OneShotEffect(mage.abilities.effects.OneShotEffect) Effect(mage.abilities.effects.Effect) CounterTargetWithReplacementEffect(mage.abilities.effects.common.CounterTargetWithReplacementEffect) GainSuspendEffect(mage.abilities.effects.common.continuous.GainSuspendEffect) UUID(java.util.UUID) GainSuspendEffect(mage.abilities.effects.common.continuous.GainSuspendEffect) Spell(mage.game.stack.Spell) TargetSpell(mage.target.TargetSpell) MageObjectReference(mage.MageObjectReference) Card(mage.cards.Card)

Aggregations

UUID (java.util.UUID)4 MageObjectReference (mage.MageObjectReference)4 GainSuspendEffect (mage.abilities.effects.common.continuous.GainSuspendEffect)4 Card (mage.cards.Card)4 Player (mage.players.Player)4 ArrayList (java.util.ArrayList)1 Cost (mage.abilities.costs.Cost)1 ExileFromHandCost (mage.abilities.costs.common.ExileFromHandCost)1 GenericManaCost (mage.abilities.costs.mana.GenericManaCost)1 Effect (mage.abilities.effects.Effect)1 OneShotEffect (mage.abilities.effects.OneShotEffect)1 CounterTargetWithReplacementEffect (mage.abilities.effects.common.CounterTargetWithReplacementEffect)1 SuspendAbility (mage.abilities.keyword.SuspendAbility)1 FilterNonlandCard (mage.filter.common.FilterNonlandCard)1 Permanent (mage.game.permanent.Permanent)1 Spell (mage.game.stack.Spell)1 TargetSpell (mage.target.TargetSpell)1 TargetCreaturePermanent (mage.target.common.TargetCreaturePermanent)1