use of mage.abilities.effects.common.replacement.DiesReplacementEffect in project mage by magefree.
the class BurnFromWithinEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Player controller = game.getPlayer(source.getControllerId());
if (controller != null) {
Permanent creature = game.getPermanent(getTargetPointer().getFirst(game, source));
int amount = source.getManaCostsToPay().getX();
if (creature != null) {
game.addEffect(new DiesReplacementEffect(new MageObjectReference(creature, game), Duration.EndOfTurn), source);
int damageDealt = creature.damage(amount, source.getSourceId(), source, game, false, true);
if (damageDealt > 0) {
ContinuousEffect effect = new LoseAbilityTargetEffect(IndestructibleAbility.getInstance(), Duration.EndOfTurn);
effect.setTargetPointer(new FixedTarget(creature.getId(), game));
game.addEffect(effect, source);
}
return true;
}
Player targetPlayer = game.getPlayer(this.getTargetPointer().getFirst(game, source));
if (targetPlayer != null) {
targetPlayer.damage(amount, source.getSourceId(), source, game);
return true;
}
}
return false;
}
Aggregations