use of mage.game.events.DamagedPlayerEvent in project mage by magefree.
the class DealsDamageToAPlayerAllTriggeredAbility method checkTrigger.
@Override
public boolean checkTrigger(GameEvent event, Game game) {
if (onlyCombat && !((DamagedPlayerEvent) event).isCombatDamage()) {
return false;
}
if (targetController == TargetController.OPPONENT && !game.getOpponents(getControllerId()).contains(event.getTargetId())) {
return false;
}
Permanent permanent = game.getPermanent(event.getSourceId());
if (!filter.match(permanent, getSourceId(), getControllerId(), game)) {
return false;
}
this.getEffects().setValue("damage", event.getAmount());
this.getEffects().setValue("sourceId", event.getSourceId());
if (affectsDefendingPlayer) {
this.getEffects().setTargetPointer(new FixedTarget(event.getTargetId()));
} else {
switch(setTargetPointer) {
case PLAYER:
this.getEffects().setTargetPointer(new FixedTarget(permanent.getControllerId()));
break;
case PERMANENT:
this.getEffects().setTargetPointer(new FixedTarget(permanent, game));
break;
}
}
return true;
}
use of mage.game.events.DamagedPlayerEvent in project mage by magefree.
the class DealsDamageToAPlayerAttachedTriggeredAbility method checkTrigger.
@Override
public boolean checkTrigger(GameEvent event, Game game) {
if (targetController == TargetController.OPPONENT) {
Player controller = game.getPlayer(this.getControllerId());
if (controller == null || !game.isOpponent(controller, event.getPlayerId())) {
return false;
}
}
if (targetController == TargetController.YOU) {
if (!this.isControlledBy(event.getPlayerId())) {
return false;
}
}
DamagedPlayerEvent damageEvent = (DamagedPlayerEvent) event;
Permanent p = game.getPermanent(event.getSourceId());
if ((onlyCombat && !damageEvent.isCombatDamage()) || p == null || !p.getAttachments().contains(this.getSourceId())) {
return false;
}
getEffects().setValue("damage", event.getAmount());
if (setFixedTargetPointer) {
getEffects().setTargetPointer(new FixedTarget(event.getPlayerId()));
}
return true;
}
use of mage.game.events.DamagedPlayerEvent in project mage by magefree.
the class HixusPrisonWardenExileEffect method checkTrigger.
@Override
public boolean checkTrigger(GameEvent event, Game game) {
DamagedPlayerEvent damageEvent = (DamagedPlayerEvent) event;
Permanent sourcePermanent = game.getPermanent(event.getSourceId());
if (damageEvent.getPlayerId().equals(getControllerId()) && damageEvent.isCombatDamage() && sourcePermanent != null && sourcePermanent.isCreature(game)) {
getEffects().get(0).setTargetPointer(new FixedTarget(event.getSourceId(), game));
return true;
}
return false;
}
use of mage.game.events.DamagedPlayerEvent in project mage by magefree.
the class RaidersSpoilsTriggeredAbility method checkTrigger.
@Override
public boolean checkTrigger(GameEvent event, Game game) {
DamagedPlayerEvent damageEvent = (DamagedPlayerEvent) event;
Permanent permanent = game.getPermanent(event.getSourceId());
if (damageEvent.isCombatDamage() && permanent != null && permanent.hasSubtype(SubType.WARRIOR, game) && permanent.isControlledBy(controllerId)) {
return true;
}
return false;
}
use of mage.game.events.DamagedPlayerEvent in project mage by magefree.
the class StrixhavenStadiumEffect method checkTrigger.
@Override
public boolean checkTrigger(GameEvent event, Game game) {
DamagedPlayerEvent damageEvent = (DamagedPlayerEvent) event;
Permanent sourcePermanent = game.getPermanent(event.getSourceId());
return isControlledBy(damageEvent.getTargetId()) && damageEvent.isCombatDamage() && sourcePermanent != null && sourcePermanent.isCreature(game);
}
Aggregations