use of mage.game.events.DamagedEvent in project mage by magefree.
the class PiousWarriorGainLifeEffect method checkTrigger.
@Override
public boolean checkTrigger(GameEvent event, Game game) {
Permanent permanent = game.getPermanent(event.getTargetId());
if (permanent == null || !permanent.isCreature(game) || !event.getTargetId().equals(this.sourceId) || !((DamagedEvent) event).isCombatDamage()) {
return false;
}
this.getEffects().setValue("damageAmount", event.getAmount());
return true;
}
use of mage.game.events.DamagedEvent in project mage by magefree.
the class BlazingSunsteelEffect method checkTrigger.
@Override
public boolean checkTrigger(GameEvent event, Game game) {
Permanent equipment = game.getPermanent(this.getSourceId());
if (equipment == null) {
return false;
}
UUID attachedCreature = equipment.getAttachedTo();
if (attachedCreature == null) {
return false;
}
int damage = 0;
DamagedPermanentBatchEvent dEvent = (DamagedPermanentBatchEvent) event;
for (DamagedEvent damagedEvent : dEvent.getEvents()) {
UUID targetID = damagedEvent.getTargetId();
if (targetID == null) {
continue;
}
if (targetID == attachedCreature) {
damage += damagedEvent.getAmount();
}
}
if (damage > 0) {
this.getEffects().setValue("equipped", attachedCreature);
this.getEffects().setValue("damage", damage);
return true;
}
return false;
}
use of mage.game.events.DamagedEvent in project mage by magefree.
the class ArashinWarBeastTriggeredAbility method checkTrigger.
@Override
public boolean checkTrigger(GameEvent event, Game game) {
if (event.getType() == GameEvent.EventType.DAMAGED_PERMANENT && event.getSourceId().equals(this.sourceId) && ((DamagedEvent) event).isCombatDamage() && !usedForCombatDamageStep) {
Permanent creature = game.getPermanentOrLKIBattlefield(event.getTargetId());
if (creature == null || !filter.match(creature, getSourceId(), getControllerId(), game)) {
return false;
}
// trigger only once per combat damage step
usedForCombatDamageStep = true;
return true;
}
if (event.getType() == GameEvent.EventType.COMBAT_DAMAGE_STEP_POST) {
usedForCombatDamageStep = false;
}
return false;
}
use of mage.game.events.DamagedEvent in project mage by magefree.
the class BreechesBrazenPlundererEffect method checkTrigger.
@Override
public boolean checkTrigger(GameEvent event, Game game) {
DamagedPlayerBatchEvent dEvent = (DamagedPlayerBatchEvent) event;
Set<UUID> opponents = new HashSet<>();
for (DamagedEvent damagedEvent : dEvent.getEvents()) {
Permanent permanent = game.getPermanent(damagedEvent.getSourceId());
if (permanent == null || !permanent.isControlledBy(getControllerId()) || !permanent.hasSubtype(SubType.PIRATE, game) || !game.getOpponents(getControllerId()).contains(damagedEvent.getTargetId())) {
continue;
}
opponents.add(damagedEvent.getTargetId());
}
if (opponents.size() < 1) {
return false;
}
this.getEffects().clear();
this.addEffect(new BreechesBrazenPlundererEffect(opponents));
return true;
}
use of mage.game.events.DamagedEvent in project mage by magefree.
the class AegarTheFreezingFlameWatcher method checkTrigger.
@Override
public boolean checkTrigger(GameEvent event, Game game) {
DamagedEvent dEvent = (DamagedEvent) event;
if (dEvent.getExcess() < 1 || !game.getOpponents(getControllerId()).contains(game.getControllerId(event.getTargetId()))) {
return false;
}
AegarTheFreezingFlameWatcher watcher = game.getState().getWatcher(AegarTheFreezingFlameWatcher.class);
return watcher != null && watcher.checkDamage(getControllerId(), event.getTargetId(), game);
}
Aggregations