use of mage.game.events.DamageEvent in project mage by magefree.
the class SivvisValorEffect 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 targetPermanent.getId().equals(damageEvent.getTargetId());
}
return false;
}
use of mage.game.events.DamageEvent in project mage by magefree.
the class OpalEyeKondasYojimboRedirectionEffect method replaceEvent.
@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.getLogName());
} else {
message.append("unknown");
}
}
game.informPlayers(message.toString());
// redirect damage
discard();
sourcePermanent.damage(damageEvent.getAmount(), damageEvent.getSourceId(), source, game, damageEvent.isCombatDamage(), damageEvent.isPreventable(), event.getAppliedEffects());
return true;
}
return false;
}
use of mage.game.events.DamageEvent in project mage by magefree.
the class ReverberationEffect method applies.
@Override
public boolean applies(GameEvent event, Ability source, Game game) {
DamageEvent damageEvent = (DamageEvent) event;
Spell targetSpell = game.getStack().getSpell(source.getFirstTarget());
if (targetSpell != null) {
return damageEvent.getAmount() > 0;
}
return false;
}
use of mage.game.events.DamageEvent in project mage by magefree.
the class ShieldDancerRedirectionEffect method applies.
@Override
public boolean applies(GameEvent event, Ability source, Game game) {
if (event.getTargetId().equals(source.getSourceId()) && event.getSourceId().equals(source.getTargets().get(0).getFirstTarget())) {
DamageEvent damageEvent = (DamageEvent) event;
if (damageEvent.isCombatDamage()) {
TargetPermanent target = new TargetPermanent();
target.add(source.getTargets().get(0).getFirstTarget(), game);
redirectTarget = target;
}
return true;
}
return false;
}
use of mage.game.events.DamageEvent in project mage by magefree.
the class JadeMonolithRedirectionEffect method replaceEvent.
@Override
public boolean replaceEvent(GameEvent event, Ability source, Game game) {
Player controller = game.getPlayer(source.getControllerId());
Permanent targetCreature = game.getPermanent(source.getFirstTarget());
MageObject sourceObject = game.getObject(source.getSourceId());
DamageEvent damageEvent = (DamageEvent) event;
if (controller != null && targetCreature != null && sourceObject != null) {
controller.damage(damageEvent.getAmount(), damageEvent.getSourceId(), source, game, damageEvent.isCombatDamage(), damageEvent.isPreventable(), damageEvent.getAppliedEffects());
StringBuilder sb = new StringBuilder(sourceObject.getLogName());
sb.append(": ").append(damageEvent.getAmount()).append(" damage redirected from ").append(targetCreature.getLogName());
sb.append(" to ").append(controller.getLogName());
game.informPlayers(sb.toString());
// only one use
discard();
return true;
}
return false;
}
Aggregations