use of mage.game.events.DamagedPlayerEvent in project mage by magefree.
the class WorldslayerEffect 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 DealsDamageToOpponentTriggeredAbility method checkTrigger.
@Override
public boolean checkTrigger(GameEvent event, Game game) {
if (event.getSourceId().equals(this.sourceId) && game.getOpponents(this.getControllerId()).contains(event.getTargetId())) {
if (onlyCombat && event instanceof DamagedPlayerEvent) {
DamagedPlayerEvent damageEvent = (DamagedPlayerEvent) event;
if (!damageEvent.isCombatDamage()) {
return false;
}
}
if (setTargetPointer) {
for (Effect effect : getEffects()) {
effect.setTargetPointer(new FixedTarget(event.getTargetId(), game));
effect.setValue("damage", event.getAmount());
}
}
return true;
}
return false;
}
use of mage.game.events.DamagedPlayerEvent in project mage by magefree.
the class ControlledCreaturesDealCombatDamagePlayerTriggeredAbility method checkTrigger.
@Override
public boolean checkTrigger(GameEvent event, Game game) {
if (event.getType() == GameEvent.EventType.COMBAT_DAMAGE_STEP_PRIORITY || (event.getType() == GameEvent.EventType.ZONE_CHANGE && event.getTargetId().equals(getSourceId()))) {
damagedPlayerIds.clear();
return false;
}
if (event.getType() != EventType.DAMAGED_PLAYER) {
return false;
}
DamagedPlayerEvent damageEvent = (DamagedPlayerEvent) event;
Permanent p = game.getPermanent(event.getSourceId());
if (!damageEvent.isCombatDamage() || p == null || !p.isControlledBy(this.getControllerId()) || damagedPlayerIds.contains(event.getPlayerId()) || (onlyOpponents && !game.getOpponents(getControllerId()).contains(event.getPlayerId()))) {
return false;
}
damagedPlayerIds.add(event.getPlayerId());
if (setTargetPointer) {
this.getEffects().setTargetPointer(new FixedTarget(event.getPlayerId()));
}
return true;
}
use of mage.game.events.DamagedPlayerEvent in project mage by magefree.
the class EtrataTheSilencerEffect method checkTrigger.
@Override
public boolean checkTrigger(GameEvent event, Game game) {
DamagedPlayerEvent damageEvent = (DamagedPlayerEvent) event;
if (damageEvent.isCombatDamage() && event.getSourceId().equals(this.getSourceId())) {
Player opponent = game.getPlayer(event.getPlayerId());
if (opponent != null) {
FilterCreaturePermanent filter = new FilterCreaturePermanent("creature " + opponent.getLogName() + " controls");
filter.add(new ControllerIdPredicate(opponent.getId()));
this.getTargets().clear();
this.addTarget(new TargetCreaturePermanent(filter));
return true;
}
}
return false;
}
use of mage.game.events.DamagedPlayerEvent in project mage by magefree.
the class LiegeOfTheTangleEffect 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.getId().equals(this.getSourceId());
}
Aggregations