Search in sources :

Example 11 with AtTheEndOfCombatDelayedTriggeredAbility

use of mage.abilities.common.delayed.AtTheEndOfCombatDelayedTriggeredAbility in project mage by magefree.

the class FlamerushRiderEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Player controller = game.getPlayer(source.getControllerId());
    Permanent permanent = getTargetPointer().getFirstTargetPermanentOrLKI(game, source);
    if (controller != null && permanent != null) {
        CreateTokenCopyTargetEffect effect = new CreateTokenCopyTargetEffect(source.getControllerId(), null, true, 1, true, true);
        effect.setTargetPointer(new FixedTarget(permanent, game));
        effect.apply(game, source);
        for (Permanent addedToken : effect.getAddedPermanents()) {
            Effect exileEffect = new ExileTargetEffect();
            exileEffect.setTargetPointer(new FixedTarget(addedToken, game));
            new CreateDelayedTriggeredAbilityEffect(new AtTheEndOfCombatDelayedTriggeredAbility(exileEffect), false).apply(game, source);
        }
        return true;
    }
    return false;
}
Also used : FixedTarget(mage.target.targetpointer.FixedTarget) Player(mage.players.Player) Permanent(mage.game.permanent.Permanent) FilterCreaturePermanent(mage.filter.common.FilterCreaturePermanent) TargetPermanent(mage.target.TargetPermanent) CreateDelayedTriggeredAbilityEffect(mage.abilities.effects.common.CreateDelayedTriggeredAbilityEffect) ExileTargetEffect(mage.abilities.effects.common.ExileTargetEffect) OneShotEffect(mage.abilities.effects.OneShotEffect) CreateTokenCopyTargetEffect(mage.abilities.effects.common.CreateTokenCopyTargetEffect) Effect(mage.abilities.effects.Effect) CreateDelayedTriggeredAbilityEffect(mage.abilities.effects.common.CreateDelayedTriggeredAbilityEffect) AtTheEndOfCombatDelayedTriggeredAbility(mage.abilities.common.delayed.AtTheEndOfCombatDelayedTriggeredAbility) CreateTokenCopyTargetEffect(mage.abilities.effects.common.CreateTokenCopyTargetEffect) ExileTargetEffect(mage.abilities.effects.common.ExileTargetEffect)

Example 12 with AtTheEndOfCombatDelayedTriggeredAbility

use of mage.abilities.common.delayed.AtTheEndOfCombatDelayedTriggeredAbility in project mage by magefree.

the class GlyphOfDoomEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    if (!source.getTargets().isEmpty() && source.getFirstTarget() != null) {
        MageObjectReference mor = new MageObjectReference(source.getFirstTarget(), game);
        AtTheEndOfCombatDelayedTriggeredAbility delayedAbility = new AtTheEndOfCombatDelayedTriggeredAbility(new GlyphOfDoomEffect(mor));
        game.addDelayedTriggeredAbility(delayedAbility, source);
        return true;
    }
    return false;
}
Also used : AtTheEndOfCombatDelayedTriggeredAbility(mage.abilities.common.delayed.AtTheEndOfCombatDelayedTriggeredAbility) MageObjectReference(mage.MageObjectReference)

Example 13 with AtTheEndOfCombatDelayedTriggeredAbility

use of mage.abilities.common.delayed.AtTheEndOfCombatDelayedTriggeredAbility in project mage by magefree.

the class GyrusWakerOfCorpsesPowerLessThanSourcePredicate method apply.

@Override
public boolean apply(Game game, Ability source) {
    Card card = game.getCard(source.getFirstTarget());
    Player controller = game.getPlayer(source.getControllerId());
    if (controller == null || card == null) {
        return false;
    }
    controller.moveCards(card, Zone.EXILED, source, game);
    CreateTokenCopyTargetEffect effect = new CreateTokenCopyTargetEffect(source.getControllerId(), null, true, 1, true, true);
    effect.setTargetPointer(new FixedTarget(card, game));
    effect.apply(game, source);
    for (Permanent addedToken : effect.getAddedPermanents()) {
        Effect exileEffect = new ExileTargetEffect();
        exileEffect.setTargetPointer(new FixedTarget(addedToken, game));
        new CreateDelayedTriggeredAbilityEffect(new AtTheEndOfCombatDelayedTriggeredAbility(exileEffect), false).apply(game, source);
    }
    return true;
}
Also used : FixedTarget(mage.target.targetpointer.FixedTarget) Player(mage.players.Player) ObjectSourcePlayer(mage.filter.predicate.ObjectSourcePlayer) Permanent(mage.game.permanent.Permanent) CreateDelayedTriggeredAbilityEffect(mage.abilities.effects.common.CreateDelayedTriggeredAbilityEffect) ExileTargetEffect(mage.abilities.effects.common.ExileTargetEffect) AddCountersSourceEffect(mage.abilities.effects.common.counter.AddCountersSourceEffect) CreateDelayedTriggeredAbilityEffect(mage.abilities.effects.common.CreateDelayedTriggeredAbilityEffect) OneShotEffect(mage.abilities.effects.OneShotEffect) CreateTokenCopyTargetEffect(mage.abilities.effects.common.CreateTokenCopyTargetEffect) Effect(mage.abilities.effects.Effect) AtTheEndOfCombatDelayedTriggeredAbility(mage.abilities.common.delayed.AtTheEndOfCombatDelayedTriggeredAbility) CreateTokenCopyTargetEffect(mage.abilities.effects.common.CreateTokenCopyTargetEffect) FilterCreatureCard(mage.filter.common.FilterCreatureCard) Card(mage.cards.Card) ExileTargetEffect(mage.abilities.effects.common.ExileTargetEffect)

Example 14 with AtTheEndOfCombatDelayedTriggeredAbility

use of mage.abilities.common.delayed.AtTheEndOfCombatDelayedTriggeredAbility in project mage by magefree.

the class GeminiEngineCreateTokenEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Player player = game.getPlayer(source.getControllerId());
    if (player == null) {
        return false;
    }
    Permanent permanent = game.getPermanentOrLKIBattlefield(source.getSourceId());
    Token token;
    if (permanent != null) {
        token = new GeminiEngineTwinToken(permanent.getPower().getValue(), permanent.getToughness().getValue());
    } else {
        token = new GeminiEngineTwinToken(0, 0);
    }
    token.putOntoBattlefield(1, game, source, source.getControllerId(), false, true);
    for (UUID tokenId : token.getLastAddedTokenIds()) {
        Permanent tokenPerm = game.getPermanent(tokenId);
        if (tokenPerm != null) {
            Effect effect = new SacrificeTargetEffect("sacrifice " + tokenPerm.getLogName(), player.getId());
            effect.setTargetPointer(new FixedTarget(tokenPerm, game));
            game.addDelayedTriggeredAbility(new AtTheEndOfCombatDelayedTriggeredAbility(effect), source);
        }
    }
    return true;
}
Also used : FixedTarget(mage.target.targetpointer.FixedTarget) Player(mage.players.Player) Permanent(mage.game.permanent.Permanent) GeminiEngineTwinToken(mage.game.permanent.token.GeminiEngineTwinToken) GeminiEngineTwinToken(mage.game.permanent.token.GeminiEngineTwinToken) Token(mage.game.permanent.token.Token) SacrificeTargetEffect(mage.abilities.effects.common.SacrificeTargetEffect) OneShotEffect(mage.abilities.effects.OneShotEffect) Effect(mage.abilities.effects.Effect) SacrificeTargetEffect(mage.abilities.effects.common.SacrificeTargetEffect) AtTheEndOfCombatDelayedTriggeredAbility(mage.abilities.common.delayed.AtTheEndOfCombatDelayedTriggeredAbility) UUID(java.util.UUID)

Example 15 with AtTheEndOfCombatDelayedTriggeredAbility

use of mage.abilities.common.delayed.AtTheEndOfCombatDelayedTriggeredAbility in project mage by magefree.

the class PhantomSteedEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    ExileZone exileZone = game.getState().getExile().getExileZone(CardUtil.getExileZoneId(game, source));
    if (exileZone == null || exileZone.isEmpty()) {
        return false;
    }
    for (Card card : exileZone.getCards(game)) {
        EmptyToken token = new EmptyToken();
        CardUtil.copyTo(token).from(card, game);
        token.addSubType(SubType.ILLUSION);
        token.putOntoBattlefield(1, game, source, source.getControllerId(), true, true);
        List<Permanent> permanents = token.getLastAddedTokenIds().stream().map(game::getPermanent).filter(Objects::nonNull).collect(Collectors.toList());
        game.addDelayedTriggeredAbility(new AtTheEndOfCombatDelayedTriggeredAbility(new ExileTargetEffect("Sacrifice that token at end of combat").setTargetPointer(new FixedTargets(permanents, game))), source);
    }
    return true;
}
Also used : Permanent(mage.game.permanent.Permanent) TargetPermanent(mage.target.TargetPermanent) FixedTargets(mage.target.targetpointer.FixedTargets) ExileZone(mage.game.ExileZone) AtTheEndOfCombatDelayedTriggeredAbility(mage.abilities.common.delayed.AtTheEndOfCombatDelayedTriggeredAbility) Card(mage.cards.Card) EmptyToken(mage.game.permanent.token.EmptyToken) ExileTargetEffect(mage.abilities.effects.common.ExileTargetEffect)

Aggregations

AtTheEndOfCombatDelayedTriggeredAbility (mage.abilities.common.delayed.AtTheEndOfCombatDelayedTriggeredAbility)19 Permanent (mage.game.permanent.Permanent)14 FixedTarget (mage.target.targetpointer.FixedTarget)10 Effect (mage.abilities.effects.Effect)6 OneShotEffect (mage.abilities.effects.OneShotEffect)6 ExileTargetEffect (mage.abilities.effects.common.ExileTargetEffect)6 CreateTokenCopyTargetEffect (mage.abilities.effects.common.CreateTokenCopyTargetEffect)5 Player (mage.players.Player)5 FixedTargets (mage.target.targetpointer.FixedTargets)5 UUID (java.util.UUID)4 TargetPermanent (mage.target.TargetPermanent)4 MageObjectReference (mage.MageObjectReference)3 RemoveCounterSourceEffect (mage.abilities.effects.common.counter.RemoveCounterSourceEffect)3 CreateDelayedTriggeredAbilityEffect (mage.abilities.effects.common.CreateDelayedTriggeredAbilityEffect)2 SacrificeTargetEffect (mage.abilities.effects.common.SacrificeTargetEffect)2 AddCountersSourceEffect (mage.abilities.effects.common.counter.AddCountersSourceEffect)2 Card (mage.cards.Card)2 Token (mage.game.permanent.token.Token)2 TargetCreaturePermanent (mage.target.common.TargetCreaturePermanent)2 ArrayList (java.util.ArrayList)1