use of mage.game.events.DamagedEvent in project mage by magefree.
the class DealsDamageToACreatureAllTriggeredAbility method checkTrigger.
@Override
public boolean checkTrigger(GameEvent event, Game game) {
Permanent permanent = game.getPermanent(event.getTargetId());
if (permanent == null || !permanent.isCreature(game)) {
return false;
}
if (combatDamageOnly && !((DamagedEvent) event).isCombatDamage()) {
return false;
}
permanent = game.getPermanentOrLKIBattlefield(event.getSourceId());
if (!filterPermanent.match(permanent, getSourceId(), getControllerId(), game)) {
return false;
}
for (Effect effect : this.getEffects()) {
effect.setValue("damage", event.getAmount());
effect.setValue("sourceId", event.getSourceId());
switch(setTargetPointer) {
case PLAYER:
effect.setTargetPointer(new FixedTarget(permanent.getControllerId()));
break;
case PERMANENT:
effect.setTargetPointer(new FixedTarget(permanent, game));
break;
case PERMANENT_TARGET:
Permanent permanent_target = game.getPermanentOrLKIBattlefield(event.getTargetId());
if (permanent_target != null) {
effect.setTargetPointer(new FixedTarget(permanent_target, game));
}
break;
}
}
return true;
}
use of mage.game.events.DamagedEvent in project mage by magefree.
the class HordewingSkaabTriggeredAbility method checkTrigger.
@Override
public boolean checkTrigger(GameEvent event, Game game) {
DamagedPlayerBatchEvent dEvent = (DamagedPlayerBatchEvent) event;
Set<UUID> opponents = new HashSet<>();
for (DamagedEvent damagedEvent : dEvent.getEvents()) {
if (!damagedEvent.isCombatDamage()) {
continue;
}
Permanent permanent = game.getPermanent(damagedEvent.getSourceId());
if (permanent == null || !permanent.isControlledBy(getControllerId()) || !permanent.hasSubtype(SubType.ZOMBIE, game) || !game.getOpponents(getControllerId()).contains(damagedEvent.getTargetId())) {
continue;
}
opponents.add(damagedEvent.getTargetId());
}
if (opponents.size() < 1) {
return false;
}
this.getEffects().clear();
this.addEffect(new DrawDiscardControllerEffect(opponents.size(), opponents.size()));
return true;
}
use of mage.game.events.DamagedEvent in project mage by magefree.
the class ToralfsHammerEffect method checkTrigger.
@Override
public boolean checkTrigger(GameEvent event, Game game) {
DamagedEvent dEvent = (DamagedEvent) event;
if (dEvent.getExcess() < 1 || dEvent.isCombatDamage() || !game.getOpponents(getControllerId()).contains(game.getControllerId(event.getTargetId()))) {
return false;
}
this.getEffects().clear();
this.getTargets().clear();
this.addEffect(new DamageTargetEffect(dEvent.getExcess()));
FilterCreaturePlayerOrPlaneswalker filter = new FilterCreaturePlayerOrPlaneswalker();
filter.getPermanentFilter().add(Predicates.not(new MageObjectReferencePredicate(new MageObjectReference(event.getTargetId(), game))));
this.addTarget(new TargetAnyTarget(filter));
return true;
}
use of mage.game.events.DamagedEvent in project mage by magefree.
the class BlindZealotTriggeredAbility method checkTrigger.
@Override
public boolean checkTrigger(GameEvent event, Game game) {
Player opponent = game.getPlayer(event.getPlayerId());
if (opponent == null || !event.getSourceId().equals(this.sourceId) || !((DamagedEvent) event).isCombatDamage()) {
return false;
}
FilterCreaturePermanent filter = new FilterCreaturePermanent("creature " + opponent.getLogName() + " controls");
filter.add(new ControllerIdPredicate(opponent.getId()));
this.getTargets().clear();
this.addTarget(new TargetCreaturePermanent(filter));
return true;
}
use of mage.game.events.DamagedEvent in project mage by magefree.
the class CurseOfHospitalityEffect method checkTrigger.
@Override
public boolean checkTrigger(GameEvent event, Game game) {
DamagedEvent dEvent = (DamagedEvent) event;
Permanent permanent = getSourcePermanentIfItStillExists(game);
if (!dEvent.isCombatDamage() || permanent == null || !dEvent.getPlayerId().equals(permanent.getAttachedTo())) {
return false;
}
this.getEffects().setTargetPointer(new FixedTarget(game.getControllerId(dEvent.getSourceId())));
return true;
}
Aggregations