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;
}
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;
}
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;
}
Aggregations