use of mage.game.events.DamagedPlayerEvent in project mage by magefree.
the class SakikoMotherOfSummerTriggeredAbility method checkTrigger.
@Override
public boolean checkTrigger(GameEvent event, Game game) {
if (((DamagedPlayerEvent) event).isCombatDamage()) {
Permanent creature = game.getPermanent(event.getSourceId());
if (creature != null && creature.isControlledBy(controllerId)) {
this.getEffects().clear();
Effect effect = new AddManaToManaPoolTargetControllerEffect(Mana.GreenMana(event.getAmount()), "that player", true);
effect.setTargetPointer(new FixedTarget(creature.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.DamagedPlayerEvent in project mage by magefree.
the class SeshiroTheAnointedAbility method checkTrigger.
@Override
public boolean checkTrigger(GameEvent event, Game game) {
DamagedPlayerEvent damageEvent = (DamagedPlayerEvent) event;
Permanent p = game.getPermanent(event.getSourceId());
if (damageEvent.isCombatDamage() && p != null && p.hasSubtype(SubType.SNAKE, game) && p.isControlledBy(controllerId)) {
return true;
}
return false;
}
use of mage.game.events.DamagedPlayerEvent in project mage by magefree.
the class SubiraTulzidiCaravannerAbility method checkTrigger.
@Override
public boolean checkTrigger(GameEvent event, Game game) {
DamagedPlayerEvent dEvent = (DamagedPlayerEvent) event;
if (!dEvent.isCombatDamage()) {
return false;
}
Permanent permanent = game.getPermanent(event.getSourceId());
return permanent != null && permanent.isControlledBy(getControllerId()) && permanent.isCreature(game) && permanent.getPower().getValue() <= 2;
}
use of mage.game.events.DamagedPlayerEvent in project mage by magefree.
the class CommanderInfoWatcher method watch.
@Override
public void watch(GameEvent event, Game game) {
if (checkCommanderDamage && event.getType() == GameEvent.EventType.DAMAGED_PLAYER && event instanceof DamagedPlayerEvent) {
if (sourceId.equals(event.getSourceId())) {
DamagedPlayerEvent damageEvent = (DamagedPlayerEvent) event;
if (damageEvent.isCombatDamage()) {
UUID playerUUID = event.getTargetId();
Integer damage = damageToPlayer.getOrDefault(playerUUID, 0);
damage += damageEvent.getAmount();
damageToPlayer.put(playerUUID, damage);
Player player = game.getPlayer(playerUUID);
MageObject commander = game.getObject(sourceId);
if (player != null && commander != null) {
if (!game.isSimulation()) {
game.informPlayers(commander.getLogName() + " did " + damage + " combat damage to " + player.getLogName() + " during the game.");
}
this.addCardInfoToCommander(game);
}
}
}
}
// Add card info to the commander
if (event.getType() == GameEvent.EventType.ZONE_CHANGE && event.getTargetId().equals(sourceId)) {
this.addCardInfoToCommander(game);
}
}
use of mage.game.events.DamagedPlayerEvent in project mage by magefree.
the class HammerOfRuinTriggeredAbility method checkTrigger.
@Override
public boolean checkTrigger(GameEvent event, Game game) {
DamagedPlayerEvent damageEvent = (DamagedPlayerEvent) event;
Permanent p = game.getPermanent(event.getSourceId());
if (damageEvent.isCombatDamage() && p != null && p.getAttachments().contains(this.getSourceId())) {
FilterPermanent filter = new FilterPermanent("Equipment that player controls");
filter.add(SubType.EQUIPMENT.getPredicate());
filter.add(new ControllerIdPredicate(event.getPlayerId()));
filter.setMessage("creature controlled by " + game.getPlayer(event.getTargetId()).getLogName());
this.getTargets().clear();
this.addTarget(new TargetPermanent(filter));
return true;
}
return false;
}
Aggregations