use of mage.game.events.DamagedPlayerEvent in project mage by magefree.
the class ProwlWatcher method watch.
@Override
public void watch(GameEvent event, Game game) {
if (event.getType() != EventType.DAMAGED_PLAYER) {
return;
}
DamagedPlayerEvent dEvent = (DamagedPlayerEvent) event;
if (!dEvent.isCombatDamage()) {
return;
}
Permanent creature = game.getPermanent(dEvent.getSourceId());
if (creature == null || allSubtypes.contains(creature.getControllerId())) {
return;
}
if (creature.isAllCreatureTypes(game)) {
allSubtypes.add(creature.getControllerId());
return;
}
damagingSubtypes.computeIfAbsent(creature.getControllerId(), m -> new LinkedHashSet<>()).addAll(creature.getSubtype(game));
}
use of mage.game.events.DamagedPlayerEvent in project mage by magefree.
the class PollenbrightWingsEffect method checkTrigger.
@Override
public boolean checkTrigger(GameEvent event, Game game) {
DamagedPlayerEvent damageEvent = (DamagedPlayerEvent) event;
Permanent damageSource = game.getPermanent(event.getSourceId());
if (damageEvent.isCombatDamage() && damageSource != null && damageSource.getAttachments().contains(this.getSourceId())) {
game.getState().setValue("Damage_" + getSourceId(), damageEvent.getAmount());
return true;
}
return false;
}
use of mage.game.events.DamagedPlayerEvent in project mage by magefree.
the class ScionOfDarknessTriggeredAbility method checkTrigger.
@Override
public boolean checkTrigger(GameEvent event, Game game) {
if (!event.getSourceId().equals(this.sourceId) || !((DamagedPlayerEvent) event).isCombatDamage()) {
return false;
}
Player damagedPlayer = game.getPlayer(event.getTargetId());
if (damagedPlayer == null) {
return false;
}
FilterCard filter = new FilterCard("creature in " + damagedPlayer.getName() + "'s graveyard");
filter.add(CardType.CREATURE.getPredicate());
filter.add(new OwnerIdPredicate(damagedPlayer.getId()));
TargetCardInGraveyard target = new TargetCardInGraveyard(filter);
this.getTargets().clear();
this.addTarget(target);
return true;
}
use of mage.game.events.DamagedPlayerEvent in project mage by magefree.
the class SparkMageTriggeredAbility 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.getTargets().add(new TargetCreaturePermanent(filter));
return true;
}
}
return false;
}
use of mage.game.events.DamagedPlayerEvent in project mage by magefree.
the class ZombieCannibalTriggeredAbility method checkTrigger.
@Override
public boolean checkTrigger(GameEvent event, Game game) {
if (!event.getSourceId().equals(this.sourceId) || !((DamagedPlayerEvent) event).isCombatDamage()) {
return false;
}
Player damagedPlayer = game.getPlayer(event.getTargetId());
if (damagedPlayer == null) {
return false;
}
FilterCard filter = new FilterCard("card in " + damagedPlayer.getName() + "'s graveyard");
filter.add(new OwnerIdPredicate(damagedPlayer.getId()));
TargetCardInGraveyard target = new TargetCardInGraveyard(filter);
this.getTargets().clear();
this.addTarget(target);
return true;
}
Aggregations