use of mage.game.events.DamagedPlayerEvent in project mage by magefree.
the class FelineSovereignTriggeredAbility 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()) && filter.match(p, getSourceId(), getControllerId(), game) && !damagedPlayerIds.contains(event.getPlayerId())) {
damagedPlayerIds.add(event.getPlayerId());
this.getTargets().clear();
FilterArtifactOrEnchantmentPermanent filter = new FilterArtifactOrEnchantmentPermanent();
filter.add(new ControllerIdPredicate(event.getPlayerId()));
this.addTarget(new TargetPermanent(0, 1, filter, false));
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 SpellbinderCopyEffect method checkTrigger.
@Override
public boolean checkTrigger(GameEvent event, Game game) {
DamagedPlayerEvent damageEvent = (DamagedPlayerEvent) event;
Permanent p = game.getPermanent(event.getSourceId());
return damageEvent.isCombatDamage() && p != null && p.getAttachments().contains(this.getSourceId());
}
use of mage.game.events.DamagedPlayerEvent in project mage by magefree.
the class SwordOfDungeonsAndDragonsEffect method checkTrigger.
@Override
public boolean checkTrigger(GameEvent event, Game game) {
DamagedPlayerEvent damageEvent = (DamagedPlayerEvent) event;
Permanent p = game.getPermanent(event.getSourceId());
if (damageEvent.isCombatDamage() && p != null && p.getAttachments().contains(this.getSourceId())) {
for (Effect effect : this.getEffects()) {
effect.setTargetPointer(new FixedTarget(event.getPlayerId()));
}
return true;
}
return false;
}
use of mage.game.events.DamagedPlayerEvent in project mage by magefree.
the class SwordOfWarAndPeaceDamageEffect method checkTrigger.
@Override
public boolean checkTrigger(GameEvent event, Game game) {
DamagedPlayerEvent damageEvent = (DamagedPlayerEvent) event;
Permanent damageSource = game.getPermanentOrLKIBattlefield(event.getSourceId());
if (damageEvent.isCombatDamage() && damageSource != null && damageSource.getAttachments().contains(this.getSourceId())) {
getEffects().setTargetPointer(new FixedTarget(event.getPlayerId()));
return true;
}
return false;
}
use of mage.game.events.DamagedPlayerEvent in project mage by magefree.
the class MonarchDealsCombatDamageToAPlayerTriggeredAbility method checkTrigger.
@Override
public boolean checkTrigger(GameEvent event, Game game) {
if (((DamagedPlayerEvent) event).isCombatDamage()) {
MageObject damagingObject = game.getObject(event.getSourceId());
if (damagingObject instanceof Permanent && damagingObject.isCreature(game) && event.getTargetId().equals(game.getMonarchId())) {
setControllerId(event.getPlayerId());
getEffects().get(0).setTargetPointer(new FixedTarget(((Permanent) damagingObject).getControllerId()));
return true;
}
}
return false;
}
Aggregations