use of mage.game.events.DamagedPlayerEvent in project mage by magefree.
the class AnowonTheRuinThiefWatcher method watch.
@Override
public void watch(GameEvent event, Game game) {
if (event.getType() == GameEvent.EventType.COMBAT_DAMAGE_STEP_POST) {
damageMap.clear();
return;
}
if (event.getType() != GameEvent.EventType.DAMAGED_PLAYER || !((DamagedPlayerEvent) event).isCombatDamage()) {
return;
}
Permanent creature = game.getPermanent(event.getSourceId());
if (creature == null || !creature.hasSubtype(SubType.ROGUE, game)) {
return;
}
damageMap.computeIfAbsent(event.getTargetId(), x -> new HashMap<>()).compute(creature.getControllerId(), (uuid, i) -> i == null ? event.getAmount() : event.getAmount() + i);
}
use of mage.game.events.DamagedPlayerEvent in project mage by magefree.
the class AshlingTheExtinguisherTriggeredAbility 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 HarshJusticeEffect method checkTrigger.
@Override
public boolean checkTrigger(GameEvent event, Game game) {
Player controller = game.getPlayer(this.getControllerId());
DamagedPlayerEvent damageEvent = (DamagedPlayerEvent) event;
Permanent damagePermanent = game.getPermanentOrLKIBattlefield(damageEvent.getSourceId());
if (controller != null && damagePermanent != null) {
if (damageEvent.isCombatDamage() && controller.getId().equals(damageEvent.getTargetId()) && filter.match(damagePermanent, game)) {
for (Effect effect : this.getEffects()) {
effect.setValue("damage", damageEvent.getAmount());
effect.setValue("sourceId", damageEvent.getSourceId());
}
return true;
}
}
return false;
}
use of mage.game.events.DamagedPlayerEvent in project mage by magefree.
the class WrexialReplacementEffect 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("target instant or sorcery card from " + damagedPlayer.getName() + "'s graveyard");
filter.add(new OwnerIdPredicate(damagedPlayer.getId()));
filter.add(Predicates.or(CardType.INSTANT.getPredicate(), CardType.SORCERY.getPredicate()));
Target 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 BloodforgedBattleAxeAbility 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());
}
Aggregations