Search in sources :

Example 6 with AtTheEndOfCombatDelayedTriggeredAbility

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

the class GazeOfTheGorgonEffect 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 GazeOfTheGorgonEffect(mor));
        game.addDelayedTriggeredAbility(delayedAbility, source);
        return true;
    }
    return false;
}
Also used : AtTheEndOfCombatDelayedTriggeredAbility(mage.abilities.common.delayed.AtTheEndOfCombatDelayedTriggeredAbility) MageObjectReference(mage.MageObjectReference)

Example 7 with AtTheEndOfCombatDelayedTriggeredAbility

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

the class ArrogantBloodlordEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Permanent permanent = game.getPermanent(source.getSourceId());
    if (permanent != null) {
        AtTheEndOfCombatDelayedTriggeredAbility delayedAbility = new AtTheEndOfCombatDelayedTriggeredAbility(new DestroyTargetEffect());
        delayedAbility.getEffects().get(0).setTargetPointer(new FixedTarget(permanent, game));
        game.addDelayedTriggeredAbility(delayedAbility, source);
        return true;
    }
    return false;
}
Also used : FixedTarget(mage.target.targetpointer.FixedTarget) Permanent(mage.game.permanent.Permanent) DestroyTargetEffect(mage.abilities.effects.common.DestroyTargetEffect) AtTheEndOfCombatDelayedTriggeredAbility(mage.abilities.common.delayed.AtTheEndOfCombatDelayedTriggeredAbility)

Example 8 with AtTheEndOfCombatDelayedTriggeredAbility

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

the class MirrorMockeryEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    // In the case that the enchantment is blinked
    Permanent enchantment = (Permanent) game.getLastKnownInformation(source.getSourceId(), Zone.BATTLEFIELD);
    if (enchantment == null) {
        // It was not blinked, use the standard method
        enchantment = game.getPermanentOrLKIBattlefield(source.getSourceId());
    }
    if (enchantment == null) {
        return false;
    }
    Permanent enchanted = game.getPermanentOrLKIBattlefield(enchantment.getAttachedTo());
    if (enchanted != null) {
        CreateTokenCopyTargetEffect effect = new CreateTokenCopyTargetEffect();
        effect.setTargetPointer(new FixedTarget(enchanted, game));
        effect.apply(game, source);
        for (Permanent addedToken : effect.getAddedPermanents()) {
            if (addedToken != null) {
                ExileTargetEffect exileEffect = new ExileTargetEffect();
                exileEffect.setTargetPointer(new FixedTarget(addedToken, game));
                game.addDelayedTriggeredAbility(new AtTheEndOfCombatDelayedTriggeredAbility(exileEffect), source);
            }
        }
        return true;
    }
    return false;
}
Also used : FixedTarget(mage.target.targetpointer.FixedTarget) Permanent(mage.game.permanent.Permanent) TargetCreaturePermanent(mage.target.common.TargetCreaturePermanent) TargetPermanent(mage.target.TargetPermanent) AtTheEndOfCombatDelayedTriggeredAbility(mage.abilities.common.delayed.AtTheEndOfCombatDelayedTriggeredAbility) CreateTokenCopyTargetEffect(mage.abilities.effects.common.CreateTokenCopyTargetEffect) ExileTargetEffect(mage.abilities.effects.common.ExileTargetEffect)

Example 9 with AtTheEndOfCombatDelayedTriggeredAbility

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

the class MirrorMatchEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Player controller = game.getPlayer(source.getControllerId());
    if (controller != null) {
        for (UUID attackerId : game.getCombat().getAttackers()) {
            Permanent attacker = game.getPermanent(attackerId);
            if (attacker != null && source.isControlledBy(game.getCombat().getDefendingPlayerId(attackerId, game))) {
                CreateTokenCopyTargetEffect effect = new CreateTokenCopyTargetEffect(source.getControllerId(), null, false);
                effect.setTargetPointer(new FixedTarget(attacker, game));
                effect.apply(game, source);
                CombatGroup group = game.getCombat().findGroup(attacker.getId());
                boolean isCreature = false;
                if (group != null) {
                    for (Permanent addedToken : effect.getAddedPermanents()) {
                        if (addedToken.isCreature(game)) {
                            group.addBlockerToGroup(addedToken.getId(), attackerId, game);
                            isCreature = true;
                        }
                    }
                    ExileTargetEffect exileEffect = new ExileTargetEffect("Exile those tokens at end of combat");
                    exileEffect.setTargetPointer(new FixedTargets(effect.getAddedPermanents(), game));
                    game.addDelayedTriggeredAbility(new AtTheEndOfCombatDelayedTriggeredAbility(exileEffect), source);
                    if (isCreature) {
                        group.pickBlockerOrder(attacker.getControllerId(), game);
                    }
                }
            }
        }
        return true;
    }
    return false;
}
Also used : FixedTarget(mage.target.targetpointer.FixedTarget) Player(mage.players.Player) Permanent(mage.game.permanent.Permanent) FixedTargets(mage.target.targetpointer.FixedTargets) AtTheEndOfCombatDelayedTriggeredAbility(mage.abilities.common.delayed.AtTheEndOfCombatDelayedTriggeredAbility) UUID(java.util.UUID) CreateTokenCopyTargetEffect(mage.abilities.effects.common.CreateTokenCopyTargetEffect) CombatGroup(mage.game.combat.CombatGroup) ExileTargetEffect(mage.abilities.effects.common.ExileTargetEffect)

Example 10 with AtTheEndOfCombatDelayedTriggeredAbility

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

the class VenomousBreathEffect 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 VenomousBreathEffect(mor));
        game.addDelayedTriggeredAbility(delayedAbility, source);
        return true;
    }
    return false;
}
Also used : AtTheEndOfCombatDelayedTriggeredAbility(mage.abilities.common.delayed.AtTheEndOfCombatDelayedTriggeredAbility) MageObjectReference(mage.MageObjectReference)

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