@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(), game, damageEvent.isCombatDamage(), damageEvent.isPreventable(), event.getAppliedEffects()); } discard(); // (only once) } return false; }
@Override public boolean replaceEvent(GameEvent event, Ability source, Game game) { DamageEvent damageEvent = (DamageEvent) event; Permanent sourcePermanent = game.getPermanent(source.getSourceId()); if (sourcePermanent != null) { // get name of old target Permanent targetPermanent = game.getPermanent(event.getTargetId()); StringBuilder message = new StringBuilder(); message.append(sourcePermanent.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.getName()); } else { message.append("unknown"); } } game.informPlayers(message.toString()); // redirect damage this.used = true; sourcePermanent.damage( damageEvent.getAmount(), damageEvent.getSourceId(), game, damageEvent.isPreventable(), damageEvent.isCombatDamage(), event.getAppliedEffects()); return true; } return false; }