use of mage.game.events.DamagedPlayerEvent in project mage by magefree.
the class TheRavensWarningTriggeredAbility method checkTrigger.
@Override
public boolean checkTrigger(GameEvent event, Game game) {
if (event.getType() == GameEvent.EventType.DAMAGED_PLAYER) {
DamagedPlayerEvent damageEvent = (DamagedPlayerEvent) event;
Permanent p = game.getPermanent(event.getSourceId());
if (damageEvent.isCombatDamage() && p != null && p.isControlledBy(this.getControllerId()) && !damagedPlayerIds.contains(event.getPlayerId()) && p.hasAbility(FlyingAbility.getInstance(), game)) {
damagedPlayerIds.add(event.getPlayerId());
this.getEffects().get(0).setTargetPointer(new FixedTarget(event.getPlayerId()));
return true;
}
}
if (event.getType() == GameEvent.EventType.COMBAT_DAMAGE_STEP_PRIORITY || (event.getType() == GameEvent.EventType.ZONE_CHANGE && event.getTargetId().equals(getSourceId()))) {
damagedPlayerIds.clear();
}
return false;
}
use of mage.game.events.DamagedPlayerEvent in project mage by magefree.
the class DawningPuristTriggeredAbility method checkTrigger.
@Override
public boolean checkTrigger(GameEvent event, Game game) {
DamagedPlayerEvent damageEvent = (DamagedPlayerEvent) event;
if (damageEvent.isCombatDamage() && event.getSourceId().equals(this.getSourceId())) {
FilterEnchantmentPermanent filter = new FilterEnchantmentPermanent("enchantment that player controls");
filter.add(new ControllerIdPredicate(event.getPlayerId()));
filter.setMessage("enchantment controlled by " + game.getPlayer(event.getTargetId()).getLogName());
this.getTargets().clear();
this.addTarget(new TargetPermanent(filter));
return true;
}
return false;
}
use of mage.game.events.DamagedPlayerEvent in project mage by magefree.
the class ControllerDealtDamageByPiratesPredicate method watch.
@Override
public void watch(GameEvent event, Game game) {
if (event.getType() == GameEvent.EventType.DAMAGED_PLAYER) {
if (((DamagedPlayerEvent) event).isCombatDamage()) {
Permanent creature = game.getPermanentOrLKIBattlefield(event.getSourceId());
if (creature != null && creature.hasSubtype(SubType.PIRATE, game)) {
if (damageSourceIds.containsKey(event.getTargetId())) {
damageSourceIds.get(event.getTargetId()).add(creature.getId());
} else {
Set<UUID> creatureSet = new HashSet<>();
creatureSet.add(creature.getId());
damageSourceIds.put(event.getTargetId(), creatureSet);
}
}
}
}
}
use of mage.game.events.DamagedPlayerEvent in project mage by magefree.
the class BreathOfFuryEffect method checkTrigger.
@Override
public boolean checkTrigger(GameEvent event, Game game) {
DamagedPlayerEvent damageEvent = (DamagedPlayerEvent) event;
Permanent enchantment = game.getPermanent(getSourceId());
if (damageEvent.isCombatDamage() && enchantment != null && enchantment.isAttachedTo(event.getSourceId())) {
Permanent creature = game.getPermanent(enchantment.getAttachedTo());
if (creature != null) {
for (Effect effect : getEffects()) {
effect.setValue("TriggeringCreatureId", creature.getId());
}
return true;
}
}
return false;
}
use of mage.game.events.DamagedPlayerEvent in project mage by magefree.
the class ChandrasIncineratorTriggeredAbility method checkTrigger.
@Override
public boolean checkTrigger(GameEvent event, Game game) {
DamagedPlayerEvent dEvent = (DamagedPlayerEvent) event;
if (dEvent.isCombatDamage() || !game.getOpponents(event.getTargetId()).contains(getControllerId()) || !game.getControllerId(event.getSourceId()).equals(getControllerId())) {
return false;
}
this.getEffects().clear();
this.addEffect(new DamageTargetEffect(event.getAmount()));
FilterPermanent filter = new FilterCreatureOrPlaneswalkerPermanent("creature or planeswalker");
filter.add(new ControllerIdPredicate(event.getTargetId()));
this.getTargets().clear();
this.addTarget(new TargetPermanent(filter));
return true;
}
Aggregations