use of mage.game.events.DamagedEvent in project mage by magefree.
the class FiendlashEffect method checkTrigger.
@Override
public boolean checkTrigger(GameEvent event, Game game) {
Permanent equipment = game.getPermanent(this.getSourceId());
if (equipment == null) {
return false;
}
UUID attachedCreature = equipment.getAttachedTo();
if (attachedCreature == null) {
return false;
}
game.getState().setValue("Fiendlash" + equipment.getId(), attachedCreature);
DamagedPermanentBatchEvent dEvent = (DamagedPermanentBatchEvent) event;
for (DamagedEvent damagedEvent : dEvent.getEvents()) {
UUID targetID = damagedEvent.getTargetId();
if (targetID == null) {
continue;
}
if (targetID == attachedCreature) {
return true;
}
}
return false;
}
use of mage.game.events.DamagedEvent in project mage by magefree.
the class GlyphOfLifeGainLifeEffect method checkTrigger.
@Override
public boolean checkTrigger(GameEvent event, Game game) {
if (event.getTargetId().equals(this.getFirstTarget())) {
DamagedEvent damageEvent = (DamagedEvent) event;
Permanent attackingCreature = game.getPermanentOrLKIBattlefield(damageEvent.getSourceId());
if (attackingCreature != null && attackingCreature.isCreature(game) && attackingCreature.isAttacking()) {
this.getEffects().get(0).setValue("damageAmount", event.getAmount());
return true;
}
}
return false;
}
use of mage.game.events.DamagedEvent in project mage by magefree.
the class ZarethSanTheTricksterTriggeredAbility 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;
}
FilterCard filter = new FilterPermanentCard("permanent card in " + opponent.getLogName() + "'s graveyard");
filter.add(new OwnerIdPredicate(opponent.getId()));
this.getTargets().clear();
this.addTarget(new TargetCardInGraveyard(filter));
return true;
}
use of mage.game.events.DamagedEvent in project mage by magefree.
the class CombatDamageToCreatureWatcher method watch.
@Override
public void watch(GameEvent event, Game game) {
if (event.getType() != GameEvent.EventType.DAMAGED_PERMANENT || !((DamagedEvent) event).isCombatDamage()) {
return;
}
Permanent permanent = game.getPermanent(event.getTargetId());
if (permanent == null || !permanent.isCreature(game)) {
return;
}
MageObjectReference damageSource = new MageObjectReference(event.getSourceId(), game);
dealtCombatDamageToCreature.add(damageSource);
}
use of mage.game.events.DamagedEvent in project mage by magefree.
the class DealsCombatDamageToAPlayerTriggeredAbility method checkTrigger.
@Override
public boolean checkTrigger(GameEvent event, Game game) {
if (!event.getSourceId().equals(getSourceId()) || !((DamagedEvent) event).isCombatDamage()) {
return false;
}
switch(event.getType()) {
case DAMAGED_PLAYER:
if (onlyOpponents && !game.getOpponents(getControllerId()).contains(event.getTargetId())) {
return false;
}
break;
case DAMAGED_PERMANENT:
Permanent permanent = game.getPermanent(event.getTargetId());
if (permanent == null || !permanent.isPlaneswalker(game) || !orPlaneswalker) {
return false;
}
}
if (setTargetPointer) {
getAllEffects().setTargetPointer(new FixedTarget(event.getPlayerId()));
getAllEffects().setValue("damage", event.getAmount());
}
return true;
}
Aggregations