@Override
public boolean replaceEvent(GameEvent event, Ability source, Game game) {
GameEvent preventEvent = new GameEvent(GameEvent.EventType.PREVENT_DAMAGE, source.getControllerId(), source.getId(), source.getControllerId(), event.getAmount(), false);
if (!game.replaceEvent(preventEvent)) {
Player player = game.getPlayer(source.getFirstTarget());
if (player != null) {
if (event.getAmount() >= this.amount) {
int damage = event.getAmount();
event.setAmount(event.getAmount() - amount);
player.damage(amount, source.getSourceId(), game, false, true);
this.used = true;
game.fireEvent(GameEvent.getEvent(GameEvent.EventType.PREVENTED_DAMAGE, source.getControllerId(), source.getId(), source.getControllerId(), damage));
} else {
int damage = event.getAmount();
event.setAmount(0);
amount -= damage;
player.damage(damage, source.getSourceId(), game, false, true);
game.fireEvent(GameEvent.getEvent(GameEvent.EventType.PREVENTED_DAMAGE, source.getControllerId(), source.getId(), source.getControllerId(), damage));
}
}
}
return false;