use of mage.game.events.DamageEvent in project mage by magefree.
the class SavingGraceReplacementEffect method replaceEvent.
@Override
public boolean replaceEvent(GameEvent event, Ability source, Game game) {
DamageEvent damageEvent = (DamageEvent) event;
Permanent sourcePermanent = game.getPermanent(source.getSourceId());
if (sourcePermanent != null) {
Permanent creature = game.getPermanent(sourcePermanent.getAttachedTo());
if (creature == null) {
return false;
}
// Name of old target
Permanent targetPermanent = game.getPermanent(event.getTargetId());
StringBuilder message = new StringBuilder();
message.append(creature.getName()).append(": gets ");
message.append(damageEvent.getAmount()).append(" damage redirected from ");
if (targetPermanent != null) {
message.append(targetPermanent.getName());
} else {
Player targetPlayer = game.getPlayer(event.getTargetId());
if (targetPlayer != null) {
message.append(targetPlayer.getLogName());
} else {
message.append("unknown");
}
}
game.informPlayers(message.toString());
// Redirect damage
creature.damage(damageEvent.getAmount(), damageEvent.getSourceId(), source, game, damageEvent.isCombatDamage(), damageEvent.isPreventable(), event.getAppliedEffects());
return true;
}
return false;
}
use of mage.game.events.DamageEvent in project mage by magefree.
the class TargetControlledSource method replaceEvent.
@Override
public boolean replaceEvent(GameEvent event, Ability source, Game game) {
MageObject object = game.getObject(event.getSourceId());
Player controller = game.getPlayer(source.getControllerId());
if (controller != null && object != null) {
if (super.applies(event, source, game) && event instanceof DamageEvent && event.getAmount() > 0) {
if (wonFlip) {
event.setAmount(CardUtil.overflowMultiply(event.getAmount(), 2));
this.discard();
} else {
preventDamageAction(event, source, game);
this.discard();
return true;
}
}
}
return false;
}
use of mage.game.events.DamageEvent in project mage by magefree.
the class DralnuLichLordFlashbackEffect method replaceEvent.
@Override
public boolean replaceEvent(GameEvent event, Ability source, Game game) {
DamageEvent damageEvent = (DamageEvent) event;
new SacrificeControllerEffect(new FilterPermanent(), damageEvent.getAmount(), "").apply(game, source);
return true;
}
use of mage.game.events.DamageEvent in project mage by magefree.
the class OraclesAttendantsReplacementEffect method replaceEvent.
@Override
public boolean replaceEvent(GameEvent event, Ability source, Game game) {
Permanent permanent = game.getPermanent(source.getSourceId());
DamageEvent damageEvent = (DamageEvent) event;
if (permanent != null) {
permanent.damage(damageEvent.getAmount(), damageEvent.getSourceId(), source, game, damageEvent.isCombatDamage(), damageEvent.isPreventable());
return true;
}
return false;
}
use of mage.game.events.DamageEvent in project mage by magefree.
the class SivvisValorEffect method replaceEvent.
@Override
public boolean replaceEvent(GameEvent event, Ability source, Game game) {
Player controller = game.getPlayer(source.getControllerId());
DamageEvent damageEvent = (DamageEvent) event;
if (controller != null) {
controller.damage(damageEvent.getAmount(), damageEvent.getSourceId(), source, game, damageEvent.isCombatDamage(), damageEvent.isPreventable(), damageEvent.getAppliedEffects());
return true;
}
return false;
}
Aggregations