use of mage.game.events.DamageEvent in project mage by magefree.
the class EyeForAnEyeEffect 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());
UUID sourceControllerId = game.getControllerId(damageEvent.getSourceId());
if (sourceControllerId != null) {
Player sourceController = game.getPlayer(sourceControllerId);
if (sourceController != null) {
sourceController.damage(damageEvent.getAmount(), source.getSourceId(), source, game);
return true;
}
}
}
return false;
}
use of mage.game.events.DamageEvent in project mage by magefree.
the class ReverberationEffect 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) {
Spell targetSpell = game.getStack().getSpell(source.getFirstTarget());
if (targetSpell != null) {
Player targetsController = game.getPlayer(targetSpell.getControllerId());
if (targetsController != null) {
targetsController.damage(damageEvent.getAmount(), damageEvent.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 SoulEchoReplacementEffect method replaceEvent.
@Override
public boolean replaceEvent(GameEvent event, Ability source, Game game) {
DamageEvent damageEvent = (DamageEvent) event;
int damage = damageEvent.getAmount();
Permanent permanent = game.getPermanentOrLKIBattlefield(source.getSourceId());
Player controller = game.getPlayer(source.getControllerId());
if (permanent != null && controller != null) {
permanent.removeCounters(CounterType.ECHO.createInstance(damage), source, game);
game.informPlayers(controller.getLogName() + ": " + damage + " damage replaced with " + permanent.getLogName());
}
return true;
}
use of mage.game.events.DamageEvent in project mage by magefree.
the class SoltariGuerrillasReplacementEffect method replaceEvent.
@Override
public boolean replaceEvent(GameEvent event, Ability source, Game game) {
PreventionEffectData preventionResult = preventDamageAction(event, source, game);
if (preventionResult.getPreventedDamage() > 0) {
Permanent redirectTo = game.getPermanent(getTargetPointer().getFirst(game, source));
if (redirectTo != null) {
game.informPlayers("Dealing " + preventionResult.getPreventedDamage() + " to " + redirectTo.getLogName() + " instead.");
DamageEvent damageEvent = (DamageEvent) event;
redirectTo.damage(preventionResult.getPreventedDamage(), event.getSourceId(), source, game, damageEvent.isCombatDamage(), damageEvent.isPreventable(), event.getAppliedEffects());
}
// (only once)
discard();
}
return false;
}
use of mage.game.events.DamageEvent in project mage by magefree.
the class WallOfShadowsEffect method applies.
@Override
public boolean applies(GameEvent event, Ability source, Game game) {
if (!super.applies(event, source, game) || !(event instanceof DamageEvent) || event.getAmount() <= 0) {
return false;
}
DamageEvent damageEvent = (DamageEvent) event;
if (!event.getTargetId().equals(source.getSourceId())) {
return false;
}
Permanent permanent = game.getPermanentOrLKIBattlefield(damageEvent.getSourceId());
FilterCreaturePermanent filter = new FilterCreaturePermanent();
filter.add(new BlockedByIdPredicate(source.getSourceId()));
return permanent != null && filter.match(permanent, game);
}
Aggregations