Search in sources :

Example 1 with LoseLifeSourceControllerEffect

use of mage.abilities.effects.common.LoseLifeSourceControllerEffect in project mage by magefree.

the class BroodOfCockroachesEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    AtTheBeginOfNextEndStepDelayedTriggeredAbility delayedLifeLost = new AtTheBeginOfNextEndStepDelayedTriggeredAbility(new LoseLifeSourceControllerEffect(1));
    game.addDelayedTriggeredAbility(delayedLifeLost, source);
    Effect effect = new ReturnToHandTargetEffect();
    effect.setText("return {this} to your hand.");
    effect.setTargetPointer(new FixedTarget(source.getSourceId(), source.getSourceObjectZoneChangeCounter()));
    DelayedTriggeredAbility delayedAbility = new AtTheBeginOfNextEndStepDelayedTriggeredAbility(effect);
    game.addDelayedTriggeredAbility(delayedAbility, source);
    return true;
}
Also used : FixedTarget(mage.target.targetpointer.FixedTarget) AtTheBeginOfNextEndStepDelayedTriggeredAbility(mage.abilities.common.delayed.AtTheBeginOfNextEndStepDelayedTriggeredAbility) DelayedTriggeredAbility(mage.abilities.DelayedTriggeredAbility) AtTheBeginOfNextEndStepDelayedTriggeredAbility(mage.abilities.common.delayed.AtTheBeginOfNextEndStepDelayedTriggeredAbility) OneShotEffect(mage.abilities.effects.OneShotEffect) Effect(mage.abilities.effects.Effect) ReturnToHandTargetEffect(mage.abilities.effects.common.ReturnToHandTargetEffect) LoseLifeSourceControllerEffect(mage.abilities.effects.common.LoseLifeSourceControllerEffect) ReturnToHandTargetEffect(mage.abilities.effects.common.ReturnToHandTargetEffect) LoseLifeSourceControllerEffect(mage.abilities.effects.common.LoseLifeSourceControllerEffect)

Example 2 with LoseLifeSourceControllerEffect

use of mage.abilities.effects.common.LoseLifeSourceControllerEffect in project mage by magefree.

the class DealtDamageLoseLifeTriggeredAbility method checkTrigger.

@Override
public boolean checkTrigger(GameEvent event, Game game) {
    if (event.getTargetId().equals(this.sourceId)) {
        this.getEffects().clear();
        this.addEffect(new LoseLifeSourceControllerEffect(event.getAmount()));
        return true;
    }
    return false;
}
Also used : LoseLifeSourceControllerEffect(mage.abilities.effects.common.LoseLifeSourceControllerEffect)

Example 3 with LoseLifeSourceControllerEffect

use of mage.abilities.effects.common.LoseLifeSourceControllerEffect in project mage by magefree.

the class DelayingShieldUpkeepEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Player controller = game.getPlayer(source.getControllerId());
    Permanent permanent = game.getPermanent(source.getSourceId());
    if (controller != null && permanent != null) {
        int numCounters = permanent.getCounters(game).getCount(CounterType.DELAY);
        permanent.removeCounters(CounterType.DELAY.createInstance(numCounters), source, game);
        for (int i = numCounters; i > 0; i--) {
            if (controller.chooseUse(Outcome.Benefit, "Pay {1}{W}? (" + i + " counters left to pay)", source, game)) {
                Cost cost = new ManaCostsImpl<>("{1}{W}");
                if (cost.pay(source, game, source, source.getControllerId(), false, null)) {
                    continue;
                }
            }
            new LoseLifeSourceControllerEffect(1).apply(game, source);
        }
        return true;
    }
    return false;
}
Also used : Player(mage.players.Player) Permanent(mage.game.permanent.Permanent) LoseLifeSourceControllerEffect(mage.abilities.effects.common.LoseLifeSourceControllerEffect) Cost(mage.abilities.costs.Cost) ManaCostsImpl(mage.abilities.costs.mana.ManaCostsImpl)

Aggregations

LoseLifeSourceControllerEffect (mage.abilities.effects.common.LoseLifeSourceControllerEffect)3 DelayedTriggeredAbility (mage.abilities.DelayedTriggeredAbility)1 AtTheBeginOfNextEndStepDelayedTriggeredAbility (mage.abilities.common.delayed.AtTheBeginOfNextEndStepDelayedTriggeredAbility)1 Cost (mage.abilities.costs.Cost)1 ManaCostsImpl (mage.abilities.costs.mana.ManaCostsImpl)1 Effect (mage.abilities.effects.Effect)1 OneShotEffect (mage.abilities.effects.OneShotEffect)1 ReturnToHandTargetEffect (mage.abilities.effects.common.ReturnToHandTargetEffect)1 Permanent (mage.game.permanent.Permanent)1 Player (mage.players.Player)1 FixedTarget (mage.target.targetpointer.FixedTarget)1