use of mage.game.events.DamagedEvent in project mage by magefree.
the class HuntersInsightTriggeredAbility method checkTrigger.
@Override
public boolean checkTrigger(GameEvent event, Game game) {
if (!mor.refersTo(event.getSourceId(), game) || !((DamagedEvent) event).isCombatDamage()) {
return false;
}
Permanent permanent = game.getPermanent(event.getTargetId());
if (permanent != null && !permanent.isPlaneswalker(game)) {
return false;
}
this.getEffects().clear();
this.addEffect(new DrawCardSourceControllerEffect(event.getAmount()));
return true;
}
use of mage.game.events.DamagedEvent in project mage by magefree.
the class MarkOfSakikoTriggeredAbility method checkTrigger.
@Override
public boolean checkTrigger(GameEvent event, Game game) {
if (((DamagedEvent) event).isCombatDamage()) {
if (event.getSourceId().equals(getSourceId())) {
this.getEffects().clear();
Effect effect = new AddManaToManaPoolTargetControllerEffect(Mana.GreenMana(event.getAmount()), "that player", true);
effect.setTargetPointer(new FixedTarget(getControllerId()));
effect.setText("add that much {G}. Until end of turn, you don't lose this mana as steps and phases end");
this.addEffect(effect);
return true;
}
}
return false;
}
use of mage.game.events.DamagedEvent in project mage by magefree.
the class AegarTheFreezingFlameWatcher method watch.
@Override
public void watch(GameEvent event, Game game) {
if (event.getType() != GameEvent.EventType.DAMAGED_PERMANENT) {
return;
}
DamagedEvent dEvent = (DamagedEvent) event;
MageObject sourceObject = game.getObject(event.getSourceId());
if (sourceObject == null) {
return;
}
if (game.getSpellOrLKIStack(event.getSourceId()) == null && !sourceObject.hasSubtype(SubType.GIANT, game) && !sourceObject.hasSubtype(SubType.WIZARD, game)) {
return;
}
playerMap.computeIfAbsent(game.getControllerId(event.getSourceId()), x -> new HashSet<>()).add(new MageObjectReference(event.getTargetId(), game));
}
use of mage.game.events.DamagedEvent in project mage by magefree.
the class BladegriffPrototypeAbility method checkTrigger.
@Override
public boolean checkTrigger(GameEvent event, Game game) {
Player player = game.getPlayer(getControllerId());
if (player == null || !event.getSourceId().equals(this.sourceId) || !((DamagedEvent) event).isCombatDamage()) {
return false;
}
FilterPermanent filter = new FilterNonlandPermanent("nonland permanent controlled by an opponent of " + player.getName());
filter.add(Predicates.or(game.getOpponents(getControllerId()).stream().map(ControllerIdPredicate::new).collect(Collectors.toSet())));
TargetPermanent target = new TargetPermanent(filter);
target.setTargetController(event.getPlayerId());
this.getTargets().clear();
this.addTarget(target);
return true;
}
use of mage.game.events.DamagedEvent in project mage by magefree.
the class MalcolmKeenEyedNavigatorTriggeredAbility method checkTrigger.
@Override
public boolean checkTrigger(GameEvent event, Game game) {
DamagedPlayerBatchEvent dEvent = (DamagedPlayerBatchEvent) event;
Set<UUID> opponents = new HashSet<>();
for (DamagedEvent damagedEvent : dEvent.getEvents()) {
Permanent permanent = game.getPermanent(damagedEvent.getSourceId());
if (permanent == null || !permanent.isControlledBy(getControllerId()) || !permanent.hasSubtype(SubType.PIRATE, game) || !game.getOpponents(getControllerId()).contains(damagedEvent.getTargetId())) {
continue;
}
opponents.add(damagedEvent.getTargetId());
}
if (opponents.size() < 1) {
return false;
}
this.getEffects().clear();
this.addEffect(new CreateTokenEffect(new TreasureToken(), opponents.size()));
return true;
}
Aggregations