use of mage.abilities.effects.PreventionEffectData in project mage by magefree.
the class HonorablePassageEffect method replaceEvent.
@Override
public boolean replaceEvent(GameEvent event, Ability source, Game game) {
int damage = event.getAmount();
PreventionEffectData preventEffectData = preventDamageAction(event, source, game);
if (preventEffectData.getPreventedDamage() > 0) {
MageObject sourceObject = game.getObject(event.getSourceId());
if (sourceObject != null && sourceObject.getColor(game).isRed()) {
UUID sourceControllerId = game.getControllerId(event.getSourceId());
if (sourceControllerId != null) {
Player sourceController = game.getPlayer(sourceControllerId);
if (sourceController != null) {
sourceController.damage(damage, source.getSourceId(), source, game);
}
}
}
this.used = true;
}
return false;
}
use of mage.abilities.effects.PreventionEffectData in project mage by magefree.
the class ReverseDamageEffect method replaceEvent.
@Override
public boolean replaceEvent(GameEvent event, Ability source, Game game) {
PreventionEffectData preventionData = preventDamageAction(event, source, game);
this.used = true;
// only one use
this.discard();
if (preventionData.getPreventedDamage() > 0) {
Player player = game.getPlayer(source.getControllerId());
if (player != null) {
player.gainLife(preventionData.getPreventedDamage(), game, source);
}
}
return true;
}
use of mage.abilities.effects.PreventionEffectData in project mage by magefree.
the class SamiteMinistrationEffect method replaceEvent.
@Override
public boolean replaceEvent(GameEvent event, Ability source, Game game) {
PreventionEffectData preventionData = preventDamageAction(event, source, game);
MageObject sourceObject = game.getObject(event.getSourceId());
if (sourceObject != null && (sourceObject.getColor(game).isBlack() || sourceObject.getColor(game).isRed())) {
Player player = game.getPlayer(source.getControllerId());
if (player != null) {
player.gainLife(preventionData.getPreventedDamage(), game, source);
}
}
return false;
}
use of mage.abilities.effects.PreventionEffectData 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.abilities.effects.PreventionEffectData in project mage by magefree.
the class RefractionTrapPreventDamageEffect method replaceEvent.
@Override
public boolean replaceEvent(GameEvent event, Ability source, Game game) {
PreventionEffectData preventionData = preventDamageAction(event, source, game);
this.used = true;
// only one use
this.discard();
if (preventionData.getPreventedDamage() > 0) {
UUID damageTarget = getTargetPointer().getFirst(game, source);
Permanent permanent = game.getPermanent(damageTarget);
if (permanent != null) {
game.informPlayers("Dealing " + preventionData.getPreventedDamage() + " to " + permanent.getLogName());
permanent.damage(preventionData.getPreventedDamage(), source.getSourceId(), source, game, false, true);
}
Player player = game.getPlayer(damageTarget);
if (player != null) {
game.informPlayers("Dealing " + preventionData.getPreventedDamage() + " to " + player.getLogName());
player.damage(preventionData.getPreventedDamage(), source.getSourceId(), source, game);
}
}
return false;
}
Aggregations