use of mage.game.events.DamageEvent in project mage by magefree.
the class AscentOfTheWorthyReturnEffect method replaceEvent.
@Override
public boolean replaceEvent(GameEvent event, Ability source, Game game) {
DamageEvent damageEvent = (DamageEvent) event;
Permanent permanent = mor.getPermanent(game);
if (permanent != null) {
permanent.damage(damageEvent.getAmount(), event.getSourceId(), source, game, damageEvent.isCombatDamage(), damageEvent.isPreventable(), damageEvent.getAppliedEffects());
return true;
}
return false;
}
use of mage.game.events.DamageEvent in project mage by magefree.
the class DarkSpherePreventionEffect method replaceEvent.
@Override
public boolean replaceEvent(GameEvent event, Ability source, Game game) {
Player controller = game.getPlayer(source.getControllerId());
MageObject sourceObject = game.getObject(source.getSourceId());
DamageEvent damageEvent = (DamageEvent) event;
if (controller != null) {
controller.damage((int) Math.ceil(damageEvent.getAmount() / 2.0), damageEvent.getSourceId(), source, game, damageEvent.isCombatDamage(), damageEvent.isPreventable(), damageEvent.getAppliedEffects());
StringBuilder sb = new StringBuilder(sourceObject != null ? sourceObject.getLogName() : "");
sb.append(": ").append(damageEvent.getAmount() / 2).append(" damage prevented");
sb.append(" from ").append(controller.getLogName());
game.informPlayers(sb.toString());
// only one use
discard();
return true;
}
return false;
}
use of mage.game.events.DamageEvent in project mage by magefree.
the class GideonsSacrificeEffectReplacementEffect method replaceEvent.
@Override
public boolean replaceEvent(GameEvent event, Ability source, Game game) {
DamageEvent damageEvent = (DamageEvent) event;
Permanent permanent = mor.getPermanent(game);
if (permanent == null) {
return false;
}
// Name of old target
Permanent targetPermanent = game.getPermanent(event.getTargetId());
StringBuilder message = new StringBuilder();
message.append(permanent.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
permanent.damage(damageEvent.getAmount(), damageEvent.getSourceId(), source, game, damageEvent.isCombatDamage(), damageEvent.isPreventable(), event.getAppliedEffects());
return true;
}
use of mage.game.events.DamageEvent in project mage by magefree.
the class MirrorStrikeEffect method applies.
@Override
public boolean applies(GameEvent event, Ability source, Game game) {
Player controller = game.getPlayer(source.getControllerId());
DamageEvent damageEvent = (DamageEvent) event;
Permanent targetPermanent = game.getPermanent(source.getFirstTarget());
if (controller != null && targetPermanent != null) {
return (damageEvent.isCombatDamage() && Objects.equals(controller.getId(), damageEvent.getTargetId()) && Objects.equals(targetPermanent.getId(), damageEvent.getSourceId()));
}
return false;
}
use of mage.game.events.DamageEvent in project mage by magefree.
the class ImpulsiveManeuversEffect 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) {
DamageEvent damageEvent = (DamageEvent) event;
if (damageEvent.isCombatDamage()) {
if (wonFlip) {
event.setAmount(CardUtil.overflowMultiply(event.getAmount(), 2));
this.discard();
} else {
preventDamageAction(event, source, game);
this.discard();
return true;
}
}
}
}
return false;
}
Aggregations