diff --git a/Mage.Sets/src/mage/cards/a/AegarTheFreezingFlame.java b/Mage.Sets/src/mage/cards/a/AegarTheFreezingFlame.java index 7cb7b5feb7..8a321b2b29 100644 --- a/Mage.Sets/src/mage/cards/a/AegarTheFreezingFlame.java +++ b/Mage.Sets/src/mage/cards/a/AegarTheFreezingFlame.java @@ -56,12 +56,7 @@ class AegarTheFreezingFlameTriggeredAbility extends TriggeredAbilityImpl { @Override public boolean checkEventType(GameEvent event, Game game) { - switch (event.getType()) { - case DAMAGED_CREATURE: - case DAMAGED_PLANESWALKER: - return true; - } - return false; + return event.getType() == GameEvent.EventType.DAMAGED_PERMANENT; } @Override @@ -98,12 +93,8 @@ class AegarTheFreezingFlameWatcher extends Watcher { @Override public void watch(GameEvent event, Game game) { - switch (event.getType()) { - case DAMAGED_CREATURE: - case DAMAGED_PLANESWALKER: - break; - default: - return; + if (event.getType() != GameEvent.EventType.DAMAGED_PERMANENT) { + return; } DamagedEvent dEvent = (DamagedEvent) event; MageObject sourceObject = game.getObject(event.getSourceId()); diff --git a/Mage.Sets/src/mage/cards/a/AngelOfDeliverance.java b/Mage.Sets/src/mage/cards/a/AngelOfDeliverance.java index eaffb945ed..db59364eb9 100644 --- a/Mage.Sets/src/mage/cards/a/AngelOfDeliverance.java +++ b/Mage.Sets/src/mage/cards/a/AngelOfDeliverance.java @@ -83,8 +83,7 @@ class AngelOfDeliveranceDealsDamageTriggeredAbility extends TriggeredAbilityImpl @Override public boolean checkEventType(GameEvent event, Game game) { return event.getType() == GameEvent.EventType.DAMAGED_PLAYER - || event.getType() == GameEvent.EventType.DAMAGED_CREATURE - || event.getType() == GameEvent.EventType.DAMAGED_PLANESWALKER; + || event.getType() == GameEvent.EventType.DAMAGED_PERMANENT; } @Override diff --git a/Mage.Sets/src/mage/cards/a/AngrathsMarauders.java b/Mage.Sets/src/mage/cards/a/AngrathsMarauders.java index 7886fec8fb..31dc9eb06c 100644 --- a/Mage.Sets/src/mage/cards/a/AngrathsMarauders.java +++ b/Mage.Sets/src/mage/cards/a/AngrathsMarauders.java @@ -64,8 +64,7 @@ class AngrathsMaraudersEffect extends ReplacementEffectImpl { @Override public boolean checksEventType(GameEvent event, Game game) { return event.getType().equals(EventType.DAMAGE_PLAYER) - || event.getType().equals(EventType.DAMAGE_CREATURE) - || event.getType().equals(EventType.DAMAGE_PLANESWALKER); + || event.getType().equals(EventType.DAMAGE_PERMANENT); } @Override diff --git a/Mage.Sets/src/mage/cards/a/AnthemOfRakdos.java b/Mage.Sets/src/mage/cards/a/AnthemOfRakdos.java index 432cce2578..5dfc125633 100644 --- a/Mage.Sets/src/mage/cards/a/AnthemOfRakdos.java +++ b/Mage.Sets/src/mage/cards/a/AnthemOfRakdos.java @@ -69,9 +69,8 @@ class AnthemOfRakdosHellbentEffect extends ReplacementEffectImpl { @Override public boolean checksEventType(GameEvent event, Game game) { - return event.getType() == GameEvent.EventType.DAMAGE_CREATURE - || event.getType() == GameEvent.EventType.DAMAGE_PLAYER - || event.getType() == GameEvent.EventType.DAMAGE_PLANESWALKER; + return event.getType() == GameEvent.EventType.DAMAGE_PERMANENT + || event.getType() == GameEvent.EventType.DAMAGE_PLAYER; } @Override diff --git a/Mage.Sets/src/mage/cards/a/ArashinWarBeast.java b/Mage.Sets/src/mage/cards/a/ArashinWarBeast.java index 0c7f52fbb4..5d41985e6e 100644 --- a/Mage.Sets/src/mage/cards/a/ArashinWarBeast.java +++ b/Mage.Sets/src/mage/cards/a/ArashinWarBeast.java @@ -14,9 +14,8 @@ import mage.constants.Zone; import mage.filter.common.FilterCreaturePermanent; import mage.filter.predicate.permanent.BlockingPredicate; import mage.game.Game; -import mage.game.events.DamagedCreatureEvent; +import mage.game.events.DamagedEvent; import mage.game.events.GameEvent; -import mage.game.events.GameEvent.EventType; import mage.game.permanent.Permanent; /** @@ -73,14 +72,14 @@ class ArashinWarBeastTriggeredAbility extends TriggeredAbilityImpl { @Override public boolean checkEventType(GameEvent event, Game game) { - return event.getType() == GameEvent.EventType.DAMAGED_CREATURE || event.getType() == GameEvent.EventType.COMBAT_DAMAGE_STEP_POST ; + return event.getType() == GameEvent.EventType.DAMAGED_PERMANENT || event.getType() == GameEvent.EventType.COMBAT_DAMAGE_STEP_POST ; } @Override public boolean checkTrigger(GameEvent event, Game game) { - if (event.getType() == GameEvent.EventType.DAMAGED_CREATURE && + if (event.getType() == GameEvent.EventType.DAMAGED_PERMANENT && event.getSourceId().equals(this.sourceId) && - ((DamagedCreatureEvent) event).isCombatDamage() && + ((DamagedEvent) event).isCombatDamage() && !usedForCombatDamageStep) { Permanent creature = game.getPermanentOrLKIBattlefield(event.getTargetId()); if (creature == null || !filter.match(creature, getSourceId(), getControllerId(), game)) { diff --git a/Mage.Sets/src/mage/cards/a/Arcbond.java b/Mage.Sets/src/mage/cards/a/Arcbond.java index 65a0487f7c..23a888afdd 100644 --- a/Mage.Sets/src/mage/cards/a/Arcbond.java +++ b/Mage.Sets/src/mage/cards/a/Arcbond.java @@ -85,7 +85,7 @@ class ArcbondDelayedTriggeredAbility extends DelayedTriggeredAbility { @Override public boolean checkEventType(GameEvent event, Game game) { - return event.getType() == GameEvent.EventType.DAMAGED_CREATURE; + return event.getType() == GameEvent.EventType.DAMAGED_PERMANENT; } @Override diff --git a/Mage.Sets/src/mage/cards/a/ArchfiendOfSpite.java b/Mage.Sets/src/mage/cards/a/ArchfiendOfSpite.java index 740aa5c673..a25c3ab7d0 100644 --- a/Mage.Sets/src/mage/cards/a/ArchfiendOfSpite.java +++ b/Mage.Sets/src/mage/cards/a/ArchfiendOfSpite.java @@ -73,7 +73,7 @@ class ArchfiendOfSpiteAbility extends TriggeredAbilityImpl { @Override public boolean checkEventType(GameEvent event, Game game) { - return event.getType() == GameEvent.EventType.DAMAGED_CREATURE; + return event.getType() == GameEvent.EventType.DAMAGED_PERMANENT; } @Override diff --git a/Mage.Sets/src/mage/cards/a/AscentOfTheWorthy.java b/Mage.Sets/src/mage/cards/a/AscentOfTheWorthy.java index d119c7d484..46898f9818 100644 --- a/Mage.Sets/src/mage/cards/a/AscentOfTheWorthy.java +++ b/Mage.Sets/src/mage/cards/a/AscentOfTheWorthy.java @@ -128,13 +128,13 @@ class AscentOfTheWorthyRedirectEffect extends ReplacementEffectImpl { @Override public boolean checksEventType(GameEvent event, Game game) { - return event.getType() == GameEvent.EventType.DAMAGE_CREATURE; + return event.getType() == GameEvent.EventType.DAMAGE_PERMANENT; } @Override public boolean applies(GameEvent event, Ability source, Game game) { Permanent permanent = game.getPermanent(event.getTargetId()); - return permanent != null && permanent.isControlledBy(source.getControllerId()); + return permanent != null && permanent.isCreature() && permanent.isControlledBy(source.getControllerId()); } @Override diff --git a/Mage.Sets/src/mage/cards/a/AureliasFury.java b/Mage.Sets/src/mage/cards/a/AureliasFury.java index 5d54846142..c487c51c03 100644 --- a/Mage.Sets/src/mage/cards/a/AureliasFury.java +++ b/Mage.Sets/src/mage/cards/a/AureliasFury.java @@ -18,7 +18,6 @@ import mage.constants.Outcome; import mage.constants.WatcherScope; import mage.game.Game; import mage.game.events.GameEvent; -import mage.game.events.GameEvent.EventType; import mage.game.permanent.Permanent; import mage.game.stack.Spell; import mage.players.Player; @@ -177,21 +176,19 @@ class AureliasFuryDamagedByWatcher extends Watcher { @Override public void watch(GameEvent event, Game game) { - if (event.getType() == GameEvent.EventType.DAMAGED_CREATURE) { - MageObject obj = game.getObject(event.getSourceId()); - if (obj instanceof Spell) { - if (sourceId.equals(((Spell) obj).getSourceId())) { + MageObject obj = game.getObject(event.getSourceId()); + if (!(obj instanceof Spell) || !sourceId.equals(((Spell) obj).getSourceId())) { + return; + } + switch (event.getType()) { + case DAMAGED_PERMANENT: + Permanent permanent = game.getPermanent(event.getTargetId()); + if (permanent != null && permanent.isCreature()) { damagedCreatures.add(event.getTargetId()); } - } - } - if (event.getType() == GameEvent.EventType.DAMAGED_PLAYER) { - MageObject obj = game.getObject(event.getSourceId()); - if (obj instanceof Spell) { - if (sourceId.equals(((Spell) obj).getSourceId())) { - damagedPlayers.add(event.getTargetId()); - } - } + return; + case DAMAGED_PLAYER: + damagedPlayers.add(event.getTargetId()); } } diff --git a/Mage.Sets/src/mage/cards/a/AvacynGuardianAngel.java b/Mage.Sets/src/mage/cards/a/AvacynGuardianAngel.java index 9304d9a3d1..5a21352b8c 100644 --- a/Mage.Sets/src/mage/cards/a/AvacynGuardianAngel.java +++ b/Mage.Sets/src/mage/cards/a/AvacynGuardianAngel.java @@ -1,7 +1,5 @@ - package mage.cards.a; -import java.util.UUID; import mage.MageInt; import mage.MageObject; import mage.ObjectColor; @@ -24,8 +22,9 @@ import mage.players.Player; import mage.target.common.TargetCreaturePermanent; import mage.target.common.TargetPlayerOrPlaneswalker; +import java.util.UUID; + /** - * * @author LevelX2 */ public final class AvacynGuardianAngel extends CardImpl { @@ -80,7 +79,7 @@ class AvacynGuardianAngelPreventToCreatureEffect extends OneShotEffect { this.staticText = "Prevent all damage that would be dealt to another target creature this turn by sources of the color of your choice"; } - AvacynGuardianAngelPreventToCreatureEffect(final AvacynGuardianAngelPreventToCreatureEffect effect) { + private AvacynGuardianAngelPreventToCreatureEffect(final AvacynGuardianAngelPreventToCreatureEffect effect) { super(effect); } @@ -112,7 +111,7 @@ class AvacynGuardianAngelPreventToCreaturePreventionEffect extends PreventionEff this.color = color; } - AvacynGuardianAngelPreventToCreaturePreventionEffect(AvacynGuardianAngelPreventToCreaturePreventionEffect effect) { + private AvacynGuardianAngelPreventToCreaturePreventionEffect(AvacynGuardianAngelPreventToCreaturePreventionEffect effect) { super(effect); this.color = effect.color; } @@ -124,16 +123,13 @@ class AvacynGuardianAngelPreventToCreaturePreventionEffect extends PreventionEff @Override public boolean applies(GameEvent event, Ability source, Game game) { - if (super.applies(event, source, game)) { - if (event.getType() == GameEvent.EventType.DAMAGE_CREATURE - && event.getTargetId().equals(getTargetPointer().getFirst(game, source))) { - MageObject sourceObject = game.getObject(event.getSourceId()); - if (sourceObject != null && sourceObject.getColor(game).shares(this.color)) { - return true; - } - } + if (!super.applies(event, source, game) + || event.getType() != GameEvent.EventType.DAMAGE_PERMANENT + || !event.getTargetId().equals(getTargetPointer().getFirst(game, source))) { + return false; } - return false; + MageObject sourceObject = game.getObject(event.getSourceId()); + return sourceObject != null && sourceObject.getColor(game).shares(this.color); } @Override @@ -149,7 +145,7 @@ class AvacynGuardianAngelPreventToPlayerEffect extends OneShotEffect { this.staticText = "Prevent all damage that would be dealt to target player or planeswalker this turn by sources of the color of your choice"; } - AvacynGuardianAngelPreventToPlayerEffect(final AvacynGuardianAngelPreventToPlayerEffect effect) { + private AvacynGuardianAngelPreventToPlayerEffect(final AvacynGuardianAngelPreventToPlayerEffect effect) { super(effect); } @@ -181,7 +177,7 @@ class AvacynGuardianAngelPreventToPlayerPreventionEffect extends PreventionEffec this.color = color; } - AvacynGuardianAngelPreventToPlayerPreventionEffect(AvacynGuardianAngelPreventToPlayerPreventionEffect effect) { + private AvacynGuardianAngelPreventToPlayerPreventionEffect(AvacynGuardianAngelPreventToPlayerPreventionEffect effect) { super(effect); this.color = effect.color; } @@ -193,17 +189,11 @@ class AvacynGuardianAngelPreventToPlayerPreventionEffect extends PreventionEffec @Override public boolean applies(GameEvent event, Ability source, Game game) { - if (super.applies(event, source, game)) { - if ((event.getType() == GameEvent.EventType.DAMAGE_PLAYER - || event.getType() == GameEvent.EventType.DAMAGED_PLANESWALKER) - && event.getTargetId().equals(getTargetPointer().getFirst(game, source))) { - MageObject sourceObject = game.getObject(event.getSourceId()); - if (sourceObject != null && sourceObject.getColor(game).shares(this.color)) { - return true; - } - } + if (!super.applies(event, source, game) || !event.getTargetId().equals(getTargetPointer().getFirst(game, source))) { + return false; } - return false; + MageObject sourceObject = game.getObject(event.getSourceId()); + return sourceObject != null && sourceObject.getColor(game).shares(this.color); } @Override diff --git a/Mage.Sets/src/mage/cards/b/BansheesBlade.java b/Mage.Sets/src/mage/cards/b/BansheesBlade.java index d79d33870c..0e6a9715ac 100644 --- a/Mage.Sets/src/mage/cards/b/BansheesBlade.java +++ b/Mage.Sets/src/mage/cards/b/BansheesBlade.java @@ -73,8 +73,7 @@ class BansheesBladeAbility extends TriggeredAbilityImpl { @Override public boolean checkEventType(GameEvent event, Game game) { return event.getType() == GameEvent.EventType.DAMAGED_PLAYER - || event.getType() == GameEvent.EventType.DAMAGED_CREATURE - || event.getType() == GameEvent.EventType.DAMAGED_PLANESWALKER + || event.getType() == GameEvent.EventType.DAMAGED_PERMANENT || event.getType() == GameEvent.EventType.COMBAT_DAMAGE_STEP_PRE; } diff --git a/Mage.Sets/src/mage/cards/b/BelltowerSphinx.java b/Mage.Sets/src/mage/cards/b/BelltowerSphinx.java index 5bb674324e..9ddda1a02a 100644 --- a/Mage.Sets/src/mage/cards/b/BelltowerSphinx.java +++ b/Mage.Sets/src/mage/cards/b/BelltowerSphinx.java @@ -64,7 +64,7 @@ class BelltowerSphinxEffect extends TriggeredAbilityImpl { @Override public boolean checkEventType(GameEvent event, Game game) { - return event.getType() == GameEvent.EventType.DAMAGED_CREATURE; + return event.getType() == GameEvent.EventType.DAMAGED_PERMANENT; } @Override diff --git a/Mage.Sets/src/mage/cards/b/BenevolentUnicorn.java b/Mage.Sets/src/mage/cards/b/BenevolentUnicorn.java index 3c733774da..1798996ccb 100644 --- a/Mage.Sets/src/mage/cards/b/BenevolentUnicorn.java +++ b/Mage.Sets/src/mage/cards/b/BenevolentUnicorn.java @@ -76,7 +76,8 @@ class BenevolentUnicornEffect extends ReplacementEffectImpl { @Override public boolean checksEventType(GameEvent event, Game game) { - return event.getType() == GameEvent.EventType.DAMAGE_CREATURE || event.getType() == GameEvent.EventType.DAMAGE_PLANESWALKER || event.getType() == GameEvent.EventType.DAMAGE_PLAYER; + return event.getType() == EventType.DAMAGE_PERMANENT + || event.getType() == GameEvent.EventType.DAMAGE_PLAYER; } @Override diff --git a/Mage.Sets/src/mage/cards/b/BitterFeud.java b/Mage.Sets/src/mage/cards/b/BitterFeud.java index b8d0d2be72..8ad9ab2694 100644 --- a/Mage.Sets/src/mage/cards/b/BitterFeud.java +++ b/Mage.Sets/src/mage/cards/b/BitterFeud.java @@ -111,9 +111,8 @@ class BitterFeudEffect extends ReplacementEffectImpl { @Override public boolean checksEventType(GameEvent event, Game game) { switch (event.getType()) { - case DAMAGE_CREATURE: + case DAMAGE_PERMANENT: case DAMAGE_PLAYER: - case DAMAGE_PLANESWALKER: return true; default: return false; @@ -130,8 +129,7 @@ class BitterFeudEffect extends ReplacementEffectImpl { case DAMAGE_PLAYER: targetPlayerId = event.getTargetId(); break; - case DAMAGE_CREATURE: - case DAMAGE_PLANESWALKER: + case DAMAGE_PERMANENT: Permanent permanent = game.getPermanent(event.getTargetId()); if (permanent != null) { targetPlayerId = permanent.getControllerId(); diff --git a/Mage.Sets/src/mage/cards/b/BlazeCommando.java b/Mage.Sets/src/mage/cards/b/BlazeCommando.java index c3ba82d68f..df36371ba1 100644 --- a/Mage.Sets/src/mage/cards/b/BlazeCommando.java +++ b/Mage.Sets/src/mage/cards/b/BlazeCommando.java @@ -84,7 +84,8 @@ class BlazeCommandoTriggeredAbility extends TriggeredAbilityImpl { @Override public boolean checkEventType(GameEvent event, Game game) { - return event.getType() == GameEvent.EventType.DAMAGED_CREATURE || event.getType() == GameEvent.EventType.DAMAGED_PLANESWALKER || event.getType() == GameEvent.EventType.DAMAGED_PLAYER; + return event.getType() == GameEvent.EventType.DAMAGED_PERMANENT + || event.getType() == GameEvent.EventType.DAMAGED_PLAYER; } @Override diff --git a/Mage.Sets/src/mage/cards/b/BlazingEffigy.java b/Mage.Sets/src/mage/cards/b/BlazingEffigy.java index a25fd23543..68c7af9496 100644 --- a/Mage.Sets/src/mage/cards/b/BlazingEffigy.java +++ b/Mage.Sets/src/mage/cards/b/BlazingEffigy.java @@ -89,7 +89,7 @@ class BlazingEffigyWatcher extends Watcher { @Override public void watch(GameEvent event, Game game) { - if (event.getType() == GameEvent.EventType.DAMAGED_CREATURE) { + if (event.getType() == GameEvent.EventType.DAMAGED_PERMANENT) { if (!event.getSourceId().equals(event.getTargetId())) { MageObjectReference damageSourceRef = new MageObjectReference(event.getSourceId(), game); MageObjectReference damageTargetRef = new MageObjectReference(event.getTargetId(), game); diff --git a/Mage.Sets/src/mage/cards/b/BlazingSunsteel.java b/Mage.Sets/src/mage/cards/b/BlazingSunsteel.java index 59e13f0628..eb9218ad7f 100644 --- a/Mage.Sets/src/mage/cards/b/BlazingSunsteel.java +++ b/Mage.Sets/src/mage/cards/b/BlazingSunsteel.java @@ -72,7 +72,7 @@ class BlazingSunsteelTriggeredAbility extends TriggeredAbilityImpl { @Override public boolean checkEventType(GameEvent event, Game game) { - return event.getType() == GameEvent.EventType.DAMAGED_CREATURE; + return event.getType() == GameEvent.EventType.DAMAGED_PERMANENT; } @Override diff --git a/Mage.Sets/src/mage/cards/b/BlindFury.java b/Mage.Sets/src/mage/cards/b/BlindFury.java index d97aae48c1..27b8597474 100644 --- a/Mage.Sets/src/mage/cards/b/BlindFury.java +++ b/Mage.Sets/src/mage/cards/b/BlindFury.java @@ -11,7 +11,7 @@ import mage.constants.Duration; import mage.constants.Outcome; import mage.filter.StaticFilters; import mage.game.Game; -import mage.game.events.DamageCreatureEvent; +import mage.game.events.DamageEvent; import mage.game.events.GameEvent; import mage.game.permanent.Permanent; import mage.util.CardUtil; @@ -63,7 +63,7 @@ class FurnaceOfRathEffect extends ReplacementEffectImpl { @Override public boolean checksEventType(GameEvent event, Game game) { - return event.getType() == GameEvent.EventType.DAMAGE_CREATURE; + return event.getType() == GameEvent.EventType.DAMAGE_PERMANENT; } @Override @@ -71,7 +71,7 @@ class FurnaceOfRathEffect extends ReplacementEffectImpl { Permanent permanent = game.getPermanent(event.getSourceId()); return permanent != null && permanent.isCreature() - && ((DamageCreatureEvent) event).isCombatDamage(); + && ((DamageEvent) event).isCombatDamage(); } diff --git a/Mage.Sets/src/mage/cards/b/BloodOfTheMartyr.java b/Mage.Sets/src/mage/cards/b/BloodOfTheMartyr.java index 11ee3bafa6..4c4c25ebd2 100644 --- a/Mage.Sets/src/mage/cards/b/BloodOfTheMartyr.java +++ b/Mage.Sets/src/mage/cards/b/BloodOfTheMartyr.java @@ -12,6 +12,7 @@ import mage.constants.Outcome; import mage.game.Game; import mage.game.events.DamageEvent; import mage.game.events.GameEvent; +import mage.game.permanent.Permanent; import mage.players.Player; /** @@ -55,7 +56,7 @@ class BloodOfTheMartyrEffect extends ReplacementEffectImpl { @Override public boolean checksEventType(GameEvent event, Game game) { - return event.getType() == GameEvent.EventType.DAMAGE_CREATURE; + return event.getType() == GameEvent.EventType.DAMAGE_PERMANENT; } @Override @@ -77,8 +78,11 @@ class BloodOfTheMartyrEffect extends ReplacementEffectImpl { @Override public boolean applies(GameEvent event, Ability source, Game game) { Player controller = game.getPlayer(source.getControllerId()); + Permanent permanent = game.getPermanent(event.getTargetId()); DamageEvent damageEvent = (DamageEvent) event; return controller != null - && controller.chooseUse(outcome, "Would you like to have " + damageEvent.getAmount() + " damage dealt to you instead of " + game.getPermanentOrLKIBattlefield(damageEvent.getTargetId()).getLogName() + "?", source, game); + && permanent != null + && permanent.isCreature() + && controller.chooseUse(outcome, "Have " + damageEvent.getAmount() + " damage dealt to you instead of " + permanent.getLogName() + "?", source, game); } } diff --git a/Mage.Sets/src/mage/cards/c/CalamityBearer.java b/Mage.Sets/src/mage/cards/c/CalamityBearer.java index 52c5420652..f69213fdb0 100644 --- a/Mage.Sets/src/mage/cards/c/CalamityBearer.java +++ b/Mage.Sets/src/mage/cards/c/CalamityBearer.java @@ -72,8 +72,7 @@ class CalamityBearerEffect extends ReplacementEffectImpl { @Override public boolean checksEventType(GameEvent event, Game game) { switch (event.getType()) { - case DAMAGE_CREATURE: - case DAMAGE_PLANESWALKER: + case DAMAGE_PERMANENT: case DAMAGE_PLAYER: return true; default: diff --git a/Mage.Sets/src/mage/cards/c/Camel.java b/Mage.Sets/src/mage/cards/c/Camel.java index 0ceffdec36..72bd328800 100644 --- a/Mage.Sets/src/mage/cards/c/Camel.java +++ b/Mage.Sets/src/mage/cards/c/Camel.java @@ -15,8 +15,8 @@ import mage.constants.SubType; import mage.constants.Zone; import mage.filter.FilterPermanent; import mage.game.Game; +import mage.game.events.DamageEvent; import mage.game.events.GameEvent; -import mage.game.events.DamageCreatureEvent; import mage.game.permanent.Permanent; /** @@ -73,8 +73,8 @@ class CamelEffect extends PreventionEffectImpl { @Override public boolean applies(GameEvent event, Ability source, Game game) { - if (super.applies(event, source, game) && event instanceof DamageCreatureEvent && event.getAmount() > 0) { - DamageCreatureEvent damageEvent = (DamageCreatureEvent) event; + if (super.applies(event, source, game) && event instanceof DamageEvent && event.getAmount() > 0) { + DamageEvent damageEvent = (DamageEvent) event; Permanent sourcePermanent = game.getPermanentOrLKIBattlefield(source.getSourceId()); if (sourcePermanent != null && sourcePermanent.isAttacking() diff --git a/Mage.Sets/src/mage/cards/c/CloakOfConfusion.java b/Mage.Sets/src/mage/cards/c/CloakOfConfusion.java index fa771e757c..65694193d2 100644 --- a/Mage.Sets/src/mage/cards/c/CloakOfConfusion.java +++ b/Mage.Sets/src/mage/cards/c/CloakOfConfusion.java @@ -119,9 +119,8 @@ class CloakOfConfusionEffect extends ReplacementEffectImpl { @Override public boolean checksEventType(GameEvent event, Game game) { switch (event.getType()) { - case DAMAGE_CREATURE: + case DAMAGE_PERMANENT: case DAMAGE_PLAYER: - case DAMAGE_PLANESWALKER: return true; default: return false; diff --git a/Mage.Sets/src/mage/cards/c/CoverOfWinter.java b/Mage.Sets/src/mage/cards/c/CoverOfWinter.java index f09ab94cb1..30998303d8 100644 --- a/Mage.Sets/src/mage/cards/c/CoverOfWinter.java +++ b/Mage.Sets/src/mage/cards/c/CoverOfWinter.java @@ -65,7 +65,7 @@ class CoverOfWinterEffect extends PreventionEffectImpl { @Override public boolean checksEventType(GameEvent event, Game game) { - return event.getType() == GameEvent.EventType.DAMAGE_PLAYER || event.getType() == GameEvent.EventType.DAMAGE_CREATURE; + return event.getType() == GameEvent.EventType.DAMAGE_PLAYER || event.getType() == GameEvent.EventType.DAMAGE_PERMANENT; } @Override @@ -86,9 +86,9 @@ class CoverOfWinterEffect extends PreventionEffectImpl { return super.applies(event, source, game); } - if (event.getType() == GameEvent.EventType.DAMAGE_CREATURE) { + if (event.getType() == GameEvent.EventType.DAMAGE_PERMANENT) { Permanent permanent = game.getPermanent(event.getTargetId()); - if (permanent != null && permanent.isControlledBy(source.getControllerId())) { + if (permanent != null && permanent.isCreature() && permanent.isControlledBy(source.getControllerId())) { return super.applies(event, source, game); } } diff --git a/Mage.Sets/src/mage/cards/c/CragSaurian.java b/Mage.Sets/src/mage/cards/c/CragSaurian.java index 9d19434dfd..ff8cb76395 100644 --- a/Mage.Sets/src/mage/cards/c/CragSaurian.java +++ b/Mage.Sets/src/mage/cards/c/CragSaurian.java @@ -94,7 +94,7 @@ public final class CragSaurian extends CardImpl { @Override public boolean checkEventType(GameEvent event, Game game) { - return event.getType() == GameEvent.EventType.DAMAGED_CREATURE; + return event.getType() == GameEvent.EventType.DAMAGED_PERMANENT; } @Override diff --git a/Mage.Sets/src/mage/cards/c/CreepyDoll.java b/Mage.Sets/src/mage/cards/c/CreepyDoll.java index 4022f1b25b..ca21b756e4 100644 --- a/Mage.Sets/src/mage/cards/c/CreepyDoll.java +++ b/Mage.Sets/src/mage/cards/c/CreepyDoll.java @@ -1,7 +1,5 @@ - package mage.cards.c; -import java.util.UUID; import mage.MageInt; import mage.abilities.Ability; import mage.abilities.TriggeredAbilityImpl; @@ -10,24 +8,25 @@ import mage.abilities.keyword.IndestructibleAbility; import mage.cards.CardImpl; import mage.cards.CardSetInfo; import mage.constants.CardType; -import mage.constants.SubType; import mage.constants.Outcome; +import mage.constants.SubType; import mage.constants.Zone; import mage.game.Game; -import mage.game.events.DamagedCreatureEvent; +import mage.game.events.DamagedEvent; import mage.game.events.GameEvent; -import mage.game.events.GameEvent.EventType; import mage.game.permanent.Permanent; import mage.players.Player; import mage.target.targetpointer.FixedTarget; +import java.util.UUID; + /** * @author nantuko */ public final class CreepyDoll extends CardImpl { public CreepyDoll(UUID ownerId, CardSetInfo setInfo) { - super(ownerId,setInfo,new CardType[]{CardType.ARTIFACT,CardType.CREATURE},"{5}"); + super(ownerId, setInfo, new CardType[]{CardType.ARTIFACT, CardType.CREATURE}, "{5}"); this.subtype.add(SubType.CONSTRUCT); this.power = new MageInt(1); @@ -67,13 +66,17 @@ class CreepyDollTriggeredAbility extends TriggeredAbilityImpl { @Override public boolean checkEventType(GameEvent event, Game game) { - return event.getType() == GameEvent.EventType.DAMAGED_CREATURE; + return event.getType() == GameEvent.EventType.DAMAGED_PERMANENT; } @Override public boolean checkTrigger(GameEvent event, Game game) { - if (((DamagedCreatureEvent) event).isCombatDamage() && event.getSourceId().equals(sourceId)) { - getEffects().get(0).setTargetPointer(new FixedTarget(event.getTargetId())); + Permanent permanent = game.getPermanent(event.getTargetId()); + if (permanent != null + && permanent.isCreature() + && ((DamagedEvent) event).isCombatDamage() + && event.getSourceId().equals(sourceId)) { + getEffects().setTargetPointer(new FixedTarget(event.getTargetId(), game)); return true; } return false; diff --git a/Mage.Sets/src/mage/cards/d/DauntingDefender.java b/Mage.Sets/src/mage/cards/d/DauntingDefender.java index b792b5ac19..2f82af5c1e 100644 --- a/Mage.Sets/src/mage/cards/d/DauntingDefender.java +++ b/Mage.Sets/src/mage/cards/d/DauntingDefender.java @@ -63,9 +63,9 @@ class DauntingDefenderEffect extends PreventionEffectImpl { @Override public boolean applies(GameEvent event, Ability source, Game game) { - if (event.getType() == GameEvent.EventType.DAMAGE_CREATURE) { + if (event.getType() == GameEvent.EventType.DAMAGE_PERMANENT) { Permanent permanent = game.getPermanent(event.getTargetId()); - if (permanent != null && permanent.isControlledBy(source.getControllerId()) && permanent.hasSubtype(SubType.CLERIC, game)) { + if (permanent != null && permanent.isControlledBy(source.getControllerId()) && permanent.isCreature() && permanent.hasSubtype(SubType.CLERIC, game)) { return super.applies(event, source, game); } } diff --git a/Mage.Sets/src/mage/cards/d/DeathPitsOfRath.java b/Mage.Sets/src/mage/cards/d/DeathPitsOfRath.java index f7a3a13f5d..c89e27d75b 100644 --- a/Mage.Sets/src/mage/cards/d/DeathPitsOfRath.java +++ b/Mage.Sets/src/mage/cards/d/DeathPitsOfRath.java @@ -1,9 +1,7 @@ package mage.cards.d; -import java.util.UUID; import mage.abilities.TriggeredAbilityImpl; -import mage.abilities.effects.Effect; import mage.abilities.effects.common.DestroyTargetEffect; import mage.cards.CardImpl; import mage.cards.CardSetInfo; @@ -11,16 +9,18 @@ import mage.constants.CardType; import mage.constants.Zone; import mage.game.Game; import mage.game.events.GameEvent; +import mage.game.permanent.Permanent; import mage.target.targetpointer.FixedTarget; +import java.util.UUID; + /** - * * @author Plopman */ public final class DeathPitsOfRath extends CardImpl { public DeathPitsOfRath(UUID ownerId, CardSetInfo setInfo) { - super(ownerId,setInfo,new CardType[]{CardType.ENCHANTMENT},"{3}{B}{B}"); + super(ownerId, setInfo, new CardType[]{CardType.ENCHANTMENT}, "{3}{B}{B}"); // Whenever a creature is dealt damage, destroy it. It can't be regenerated. this.addAbility(new DeathPitsOfRathTriggeredAbility()); @@ -53,14 +53,16 @@ class DeathPitsOfRathTriggeredAbility extends TriggeredAbilityImpl { @Override public boolean checkEventType(GameEvent event, Game game) { - return event.getType() == GameEvent.EventType.DAMAGED_CREATURE; + return event.getType() == GameEvent.EventType.DAMAGED_PERMANENT; } @Override public boolean checkTrigger(GameEvent event, Game game) { - for (Effect effect : this.getEffects()) { - effect.setTargetPointer(new FixedTarget(event.getTargetId())); + Permanent permanent = game.getPermanent(event.getTargetId()); + if (permanent == null || !permanent.isCreature()) { + return false; } + getEffects().setTargetPointer(new FixedTarget(event.getTargetId(), game)); return true; } diff --git a/Mage.Sets/src/mage/cards/d/DelifsCone.java b/Mage.Sets/src/mage/cards/d/DelifsCone.java index 1a03e705e7..afec01670b 100644 --- a/Mage.Sets/src/mage/cards/d/DelifsCone.java +++ b/Mage.Sets/src/mage/cards/d/DelifsCone.java @@ -139,9 +139,8 @@ class DelifsConePreventEffect extends ReplacementEffectImpl { @Override public boolean checksEventType(GameEvent event, Game game) { switch (event.getType()) { - case DAMAGE_CREATURE: + case DAMAGE_PERMANENT: case DAMAGE_PLAYER: - case DAMAGE_PLANESWALKER: return true; default: return false; diff --git a/Mage.Sets/src/mage/cards/d/DelifsCube.java b/Mage.Sets/src/mage/cards/d/DelifsCube.java index a1da998ac8..62a9cf9d68 100644 --- a/Mage.Sets/src/mage/cards/d/DelifsCube.java +++ b/Mage.Sets/src/mage/cards/d/DelifsCube.java @@ -117,9 +117,8 @@ class DelifsCubePreventEffect extends ReplacementEffectImpl { @Override public boolean checksEventType(GameEvent event, Game game) { switch (event.getType()) { - case DAMAGE_CREATURE: + case DAMAGE_PERMANENT: case DAMAGE_PLAYER: - case DAMAGE_PLANESWALKER: return true; default: return false; diff --git a/Mage.Sets/src/mage/cards/d/DesperateGambit.java b/Mage.Sets/src/mage/cards/d/DesperateGambit.java index c9c97dd9bb..2e9d4d1ce2 100644 --- a/Mage.Sets/src/mage/cards/d/DesperateGambit.java +++ b/Mage.Sets/src/mage/cards/d/DesperateGambit.java @@ -80,8 +80,7 @@ class DesperateGambitEffect extends PreventionEffectImpl { @Override public boolean checksEventType(GameEvent event, Game game) { - return event.getType() == GameEvent.EventType.DAMAGE_CREATURE || - event.getType() == GameEvent.EventType.DAMAGE_PLANESWALKER || + return event.getType() == GameEvent.EventType.DAMAGE_PERMANENT || event.getType() == GameEvent.EventType.DAMAGE_PLAYER; } diff --git a/Mage.Sets/src/mage/cards/d/DictateOfTheTwinGods.java b/Mage.Sets/src/mage/cards/d/DictateOfTheTwinGods.java index 91745fefd0..6a870e43b6 100644 --- a/Mage.Sets/src/mage/cards/d/DictateOfTheTwinGods.java +++ b/Mage.Sets/src/mage/cards/d/DictateOfTheTwinGods.java @@ -64,9 +64,8 @@ class DictateOfTheTwinGodsEffect extends ReplacementEffectImpl { @Override public boolean checksEventType(GameEvent event, Game game) { switch (event.getType()) { - case DAMAGE_CREATURE: + case DAMAGE_PERMANENT: case DAMAGE_PLAYER: - case DAMAGE_PLANESWALKER: return true; default: return false; diff --git a/Mage.Sets/src/mage/cards/d/DinosaurHunter.java b/Mage.Sets/src/mage/cards/d/DinosaurHunter.java index 267cae4301..1ba2c00780 100644 --- a/Mage.Sets/src/mage/cards/d/DinosaurHunter.java +++ b/Mage.Sets/src/mage/cards/d/DinosaurHunter.java @@ -1,18 +1,20 @@ - package mage.cards.d; -import java.util.UUID; import mage.MageInt; import mage.abilities.TriggeredAbilityImpl; -import mage.abilities.effects.common.*; +import mage.abilities.effects.common.DestroyTargetEffect; import mage.cards.CardImpl; import mage.cards.CardSetInfo; -import mage.constants.*; +import mage.constants.CardType; +import mage.constants.SubType; +import mage.constants.Zone; import mage.game.Game; import mage.game.events.GameEvent; import mage.game.permanent.Permanent; import mage.target.targetpointer.FixedTarget; +import java.util.UUID; + /** * @author JayDi85 */ @@ -57,19 +59,20 @@ class DinosaurHunterAbility extends TriggeredAbilityImpl { @Override public boolean checkEventType(GameEvent event, Game game) { - return event.getType() == GameEvent.EventType.DAMAGED_CREATURE; + return event.getType() == GameEvent.EventType.DAMAGED_PERMANENT; } @Override public boolean checkTrigger(GameEvent event, Game game) { - if (event.getSourceId().equals(getSourceId())) { - Permanent targetPermanent = game.getPermanentOrLKIBattlefield(event.getTargetId()); - if (targetPermanent.hasSubtype(SubType.DINOSAUR, game)) { - getEffects().setTargetPointer(new FixedTarget(targetPermanent, game)); - return true; - } + if (!event.getSourceId().equals(getSourceId())) { + return false; } - return false; + Permanent targetPermanent = game.getPermanentOrLKIBattlefield(event.getTargetId()); + if (targetPermanent == null || !targetPermanent.hasSubtype(SubType.DINOSAUR, game)) { + return false; + } + getEffects().setTargetPointer(new FixedTarget(targetPermanent, game)); + return true; } @Override diff --git a/Mage.Sets/src/mage/cards/d/DivinePresence.java b/Mage.Sets/src/mage/cards/d/DivinePresence.java index e1d12cc0a9..cb13715444 100644 --- a/Mage.Sets/src/mage/cards/d/DivinePresence.java +++ b/Mage.Sets/src/mage/cards/d/DivinePresence.java @@ -56,9 +56,8 @@ class DivinePresenceEffect extends ReplacementEffectImpl { @Override public boolean checksEventType(GameEvent event, Game game) { switch (event.getType()) { - case DAMAGE_CREATURE: + case DAMAGE_PERMANENT: case DAMAGE_PLAYER: - case DAMAGE_PLANESWALKER: return true; default: return false; diff --git a/Mage.Sets/src/mage/cards/d/DjeruWithEyesOpen.java b/Mage.Sets/src/mage/cards/d/DjeruWithEyesOpen.java index e9dfe4c072..c212421ed7 100644 --- a/Mage.Sets/src/mage/cards/d/DjeruWithEyesOpen.java +++ b/Mage.Sets/src/mage/cards/d/DjeruWithEyesOpen.java @@ -84,9 +84,9 @@ class DjeruWithEyesOpenPreventEffect extends PreventionEffectImpl { @Override public boolean applies(GameEvent event, Ability source, Game game) { - if (event.getType() == GameEvent.EventType.DAMAGE_PLANESWALKER) { + if (event.getType() == GameEvent.EventType.DAMAGE_PERMANENT) { Permanent permanent = game.getPermanent(event.getTargetId()); - if (permanent != null && permanent.isControlledBy(source.getControllerId())) { + if (permanent != null && permanent.isPlaneswalker() && permanent.isControlledBy(source.getControllerId())) { return super.applies(event, source, game); } } diff --git a/Mage.Sets/src/mage/cards/d/DralnuLichLord.java b/Mage.Sets/src/mage/cards/d/DralnuLichLord.java index ec6e4a97aa..c32b2780ab 100644 --- a/Mage.Sets/src/mage/cards/d/DralnuLichLord.java +++ b/Mage.Sets/src/mage/cards/d/DralnuLichLord.java @@ -19,7 +19,7 @@ import mage.filter.FilterCard; import mage.filter.FilterPermanent; import mage.filter.predicate.Predicates; import mage.game.Game; -import mage.game.events.DamageCreatureEvent; +import mage.game.events.DamageEvent; import mage.game.events.GameEvent; import mage.target.common.TargetCardInYourGraveyard; @@ -76,14 +76,14 @@ class DralnuLichLordReplacementEffect extends ReplacementEffectImpl { @Override public boolean replaceEvent(GameEvent event, Ability source, Game game) { - DamageCreatureEvent damageEvent = (DamageCreatureEvent) event; + DamageEvent damageEvent = (DamageEvent) event; new SacrificeControllerEffect(new FilterPermanent(), damageEvent.getAmount(), "").apply(game, source); return true; } @Override public boolean checksEventType(GameEvent event, Game game) { - return event.getType() == GameEvent.EventType.DAMAGE_CREATURE; + return event.getType() == GameEvent.EventType.DAMAGE_PERMANENT; } @Override diff --git a/Mage.Sets/src/mage/cards/e/EmbermawHellion.java b/Mage.Sets/src/mage/cards/e/EmbermawHellion.java index d88a3e8c12..58388c02b2 100644 --- a/Mage.Sets/src/mage/cards/e/EmbermawHellion.java +++ b/Mage.Sets/src/mage/cards/e/EmbermawHellion.java @@ -63,8 +63,7 @@ class EmbermawHellionEffect extends ReplacementEffectImpl { @Override public boolean checksEventType(GameEvent event, Game game) { switch(event.getType()) { - case DAMAGE_CREATURE: - case DAMAGE_PLANESWALKER: + case DAMAGE_PERMANENT: case DAMAGE_PLAYER: return true; default: diff --git a/Mage.Sets/src/mage/cards/e/EmberwildeCaliph.java b/Mage.Sets/src/mage/cards/e/EmberwildeCaliph.java index a5294051b9..075d90dae3 100644 --- a/Mage.Sets/src/mage/cards/e/EmberwildeCaliph.java +++ b/Mage.Sets/src/mage/cards/e/EmberwildeCaliph.java @@ -72,9 +72,8 @@ class EmberwildeCaliphTriggeredAbility extends TriggeredAbilityImpl { @Override public boolean checkEventType(GameEvent event, Game game) { - return event.getType() == GameEvent.EventType.DAMAGED_CREATURE - || event.getType() == GameEvent.EventType.DAMAGED_PLAYER - || event.getType() == GameEvent.EventType.DAMAGED_PLANESWALKER; + return event.getType() == GameEvent.EventType.DAMAGED_PERMANENT + || event.getType() == GameEvent.EventType.DAMAGED_PLAYER; } @Override diff --git a/Mage.Sets/src/mage/cards/e/EqualTreatment.java b/Mage.Sets/src/mage/cards/e/EqualTreatment.java index 5bb803e3f7..9cac57fc95 100644 --- a/Mage.Sets/src/mage/cards/e/EqualTreatment.java +++ b/Mage.Sets/src/mage/cards/e/EqualTreatment.java @@ -57,9 +57,8 @@ class EqualTreatmentEffect extends ReplacementEffectImpl { @Override public boolean checksEventType(GameEvent event, Game game) { - return event.getType() == GameEvent.EventType.DAMAGE_CREATURE - || event.getType() == GameEvent.EventType.DAMAGE_PLAYER - || event.getType() == GameEvent.EventType.DAMAGED_PLANESWALKER; + return event.getType() == GameEvent.EventType.DAMAGE_PERMANENT + || event.getType() == GameEvent.EventType.DAMAGE_PLAYER; } @Override diff --git a/Mage.Sets/src/mage/cards/e/EssenceSliver.java b/Mage.Sets/src/mage/cards/e/EssenceSliver.java index c8a1de1edb..4a619fa253 100644 --- a/Mage.Sets/src/mage/cards/e/EssenceSliver.java +++ b/Mage.Sets/src/mage/cards/e/EssenceSliver.java @@ -65,9 +65,8 @@ class DealsDamageAllTriggeredAbility extends TriggeredAbilityImpl { @Override public boolean checkEventType(GameEvent event, Game game) { - return event.getType() == GameEvent.EventType.DAMAGED_CREATURE - || event.getType() == GameEvent.EventType.DAMAGED_PLAYER - || event.getType() == GameEvent.EventType.DAMAGED_PLANESWALKER; + return event.getType() == GameEvent.EventType.DAMAGED_PERMANENT + || event.getType() == GameEvent.EventType.DAMAGED_PLAYER; } @Override diff --git a/Mage.Sets/src/mage/cards/e/EverlastingTorment.java b/Mage.Sets/src/mage/cards/e/EverlastingTorment.java index 5feddd1fd7..7090898426 100644 --- a/Mage.Sets/src/mage/cards/e/EverlastingTorment.java +++ b/Mage.Sets/src/mage/cards/e/EverlastingTorment.java @@ -1,7 +1,5 @@ - package mage.cards.e; -import java.util.UUID; import mage.abilities.Ability; import mage.abilities.common.SimpleStaticAbility; import mage.abilities.effects.ReplacementEffectImpl; @@ -12,32 +10,31 @@ import mage.cards.CardSetInfo; import mage.constants.CardType; import mage.constants.Duration; import mage.constants.Outcome; -import mage.constants.Zone; -import mage.counters.Counter; -import mage.counters.CounterType; import mage.game.Game; +import mage.game.events.DamageEvent; import mage.game.events.GameEvent; -import mage.game.permanent.Permanent; + +import java.util.UUID; /** - * * @author jeffwadsworth */ public final class EverlastingTorment extends CardImpl { public EverlastingTorment(UUID ownerId, CardSetInfo setInfo) { - super(ownerId,setInfo,new CardType[]{CardType.ENCHANTMENT},"{2}{B/R}"); + super(ownerId, setInfo, new CardType[]{CardType.ENCHANTMENT}, "{2}{B/R}"); // Players can't gain life. - this.addAbility(new SimpleStaticAbility(Zone.BATTLEFIELD, new CantGainLifeAllEffect())); + this.addAbility(new SimpleStaticAbility(new CantGainLifeAllEffect())); // Damage can't be prevented. - this.addAbility(new SimpleStaticAbility(Zone.BATTLEFIELD, - new DamageCantBePreventedEffect(Duration.WhileOnBattlefield, "Damage can't be prevented", true, false))); + this.addAbility(new SimpleStaticAbility(new DamageCantBePreventedEffect( + Duration.WhileOnBattlefield, "Damage can't be prevented", + true, false + ))); // All damage is dealt as though its source had wither. - this.addAbility(new SimpleStaticAbility(Zone.BATTLEFIELD, new DamageDealtAsIfSourceHadWitherEffect())); - + this.addAbility(new SimpleStaticAbility(new DamageDealtAsIfSourceHadWitherEffect())); } private EverlastingTorment(final EverlastingTorment card) { @@ -52,12 +49,12 @@ public final class EverlastingTorment extends CardImpl { class DamageDealtAsIfSourceHadWitherEffect extends ReplacementEffectImpl { - public DamageDealtAsIfSourceHadWitherEffect() { + DamageDealtAsIfSourceHadWitherEffect() { super(Duration.WhileOnBattlefield, Outcome.Neutral); staticText = "All damage is dealt as though its source had wither"; } - public DamageDealtAsIfSourceHadWitherEffect(final DamageDealtAsIfSourceHadWitherEffect effect) { + private DamageDealtAsIfSourceHadWitherEffect(final DamageDealtAsIfSourceHadWitherEffect effect) { super(effect); } @@ -73,23 +70,15 @@ class DamageDealtAsIfSourceHadWitherEffect extends ReplacementEffectImpl { @Override public boolean replaceEvent(GameEvent event, Ability source, Game game) { - int damageAmount = event.getAmount(); - if (damageAmount > 0) { - Counter counter = CounterType.M1M1.createInstance(damageAmount); - Permanent creatureDamaged = game.getPermanent(event.getTargetId()); - if (creatureDamaged != null) { - creatureDamaged.addCounters(counter, source.getControllerId(), source, game); - } - } - return true; + ((DamageEvent) event).setAsThoughWither(true); + return false; } @Override public boolean checksEventType(GameEvent event, Game game) { - return event.getType() == GameEvent.EventType.DAMAGE_CREATURE; + return event.getType() == GameEvent.EventType.DAMAGE_PERMANENT; } - @Override public boolean applies(GameEvent event, Ability source, Game game) { return true; diff --git a/Mage.Sets/src/mage/cards/f/FarrelsMantle.java b/Mage.Sets/src/mage/cards/f/FarrelsMantle.java index 157e80e20b..cfb64e43bb 100644 --- a/Mage.Sets/src/mage/cards/f/FarrelsMantle.java +++ b/Mage.Sets/src/mage/cards/f/FarrelsMantle.java @@ -173,9 +173,8 @@ class FarrelsMantleDamageEffect extends ReplacementEffectImpl { @Override public boolean checksEventType(GameEvent event, Game game) { switch (event.getType()) { - case DAMAGE_CREATURE: + case DAMAGE_PERMANENT: case DAMAGE_PLAYER: - case DAMAGE_PLANESWALKER: return true; default: return false; diff --git a/Mage.Sets/src/mage/cards/f/FieryEmancipation.java b/Mage.Sets/src/mage/cards/f/FieryEmancipation.java index 0a9a0e94e6..35ac935442 100644 --- a/Mage.Sets/src/mage/cards/f/FieryEmancipation.java +++ b/Mage.Sets/src/mage/cards/f/FieryEmancipation.java @@ -56,8 +56,7 @@ class FieryEmancipationEffect extends ReplacementEffectImpl { @Override public boolean checksEventType(GameEvent event, Game game) { return event.getType().equals(GameEvent.EventType.DAMAGE_PLAYER) - || event.getType().equals(GameEvent.EventType.DAMAGE_CREATURE) - || event.getType().equals(GameEvent.EventType.DAMAGE_PLANESWALKER); + || event.getType().equals(GameEvent.EventType.DAMAGE_PERMANENT); } @Override diff --git a/Mage.Sets/src/mage/cards/f/FilthyCur.java b/Mage.Sets/src/mage/cards/f/FilthyCur.java index de1ba0f1e6..b819361737 100644 --- a/Mage.Sets/src/mage/cards/f/FilthyCur.java +++ b/Mage.Sets/src/mage/cards/f/FilthyCur.java @@ -60,7 +60,7 @@ class DealtDamageLoseLifeTriggeredAbility extends TriggeredAbilityImpl { @Override public boolean checkEventType(GameEvent event, Game game) { - return event.getType() == GameEvent.EventType.DAMAGED_CREATURE; + return event.getType() == GameEvent.EventType.DAMAGED_PERMANENT; } @Override diff --git a/Mage.Sets/src/mage/cards/f/FireServant.java b/Mage.Sets/src/mage/cards/f/FireServant.java index 544923dd53..be773946ab 100644 --- a/Mage.Sets/src/mage/cards/f/FireServant.java +++ b/Mage.Sets/src/mage/cards/f/FireServant.java @@ -65,8 +65,7 @@ class FireServantEffect extends ReplacementEffectImpl { @Override public boolean checksEventType(GameEvent event, Game game) { - return event.getType() == GameEvent.EventType.DAMAGE_CREATURE || - event.getType() == GameEvent.EventType.DAMAGE_PLANESWALKER || + return event.getType() == GameEvent.EventType.DAMAGE_PERMANENT || event.getType() == GameEvent.EventType.DAMAGE_PLAYER; } diff --git a/Mage.Sets/src/mage/cards/f/FiveAlarmFire.java b/Mage.Sets/src/mage/cards/f/FiveAlarmFire.java index a38fda36de..61ceaef19a 100644 --- a/Mage.Sets/src/mage/cards/f/FiveAlarmFire.java +++ b/Mage.Sets/src/mage/cards/f/FiveAlarmFire.java @@ -78,16 +78,14 @@ class FiveAlarmFireTriggeredAbility extends TriggeredAbilityImpl { @Override public boolean checkEventType(GameEvent event, Game game) { - return event.getType() == GameEvent.EventType.DAMAGED_CREATURE - || event.getType() == GameEvent.EventType.DAMAGED_PLANESWALKER + return event.getType() == GameEvent.EventType.DAMAGED_PERMANENT || event.getType() == GameEvent.EventType.DAMAGED_PLAYER || event.getType() == GameEvent.EventType.COMBAT_DAMAGE_STEP_PRE; } @Override public boolean checkTrigger(GameEvent event, Game game) { - if (event.getType() == GameEvent.EventType.DAMAGED_CREATURE - || event.getType() == GameEvent.EventType.DAMAGED_PLANESWALKER + if (event.getType() == GameEvent.EventType.DAMAGED_PERMANENT || event.getType() == GameEvent.EventType.DAMAGED_PLAYER) { if (((DamagedEvent) event).isCombatDamage() && !triggeringCreatures.contains(event.getSourceId())) { Permanent permanent = game.getPermanent(event.getSourceId()); diff --git a/Mage.Sets/src/mage/cards/f/FlameSpill.java b/Mage.Sets/src/mage/cards/f/FlameSpill.java index 6c3a159d45..dc2ddb497a 100644 --- a/Mage.Sets/src/mage/cards/f/FlameSpill.java +++ b/Mage.Sets/src/mage/cards/f/FlameSpill.java @@ -3,7 +3,6 @@ package mage.cards.f; import mage.MageObject; import mage.abilities.Ability; import mage.abilities.effects.OneShotEffect; -import mage.abilities.keyword.DeathtouchAbility; import mage.cards.CardImpl; import mage.cards.CardSetInfo; import mage.constants.CardType; @@ -15,8 +14,6 @@ import mage.target.common.TargetCreaturePermanent; import java.util.UUID; -import static mage.game.combat.CombatGroup.getLethalDamage; - /** * @author TheElk801 */ @@ -64,10 +61,7 @@ class FlameSpillEffect extends OneShotEffect { if (permanent == null || sourceObject == null) { return false; } - int lethal = getLethalDamage(permanent, game); - if (sourceObject.getAbilities().containsKey(DeathtouchAbility.getInstance().getId())) { - lethal = Math.min(lethal, 1); - } + int lethal = permanent.getLethalDamage(source.getSourceId(), game); lethal = Math.min(lethal, 4); permanent.damage(lethal, source.getSourceId(), source, game); Player player = game.getPlayer(permanent.getControllerId()); diff --git a/Mage.Sets/src/mage/cards/f/FlamebladeAngel.java b/Mage.Sets/src/mage/cards/f/FlamebladeAngel.java index 85c72fdc35..00fb7c6b1d 100644 --- a/Mage.Sets/src/mage/cards/f/FlamebladeAngel.java +++ b/Mage.Sets/src/mage/cards/f/FlamebladeAngel.java @@ -63,8 +63,7 @@ class FlamebladeAngelTriggeredAbility extends TriggeredAbilityImpl { @Override public boolean checkEventType(GameEvent event, Game game) { - return event.getType() == GameEvent.EventType.DAMAGED_CREATURE - || event.getType() == GameEvent.EventType.DAMAGED_PLANESWALKER + return event.getType() == GameEvent.EventType.DAMAGED_PERMANENT || event.getType() == GameEvent.EventType.DAMAGED_PLAYER; } diff --git a/Mage.Sets/src/mage/cards/f/FlashConscription.java b/Mage.Sets/src/mage/cards/f/FlashConscription.java index d0eaf93e8e..3600f8622f 100644 --- a/Mage.Sets/src/mage/cards/f/FlashConscription.java +++ b/Mage.Sets/src/mage/cards/f/FlashConscription.java @@ -72,9 +72,8 @@ class FlashConscriptionTriggeredAbility extends TriggeredAbilityImpl { @Override public boolean checkEventType(GameEvent event, Game game) { - return event.getType() == GameEvent.EventType.DAMAGED_CREATURE - || event.getType() == GameEvent.EventType.DAMAGED_PLAYER - || event.getType() == GameEvent.EventType.DAMAGED_PLANESWALKER; + return event.getType() == GameEvent.EventType.DAMAGED_PERMANENT + || event.getType() == GameEvent.EventType.DAMAGED_PLAYER; } @Override diff --git a/Mage.Sets/src/mage/cards/f/FleshReaver.java b/Mage.Sets/src/mage/cards/f/FleshReaver.java index 6f0323a0e5..9ae154836a 100644 --- a/Mage.Sets/src/mage/cards/f/FleshReaver.java +++ b/Mage.Sets/src/mage/cards/f/FleshReaver.java @@ -3,7 +3,6 @@ package mage.cards.f; import mage.MageInt; import mage.abilities.Ability; import mage.abilities.TriggeredAbilityImpl; -import mage.abilities.effects.Effect; import mage.abilities.effects.OneShotEffect; import mage.cards.CardImpl; import mage.cards.CardSetInfo; @@ -50,7 +49,7 @@ class FleshReaverTriggeredAbility extends TriggeredAbilityImpl { super(Zone.BATTLEFIELD, new FleshReaverEffect()); } - FleshReaverTriggeredAbility(final FleshReaverTriggeredAbility effect) { + private FleshReaverTriggeredAbility(final FleshReaverTriggeredAbility effect) { super(effect); } @@ -61,23 +60,22 @@ class FleshReaverTriggeredAbility extends TriggeredAbilityImpl { @Override public boolean checkEventType(GameEvent event, Game game) { - return event.getType() == GameEvent.EventType.DAMAGED_CREATURE || event.getType() == GameEvent.EventType.DAMAGED_PLAYER; + return event.getType() == GameEvent.EventType.DAMAGED_PERMANENT + || event.getType() == GameEvent.EventType.DAMAGED_PLAYER; } @Override public boolean checkTrigger(GameEvent event, Game game) { - if (!event.getSourceId().equals(sourceId)) { + if (!event.getSourceId().equals(getSourceId())) { return false; } - if (event.getType() == GameEvent.EventType.DAMAGED_PLAYER) { - if (event.getTargetId().equals(controllerId)) { - return false; - } + Permanent permanent = game.getPermanent(event.getTargetId()); + if ((permanent != null && permanent.isCreature()) + || game.getOpponents(event.getTargetId()).contains(getControllerId())) { + this.getEffects().setValue("damage", event.getAmount()); + return true; } - for (Effect effect : this.getEffects()) { - effect.setValue("damage", event.getAmount()); - } - return true; + return false; } @Override @@ -94,7 +92,7 @@ class FleshReaverEffect extends OneShotEffect { this.staticText = "{this} deals that much damage to you."; } - FleshReaverEffect(final FleshReaverEffect effect) { + private FleshReaverEffect(final FleshReaverEffect effect) { super(effect); } diff --git a/Mage.Sets/src/mage/cards/f/FurnaceOfRath.java b/Mage.Sets/src/mage/cards/f/FurnaceOfRath.java index 68639e1d4b..b1f7e0548a 100644 --- a/Mage.Sets/src/mage/cards/f/FurnaceOfRath.java +++ b/Mage.Sets/src/mage/cards/f/FurnaceOfRath.java @@ -59,10 +59,7 @@ class FurnaceOfRathEffect extends ReplacementEffectImpl { public boolean checksEventType(GameEvent event, Game game) { switch (event.getType()) { case DAMAGE_PLAYER: - return true; - case DAMAGE_CREATURE: - return true; - case DAMAGE_PLANESWALKER: + case DAMAGE_PERMANENT: return true; } return false; diff --git a/Mage.Sets/src/mage/cards/g/GazeOfPain.java b/Mage.Sets/src/mage/cards/g/GazeOfPain.java index 4073979ae0..f1f5d1531a 100644 --- a/Mage.Sets/src/mage/cards/g/GazeOfPain.java +++ b/Mage.Sets/src/mage/cards/g/GazeOfPain.java @@ -142,9 +142,8 @@ class GazeOfPainDamageEffect extends ReplacementEffectImpl { @Override public boolean checksEventType(GameEvent event, Game game) { switch (event.getType()) { - case DAMAGE_CREATURE: + case DAMAGE_PERMANENT: case DAMAGE_PLAYER: - case DAMAGE_PLANESWALKER: return true; default: return false; diff --git a/Mage.Sets/src/mage/cards/g/GhostsOfTheInnocent.java b/Mage.Sets/src/mage/cards/g/GhostsOfTheInnocent.java index 607e592ac7..d8ffa45b50 100644 --- a/Mage.Sets/src/mage/cards/g/GhostsOfTheInnocent.java +++ b/Mage.Sets/src/mage/cards/g/GhostsOfTheInnocent.java @@ -61,9 +61,8 @@ class GhostsOfTheInnocentPreventDamageEffect extends ReplacementEffectImpl imple @Override public boolean checksEventType(GameEvent event, Game game) { - return event.getType() == GameEvent.EventType.DAMAGE_CREATURE - || event.getType() == GameEvent.EventType.DAMAGE_PLAYER - || event.getType() == GameEvent.EventType.DAMAGE_PLANESWALKER; + return event.getType() == GameEvent.EventType.DAMAGE_PLAYER + || event.getType() == EventType.DAMAGE_PERMANENT; } @Override diff --git a/Mage.Sets/src/mage/cards/g/GiantsSkewer.java b/Mage.Sets/src/mage/cards/g/GiantsSkewer.java index 1baf34e5fa..8fc467963b 100644 --- a/Mage.Sets/src/mage/cards/g/GiantsSkewer.java +++ b/Mage.Sets/src/mage/cards/g/GiantsSkewer.java @@ -11,7 +11,7 @@ import mage.constants.CardType; import mage.constants.SubType; import mage.constants.Zone; import mage.game.Game; -import mage.game.events.DamagedCreatureEvent; +import mage.game.events.DamagedEvent; import mage.game.events.GameEvent; import mage.game.permanent.Permanent; import mage.game.permanent.token.FoodToken; @@ -65,12 +65,12 @@ class GiantsSkewerTriggeredAbility extends TriggeredAbilityImpl { @Override public boolean checkEventType(GameEvent event, Game game) { - return event.getType() == GameEvent.EventType.DAMAGED_CREATURE; + return event.getType() == GameEvent.EventType.DAMAGED_PERMANENT; } @Override public boolean checkTrigger(GameEvent event, Game game) { - if (!((DamagedCreatureEvent) event).isCombatDamage()) { + if (!((DamagedEvent) event).isCombatDamage()) { return false; } Permanent permanent = game.getPermanent(event.getSourceId()); diff --git a/Mage.Sets/src/mage/cards/g/GideonsIntervention.java b/Mage.Sets/src/mage/cards/g/GideonsIntervention.java index a8964c25f8..1549b31485 100644 --- a/Mage.Sets/src/mage/cards/g/GideonsIntervention.java +++ b/Mage.Sets/src/mage/cards/g/GideonsIntervention.java @@ -135,9 +135,8 @@ class GideonsInterventionPreventAllDamageEffect extends PreventionEffectImpl { MageObject object = game.getObject(event.getSourceId()); Permanent targetPerm = game.getPermanent(event.getTargetId()); String cardName = (String) game.getState().getValue(source.getSourceId().toString() + ChooseACardNameEffect.INFO_KEY); - if (object != null && (event.getType() == GameEvent.EventType.DAMAGE_PLAYER - || targetPerm != null && (event.getType() == GameEvent.EventType.DAMAGE_CREATURE - || event.getType() == GameEvent.EventType.DAMAGE_PLANESWALKER))) { + if (object != null && (event.getType() == EventType.DAMAGE_PLAYER + || targetPerm != null && event.getType() == EventType.DAMAGE_PERMANENT)) { if (CardUtil.haveSameNames(object, cardName, game) && (event.getTargetId().equals(source.getControllerId()) || targetPerm != null && targetPerm.isControlledBy(source.getControllerId()))) { diff --git a/Mage.Sets/src/mage/cards/g/GideonsSacrifice.java b/Mage.Sets/src/mage/cards/g/GideonsSacrifice.java index d52bedde4e..49ee47ae86 100644 --- a/Mage.Sets/src/mage/cards/g/GideonsSacrifice.java +++ b/Mage.Sets/src/mage/cards/g/GideonsSacrifice.java @@ -107,9 +107,8 @@ class GideonsSacrificeEffectReplacementEffect extends ReplacementEffectImpl { @Override public boolean checksEventType(GameEvent event, Game game) { switch (event.getType()) { - case DAMAGE_CREATURE: case DAMAGE_PLAYER: - case DAMAGE_PLANESWALKER: + case DAMAGE_PERMANENT: return true; default: return false; @@ -122,8 +121,7 @@ class GideonsSacrificeEffectReplacementEffect extends ReplacementEffectImpl { && event.getPlayerId().equals(source.getControllerId())) { return true; } - if (event.getType() == GameEvent.EventType.DAMAGE_CREATURE - || event.getType() == GameEvent.EventType.DAMAGE_PLANESWALKER) { + if (event.getType() == GameEvent.EventType.DAMAGE_PERMANENT) { Permanent targetPermanent = game.getPermanent(event.getTargetId()); if (targetPermanent != null && targetPermanent.isControlledBy(source.getControllerId())) { diff --git a/Mage.Sets/src/mage/cards/g/GiselaBladeOfGoldnight.java b/Mage.Sets/src/mage/cards/g/GiselaBladeOfGoldnight.java index c01ba19127..93dd84e433 100644 --- a/Mage.Sets/src/mage/cards/g/GiselaBladeOfGoldnight.java +++ b/Mage.Sets/src/mage/cards/g/GiselaBladeOfGoldnight.java @@ -72,9 +72,8 @@ class GiselaBladeOfGoldnightDoubleDamageEffect extends ReplacementEffectImpl { @Override public boolean checksEventType(GameEvent event, Game game) { switch (event.getType()) { - case DAMAGE_CREATURE: case DAMAGE_PLAYER: - case DAMAGE_PLANESWALKER: + case DAMAGE_PERMANENT: return true; default: return false; diff --git a/Mage.Sets/src/mage/cards/g/Glarecaster.java b/Mage.Sets/src/mage/cards/g/Glarecaster.java index c3f53b4ea8..30cbef5c45 100644 --- a/Mage.Sets/src/mage/cards/g/Glarecaster.java +++ b/Mage.Sets/src/mage/cards/g/Glarecaster.java @@ -87,7 +87,7 @@ class GlarecasterEffect extends RedirectionEffect { @Override public boolean checksEventType(GameEvent event, Game game) { - return event.getType() == GameEvent.EventType.DAMAGE_CREATURE || event.getType() == GameEvent.EventType.DAMAGE_PLAYER; + return event.getType() == EventType.DAMAGE_PERMANENT || event.getType() == GameEvent.EventType.DAMAGE_PLAYER; } @Override diff --git a/Mage.Sets/src/mage/cards/g/GloomSurgeon.java b/Mage.Sets/src/mage/cards/g/GloomSurgeon.java index 0419ea6d5f..7b60e91a57 100644 --- a/Mage.Sets/src/mage/cards/g/GloomSurgeon.java +++ b/Mage.Sets/src/mage/cards/g/GloomSurgeon.java @@ -67,13 +67,13 @@ class GloomSurgeonEffect extends ReplacementEffectImpl { @Override public boolean checksEventType(GameEvent event, Game game) { - return event.getType() == GameEvent.EventType.DAMAGE_CREATURE; + return event.getType() == GameEvent.EventType.DAMAGE_PERMANENT; } @Override public boolean applies(GameEvent event, Ability source, Game game) { if (event.getTargetId().equals(source.getSourceId())) { - DamageCreatureEvent damageEvent = (DamageCreatureEvent) event; + DamageEvent damageEvent = (DamageEvent) event; return damageEvent.isCombatDamage(); } return false; diff --git a/Mage.Sets/src/mage/cards/g/GlyphOfLife.java b/Mage.Sets/src/mage/cards/g/GlyphOfLife.java index 94f927bbe7..7c91d7128d 100644 --- a/Mage.Sets/src/mage/cards/g/GlyphOfLife.java +++ b/Mage.Sets/src/mage/cards/g/GlyphOfLife.java @@ -15,9 +15,8 @@ import mage.constants.Duration; import mage.constants.Outcome; import mage.filter.common.FilterCreaturePermanent; import mage.game.Game; +import mage.game.events.DamagedEvent; import mage.game.events.GameEvent; -import mage.game.events.DamagedCreatureEvent; -import mage.game.events.GameEvent.EventType; import mage.game.permanent.Permanent; import mage.players.Player; import mage.target.common.TargetCreaturePermanent; @@ -70,13 +69,13 @@ class GlyphOfLifeTriggeredAbility extends DelayedTriggeredAbility { @Override public boolean checkEventType(GameEvent event, Game game) { - return event.getType() == GameEvent.EventType.DAMAGED_CREATURE; + return event.getType() == GameEvent.EventType.DAMAGED_PERMANENT; } @Override public boolean checkTrigger(GameEvent event, Game game) { if (event.getTargetId().equals(this.getFirstTarget())) { - DamagedCreatureEvent damageEvent = (DamagedCreatureEvent) event; + DamagedEvent damageEvent = (DamagedEvent) event; Permanent attackingCreature = game.getPermanentOrLKIBattlefield(damageEvent.getSourceId()); if (attackingCreature != null && attackingCreature.isCreature() && attackingCreature.isAttacking()) { this.getEffects().get(0).setValue("damageAmount", event.getAmount()); diff --git a/Mage.Sets/src/mage/cards/g/GoblinBowlingTeam.java b/Mage.Sets/src/mage/cards/g/GoblinBowlingTeam.java index cadb994f29..bd0a9c5041 100644 --- a/Mage.Sets/src/mage/cards/g/GoblinBowlingTeam.java +++ b/Mage.Sets/src/mage/cards/g/GoblinBowlingTeam.java @@ -66,9 +66,8 @@ class GoblinBowlingTeamEffect extends ReplacementEffectImpl { @Override public boolean checksEventType(GameEvent event, Game game) { switch (event.getType()) { - case DAMAGE_CREATURE: case DAMAGE_PLAYER: - case DAMAGE_PLANESWALKER: + case DAMAGE_PERMANENT: return true; default: return false; diff --git a/Mage.Sets/src/mage/cards/g/GoblinPsychopath.java b/Mage.Sets/src/mage/cards/g/GoblinPsychopath.java index 0fc141c9eb..d143fc2df3 100644 --- a/Mage.Sets/src/mage/cards/g/GoblinPsychopath.java +++ b/Mage.Sets/src/mage/cards/g/GoblinPsychopath.java @@ -70,8 +70,7 @@ class GoblinPsychopathEffect extends ReplacementEffectImpl { @Override public boolean checksEventType(GameEvent event, Game game) { - return event.getType() == GameEvent.EventType.DAMAGE_CREATURE - || event.getType() == GameEvent.EventType.DAMAGE_PLANESWALKER + return event.getType() == GameEvent.EventType.DAMAGE_PERMANENT || event.getType() == GameEvent.EventType.DAMAGE_PLAYER; } diff --git a/Mage.Sets/src/mage/cards/g/GoldnightCastigator.java b/Mage.Sets/src/mage/cards/g/GoldnightCastigator.java index 7380fd13b9..5300b4bcfe 100644 --- a/Mage.Sets/src/mage/cards/g/GoldnightCastigator.java +++ b/Mage.Sets/src/mage/cards/g/GoldnightCastigator.java @@ -72,7 +72,7 @@ class GoldnightCastigatorDoubleDamageEffect extends ReplacementEffectImpl { @Override public boolean checksEventType(GameEvent event, Game game) { - return event.getType() == GameEvent.EventType.DAMAGE_CREATURE || + return event.getType() == GameEvent.EventType.DAMAGE_PERMANENT || event.getType() == GameEvent.EventType.DAMAGE_PLAYER; } @@ -95,7 +95,7 @@ class GoldnightCastigatorDoubleDamageEffect extends ReplacementEffectImpl { event.setAmount(CardUtil.overflowMultiply(event.getAmount(), 2)); } break; - case DAMAGE_CREATURE: + case DAMAGE_PERMANENT: Permanent permanent = game.getPermanent(event.getTargetId()); if (permanent != null) { if (permanent.getId().equals(source.getSourceId())) { diff --git a/Mage.Sets/src/mage/cards/g/GratuitousViolence.java b/Mage.Sets/src/mage/cards/g/GratuitousViolence.java index b9ba8512fd..eb60b065e7 100644 --- a/Mage.Sets/src/mage/cards/g/GratuitousViolence.java +++ b/Mage.Sets/src/mage/cards/g/GratuitousViolence.java @@ -58,9 +58,8 @@ class GratuitousViolenceReplacementEffect extends ReplacementEffectImpl { @Override public boolean checksEventType(GameEvent event, Game game) { switch (event.getType()) { - case DAMAGE_CREATURE: case DAMAGE_PLAYER: - case DAMAGE_PLANESWALKER: + case DAMAGE_PERMANENT: return true; default: return false; diff --git a/Mage.Sets/src/mage/cards/g/GreatbowDoyen.java b/Mage.Sets/src/mage/cards/g/GreatbowDoyen.java index 36d4ccb9d4..9da3f0a5d0 100644 --- a/Mage.Sets/src/mage/cards/g/GreatbowDoyen.java +++ b/Mage.Sets/src/mage/cards/g/GreatbowDoyen.java @@ -72,7 +72,7 @@ class GreatbowDoyenTriggeredAbility extends TriggeredAbilityImpl { @Override public boolean checkEventType(GameEvent event, Game game) { - return event.getType() == GameEvent.EventType.DAMAGED_CREATURE; + return event.getType() == GameEvent.EventType.DAMAGED_PERMANENT; } @Override diff --git a/Mage.Sets/src/mage/cards/g/GrothamaAllDevouring.java b/Mage.Sets/src/mage/cards/g/GrothamaAllDevouring.java index 0236379584..3a1703b9a1 100644 --- a/Mage.Sets/src/mage/cards/g/GrothamaAllDevouring.java +++ b/Mage.Sets/src/mage/cards/g/GrothamaAllDevouring.java @@ -176,12 +176,12 @@ class GrothamaAllDevouringWatcher extends Watcher { @Override public void watch(GameEvent event, Game game) { - if (event.getType() != GameEvent.EventType.DAMAGED_CREATURE) { + if (event.getType() != GameEvent.EventType.DAMAGED_PERMANENT) { return; } UUID damageControllerId = game.getControllerId(event.getSourceId()); Permanent damaged = game.getPermanentOrLKIBattlefield(event.getTargetId()); - if (damaged == null || damageControllerId == null) { + if (damaged == null || !damaged.isCreature() || damageControllerId == null) { return; } MageObjectReference mor = new MageObjectReference(damaged, game); diff --git a/Mage.Sets/src/mage/cards/h/HanSoloScrumrat.java b/Mage.Sets/src/mage/cards/h/HanSoloScrumrat.java index 7eb615b851..3d963281ef 100644 --- a/Mage.Sets/src/mage/cards/h/HanSoloScrumrat.java +++ b/Mage.Sets/src/mage/cards/h/HanSoloScrumrat.java @@ -80,9 +80,8 @@ class HanSoloScrumratTriggeredAbility extends TriggeredAbilityImpl { @Override public boolean checkEventType(GameEvent event, Game game) { - return event.getType() == GameEvent.EventType.DAMAGED_CREATURE - || event.getType() == GameEvent.EventType.DAMAGED_PLAYER - || event.getType() == GameEvent.EventType.DAMAGED_PLANESWALKER; + return event.getType() == GameEvent.EventType.DAMAGED_PERMANENT + || event.getType() == GameEvent.EventType.DAMAGED_PLAYER; } @Override diff --git a/Mage.Sets/src/mage/cards/h/HedronFieldPurists.java b/Mage.Sets/src/mage/cards/h/HedronFieldPurists.java index b99c6fe902..9e3bc541d4 100644 --- a/Mage.Sets/src/mage/cards/h/HedronFieldPurists.java +++ b/Mage.Sets/src/mage/cards/h/HedronFieldPurists.java @@ -88,9 +88,9 @@ class HedronFieldPuristsEffect extends PreventionEffectImpl { return super.applies(event, source, game); } - if (event.getType() == GameEvent.EventType.DAMAGE_CREATURE) { + if (event.getType() == GameEvent.EventType.DAMAGE_PERMANENT) { Permanent permanent = game.getPermanent(event.getTargetId()); - if (permanent != null && permanent.isControlledBy(source.getControllerId())) { + if (permanent != null && permanent.isCreature() && permanent.isControlledBy(source.getControllerId())) { return super.applies(event, source, game); } } diff --git a/Mage.Sets/src/mage/cards/h/HighPriestOfPenance.java b/Mage.Sets/src/mage/cards/h/HighPriestOfPenance.java index ee90375f11..740ab3f568 100644 --- a/Mage.Sets/src/mage/cards/h/HighPriestOfPenance.java +++ b/Mage.Sets/src/mage/cards/h/HighPriestOfPenance.java @@ -60,7 +60,7 @@ class HighPriestOfPenanceTriggeredAbility extends TriggeredAbilityImpl { @Override public boolean checkEventType(GameEvent event, Game game) { - return event.getType() == GameEvent.EventType.DAMAGED_CREATURE; + return event.getType() == GameEvent.EventType.DAMAGED_PERMANENT; } @Override diff --git a/Mage.Sets/src/mage/cards/h/HotSoup.java b/Mage.Sets/src/mage/cards/h/HotSoup.java index 9525ad94fb..6121b4f64a 100644 --- a/Mage.Sets/src/mage/cards/h/HotSoup.java +++ b/Mage.Sets/src/mage/cards/h/HotSoup.java @@ -69,7 +69,7 @@ class HotSoupTriggeredAbility extends TriggeredAbilityImpl { @Override public boolean checkEventType(GameEvent event, Game game) { - return event.getType() == GameEvent.EventType.DAMAGED_CREATURE; + return event.getType() == GameEvent.EventType.DAMAGED_PERMANENT; } @Override diff --git a/Mage.Sets/src/mage/cards/h/HuntersInsight.java b/Mage.Sets/src/mage/cards/h/HuntersInsight.java index 87315f363c..c15b511947 100644 --- a/Mage.Sets/src/mage/cards/h/HuntersInsight.java +++ b/Mage.Sets/src/mage/cards/h/HuntersInsight.java @@ -13,7 +13,6 @@ import mage.constants.Outcome; import mage.game.Game; import mage.game.events.DamagedEvent; import mage.game.events.GameEvent; -import mage.game.events.GameEvent.EventType; import mage.game.permanent.Permanent; import mage.target.common.TargetControlledCreaturePermanent; @@ -92,7 +91,7 @@ class HuntersInsightTriggeredAbility extends DelayedTriggeredAbility { @Override public boolean checkEventType(GameEvent event, Game game) { return event.getType() == GameEvent.EventType.DAMAGED_PLAYER - || event.getType() == GameEvent.EventType.DAMAGED_PLANESWALKER; + || event.getType() == GameEvent.EventType.DAMAGED_PERMANENT; } @Override @@ -101,6 +100,10 @@ class HuntersInsightTriggeredAbility extends DelayedTriggeredAbility { || !((DamagedEvent) event).isCombatDamage()) { return false; } + Permanent permanent = game.getPermanent(event.getTargetId()); + if (permanent != null && !permanent.isPlaneswalker()) { + return false; + } this.getEffects().clear(); this.addEffect(new DrawCardSourceControllerEffect(event.getAmount())); return true; diff --git a/Mage.Sets/src/mage/cards/i/ImpactResonance.java b/Mage.Sets/src/mage/cards/i/ImpactResonance.java index 8003e78777..ab458592a2 100644 --- a/Mage.Sets/src/mage/cards/i/ImpactResonance.java +++ b/Mage.Sets/src/mage/cards/i/ImpactResonance.java @@ -96,8 +96,7 @@ class GreatestAmountOfDamageWatcher extends Watcher { @Override public void watch(GameEvent event, Game game) { switch(event.getType()) { - case DAMAGED_CREATURE: - case DAMAGED_PLANESWALKER: + case DAMAGED_PERMANENT: case DAMAGED_PLAYER: if (event.getAmount() > damageAmount) { damageAmount = event.getAmount(); diff --git a/Mage.Sets/src/mage/cards/i/ImpulsiveManeuvers.java b/Mage.Sets/src/mage/cards/i/ImpulsiveManeuvers.java index e0183c6a83..125626947f 100644 --- a/Mage.Sets/src/mage/cards/i/ImpulsiveManeuvers.java +++ b/Mage.Sets/src/mage/cards/i/ImpulsiveManeuvers.java @@ -68,8 +68,7 @@ class ImpulsiveManeuversEffect extends PreventionEffectImpl { @Override public boolean checksEventType(GameEvent event, Game game) { - return event.getType() == GameEvent.EventType.DAMAGE_CREATURE || - event.getType() == GameEvent.EventType.DAMAGE_PLANESWALKER || + return event.getType() == GameEvent.EventType.DAMAGE_PERMANENT || event.getType() == GameEvent.EventType.DAMAGE_PLAYER; } diff --git a/Mage.Sets/src/mage/cards/i/InquisitorsFlail.java b/Mage.Sets/src/mage/cards/i/InquisitorsFlail.java index da0965d151..3bc2200e3e 100644 --- a/Mage.Sets/src/mage/cards/i/InquisitorsFlail.java +++ b/Mage.Sets/src/mage/cards/i/InquisitorsFlail.java @@ -1,7 +1,6 @@ package mage.cards.i; -import java.util.UUID; import mage.abilities.Ability; import mage.abilities.common.SimpleStaticAbility; import mage.abilities.costs.mana.GenericManaCost; @@ -9,25 +8,22 @@ import mage.abilities.effects.ReplacementEffectImpl; import mage.abilities.keyword.EquipAbility; import mage.cards.CardImpl; import mage.cards.CardSetInfo; -import mage.constants.CardType; -import mage.constants.SubType; -import mage.constants.Duration; -import mage.constants.Outcome; -import mage.constants.Zone; +import mage.constants.*; import mage.game.Game; -import mage.game.events.DamageCreatureEvent; import mage.game.events.DamageEvent; import mage.game.events.GameEvent; import mage.game.permanent.Permanent; import mage.util.CardUtil; +import java.util.UUID; + /** * @author nantuko */ public final class InquisitorsFlail extends CardImpl { public InquisitorsFlail(UUID ownerId, CardSetInfo setInfo) { - super(ownerId,setInfo,new CardType[]{CardType.ARTIFACT},"{2}"); + super(ownerId, setInfo, new CardType[]{CardType.ARTIFACT}, "{2}"); this.subtype.add(SubType.EQUIPMENT); // If equipped creature would deal combat damage, it deals double that damage instead. @@ -67,20 +63,13 @@ class InquisitorsFlailEffect extends ReplacementEffectImpl { @Override public boolean checksEventType(GameEvent event, Game game) { - return event.getType() == GameEvent.EventType.DAMAGE_CREATURE || - event.getType() == GameEvent.EventType.DAMAGE_PLANESWALKER || + return event.getType() == GameEvent.EventType.DAMAGE_PERMANENT || event.getType() == GameEvent.EventType.DAMAGE_PLAYER; } @Override public boolean applies(GameEvent event, Ability source, Game game) { - boolean isCombat = false; - if (event instanceof DamageCreatureEvent) { - isCombat = ((DamageCreatureEvent) event).isCombatDamage(); - } else if (event instanceof DamageEvent) { - isCombat = ((DamageEvent) event).isCombatDamage(); - } - if (isCombat) { + if (((DamageEvent) event).isCombatDamage()) { Permanent equipment = game.getPermanent(source.getSourceId()); if (equipment != null && equipment.getAttachedTo() != null) { UUID attachedTo = equipment.getAttachedTo(); diff --git a/Mage.Sets/src/mage/cards/i/InsultInjury.java b/Mage.Sets/src/mage/cards/i/InsultInjury.java index 4fca4d7fb5..ea490acee1 100644 --- a/Mage.Sets/src/mage/cards/i/InsultInjury.java +++ b/Mage.Sets/src/mage/cards/i/InsultInjury.java @@ -72,9 +72,8 @@ class InsultDoubleDamageEffect extends ReplacementEffectImpl { @Override public boolean checksEventType(GameEvent event, Game game) { - return event.getType() == GameEvent.EventType.DAMAGE_CREATURE - || event.getType() == GameEvent.EventType.DAMAGE_PLAYER - || event.getType() == GameEvent.EventType.DAMAGE_PLANESWALKER; + return event.getType() == GameEvent.EventType.DAMAGE_PLAYER + || event.getType() == GameEvent.EventType.DAMAGE_PERMANENT; } @Override diff --git a/Mage.Sets/src/mage/cards/j/JadeMonolith.java b/Mage.Sets/src/mage/cards/j/JadeMonolith.java index e51b283adc..51fa65d4bc 100644 --- a/Mage.Sets/src/mage/cards/j/JadeMonolith.java +++ b/Mage.Sets/src/mage/cards/j/JadeMonolith.java @@ -93,15 +93,13 @@ class JadeMonolithRedirectionEffect extends ReplacementEffectImpl { @Override public boolean checksEventType(GameEvent event, Game game) { - return event.getType() == GameEvent.EventType.DAMAGE_CREATURE; + return event.getType() == EventType.DAMAGE_PERMANENT; } @Override public boolean applies(GameEvent event, Ability source, Game game) { - if (event.getSourceId().equals(targetSource.getFirstTarget()) && event.getTargetId().equals(source.getFirstTarget())) { - return true; - } - return false; + return event.getSourceId().equals(targetSource.getFirstTarget()) + && event.getTargetId().equals(source.getFirstTarget()); } } diff --git a/Mage.Sets/src/mage/cards/j/JayaVeneratedFiremage.java b/Mage.Sets/src/mage/cards/j/JayaVeneratedFiremage.java index 8805450e1b..f124de4b77 100644 --- a/Mage.Sets/src/mage/cards/j/JayaVeneratedFiremage.java +++ b/Mage.Sets/src/mage/cards/j/JayaVeneratedFiremage.java @@ -64,8 +64,7 @@ class JayaVeneratedFiremageEffect extends ReplacementEffectImpl { @Override public boolean checksEventType(GameEvent event, Game game) { switch (event.getType()) { - case DAMAGE_CREATURE: - case DAMAGE_PLANESWALKER: + case DAMAGE_PERMANENT: case DAMAGE_PLAYER: return true; default: diff --git a/Mage.Sets/src/mage/cards/j/Justice.java b/Mage.Sets/src/mage/cards/j/Justice.java index 854eb20032..72342d4c48 100644 --- a/Mage.Sets/src/mage/cards/j/Justice.java +++ b/Mage.Sets/src/mage/cards/j/Justice.java @@ -67,9 +67,8 @@ class JusticeTriggeredAbility extends TriggeredAbilityImpl { @Override public boolean checkEventType(GameEvent event, Game game) { - return event.getType() == GameEvent.EventType.DAMAGED_CREATURE - || event.getType() == GameEvent.EventType.DAMAGED_PLAYER - || event.getType() == GameEvent.EventType.DAMAGED_PLANESWALKER; + return event.getType() == GameEvent.EventType.DAMAGED_PERMANENT + || event.getType() == GameEvent.EventType.DAMAGED_PLAYER; } @Override diff --git a/Mage.Sets/src/mage/cards/k/KamiOfTheHonoredDead.java b/Mage.Sets/src/mage/cards/k/KamiOfTheHonoredDead.java index 4c0f016a27..38a0f9275f 100644 --- a/Mage.Sets/src/mage/cards/k/KamiOfTheHonoredDead.java +++ b/Mage.Sets/src/mage/cards/k/KamiOfTheHonoredDead.java @@ -68,7 +68,7 @@ class KamiOfTheHonoredDeadTriggeredAbility extends TriggeredAbilityImpl { @Override public boolean checkEventType(GameEvent event, Game game) { - return event.getType() == GameEvent.EventType.DAMAGED_CREATURE; + return event.getType() == GameEvent.EventType.DAMAGED_PERMANENT; } @Override diff --git a/Mage.Sets/src/mage/cards/k/KazarovSengirPureblood.java b/Mage.Sets/src/mage/cards/k/KazarovSengirPureblood.java index 54c081b779..ac9021f9df 100644 --- a/Mage.Sets/src/mage/cards/k/KazarovSengirPureblood.java +++ b/Mage.Sets/src/mage/cards/k/KazarovSengirPureblood.java @@ -75,22 +75,15 @@ class KazarovSengirPurebloodTriggeredAbility extends TriggeredAbilityImpl { @Override public boolean checkEventType(GameEvent event, Game game) { - return event.getType() == GameEvent.EventType.DAMAGED_CREATURE; + return event.getType() == GameEvent.EventType.DAMAGED_PERMANENT; } @Override public boolean checkTrigger(GameEvent event, Game game) { - if (event == null) { - return false; - } Permanent permanent = game.getPermanentOrLKIBattlefield(event.getTargetId()); - if (permanent == null) { - return false; - } - if (permanent.isControlledBy(this.getControllerId())) { - return false; - } - return true; + return permanent!=null + && permanent.isCreature() + && game.getOpponents(permanent.getControllerId()).contains(this.getControllerId()); } @Override diff --git a/Mage.Sets/src/mage/cards/k/KillSuitCultist.java b/Mage.Sets/src/mage/cards/k/KillSuitCultist.java index 4a3c27b84c..00dfe7fd27 100644 --- a/Mage.Sets/src/mage/cards/k/KillSuitCultist.java +++ b/Mage.Sets/src/mage/cards/k/KillSuitCultist.java @@ -72,7 +72,7 @@ class KillSuitCultistEffect extends ReplacementEffectImpl { @Override public boolean checksEventType(GameEvent event, Game game) { - return event.getType() == GameEvent.EventType.DAMAGE_CREATURE; + return event.getType() == EventType.DAMAGE_PERMANENT; } @Override diff --git a/Mage.Sets/src/mage/cards/k/KithkinArmor.java b/Mage.Sets/src/mage/cards/k/KithkinArmor.java index ababcbe641..8dd7a95f1b 100644 --- a/Mage.Sets/src/mage/cards/k/KithkinArmor.java +++ b/Mage.Sets/src/mage/cards/k/KithkinArmor.java @@ -2,6 +2,7 @@ package mage.cards.k; import java.util.UUID; import mage.constants.SubType; +import mage.game.events.DamageEvent; import mage.target.common.TargetCreaturePermanent; import mage.abilities.Ability; import mage.abilities.common.SimpleActivatedAbility; @@ -20,7 +21,6 @@ import mage.constants.CardType; import mage.constants.Duration; import mage.constants.Zone; import mage.game.Game; -import mage.game.events.DamageCreatureEvent; import mage.game.events.GameEvent; import mage.game.permanent.Permanent; import mage.target.TargetSource; @@ -155,11 +155,11 @@ class KithkinArmorPreventionEffect extends PreventionEffectImpl { @Override public boolean applies(GameEvent event, Ability source, Game game) { if (super.applies(event, source, game) - && event instanceof DamageCreatureEvent + && event instanceof DamageEvent && event.getAmount() > 0 && !this.used) { UUID enchantedCreatureId = (UUID) game.getState().getValue(source.getSourceId().toString() + "attachedToPermanent"); - DamageCreatureEvent damageEvent = (DamageCreatureEvent) event; + DamageEvent damageEvent = (DamageEvent) event; if (enchantedCreatureId != null && event.getTargetId().equals(enchantedCreatureId) && damageEvent.getSourceId().equals(source.getFirstTarget())) { diff --git a/Mage.Sets/src/mage/cards/k/KiyomaroFirstToStand.java b/Mage.Sets/src/mage/cards/k/KiyomaroFirstToStand.java index 5e4e7319fd..cf00b5ed59 100644 --- a/Mage.Sets/src/mage/cards/k/KiyomaroFirstToStand.java +++ b/Mage.Sets/src/mage/cards/k/KiyomaroFirstToStand.java @@ -89,8 +89,7 @@ class KiyomaroFirstToStandDealsDamageTriggeredAbility extends TriggeredAbilityIm @Override public boolean checkEventType(GameEvent event, Game game) { return event.getType() == GameEvent.EventType.DAMAGED_PLAYER - || event.getType() == GameEvent.EventType.DAMAGED_CREATURE - || event.getType() == GameEvent.EventType.DAMAGED_PLANESWALKER; + || event.getType() == GameEvent.EventType.DAMAGED_PERMANENT; } @Override diff --git a/Mage.Sets/src/mage/cards/k/KorChant.java b/Mage.Sets/src/mage/cards/k/KorChant.java index b0219182e1..7b14735d97 100644 --- a/Mage.Sets/src/mage/cards/k/KorChant.java +++ b/Mage.Sets/src/mage/cards/k/KorChant.java @@ -76,7 +76,7 @@ class KorChantEffect extends RedirectionEffect { @Override public boolean checksEventType(GameEvent event, Game game) { - return event.getType() == GameEvent.EventType.DAMAGE_CREATURE; + return event.getType() == GameEvent.EventType.DAMAGE_PERMANENT; } @Override diff --git a/Mage.Sets/src/mage/cards/k/KorDirge.java b/Mage.Sets/src/mage/cards/k/KorDirge.java index 3c9838a95e..2d66c71f3c 100644 --- a/Mage.Sets/src/mage/cards/k/KorDirge.java +++ b/Mage.Sets/src/mage/cards/k/KorDirge.java @@ -76,7 +76,7 @@ class KorDirgeEffect extends RedirectionEffect { @Override public boolean checksEventType(GameEvent event, Game game) { - return event.getType() == GameEvent.EventType.DAMAGE_CREATURE; + return event.getType() == GameEvent.EventType.DAMAGE_PERMANENT; } @Override diff --git a/Mage.Sets/src/mage/cards/k/KrovikanVampire.java b/Mage.Sets/src/mage/cards/k/KrovikanVampire.java index 053e2239df..62c46d6957 100644 --- a/Mage.Sets/src/mage/cards/k/KrovikanVampire.java +++ b/Mage.Sets/src/mage/cards/k/KrovikanVampire.java @@ -1,8 +1,5 @@ package mage.cards.k; -import java.util.HashSet; -import java.util.Set; -import java.util.UUID; import mage.MageInt; import mage.abilities.Ability; import mage.abilities.DelayedTriggeredAbility; @@ -11,26 +8,22 @@ import mage.abilities.condition.Condition; import mage.abilities.effects.Effect; import mage.abilities.effects.OneShotEffect; import mage.abilities.effects.common.SacrificeTargetEffect; -import mage.constants.SubType; import mage.cards.CardImpl; import mage.cards.CardSetInfo; -import mage.constants.CardType; -import mage.constants.Duration; -import mage.constants.Outcome; -import mage.constants.TargetController; -import mage.constants.WatcherScope; -import mage.constants.Zone; +import mage.constants.*; import mage.game.Game; import mage.game.events.GameEvent; -import mage.game.events.GameEvent.EventType; import mage.game.events.ZoneChangeEvent; import mage.game.permanent.Permanent; import mage.players.Player; import mage.target.targetpointer.FixedTarget; import mage.watchers.Watcher; +import java.util.HashSet; +import java.util.Set; +import java.util.UUID; + /** - * * @author jeffwadsworth */ public final class KrovikanVampire extends CardImpl { @@ -149,10 +142,15 @@ class KrovikanVampireCreaturesDamagedWatcher extends Watcher { @Override public void watch(GameEvent event, Game game) { - if (event.getType() == GameEvent.EventType.DAMAGED_CREATURE - && sourceId.equals(event.getSourceId())) { - damagedBySource.add(event.getTargetId()); + if (event.getType() != GameEvent.EventType.DAMAGED_PERMANENT + || !sourceId.equals(event.getSourceId())) { + return; } + Permanent permanent = game.getPermanent(event.getTargetId()); + if (permanent == null || !permanent.isCreature()) { + return; + } + damagedBySource.add(event.getTargetId()); } public Set getDamagedBySource() { diff --git a/Mage.Sets/src/mage/cards/k/KumanosBlessing.java b/Mage.Sets/src/mage/cards/k/KumanosBlessing.java index e032b6d1f6..282c12f1cb 100644 --- a/Mage.Sets/src/mage/cards/k/KumanosBlessing.java +++ b/Mage.Sets/src/mage/cards/k/KumanosBlessing.java @@ -13,10 +13,8 @@ import mage.cards.CardSetInfo; import mage.constants.*; import mage.game.Game; import mage.game.events.GameEvent; -import mage.game.events.GameEvent.EventType; import mage.game.events.ZoneChangeEvent; import mage.game.permanent.Permanent; -import mage.players.Player; import mage.target.TargetPermanent; import mage.target.common.TargetCreaturePermanent; import mage.watchers.Watcher; @@ -110,12 +108,14 @@ class DamagedByEnchantedWatcher extends Watcher { @Override public void watch(GameEvent event, Game game) { - if (event.getType() == GameEvent.EventType.DAMAGED_CREATURE) { + if (event.getType() == GameEvent.EventType.DAMAGED_PERMANENT) { Permanent enchantment = game.getPermanent(this.getSourceId()); if (enchantment != null && enchantment.isAttachedTo(event.getSourceId())) { - MageObjectReference mor = new MageObjectReference(event.getTargetId(), game); - damagedCreatures.add(mor); - + Permanent permanent = game.getPermanent(event.getTargetId()); + if (permanent != null && permanent.isCreature()) { + MageObjectReference mor = new MageObjectReference(event.getTargetId(), game); + damagedCreatures.add(mor); + } } } } diff --git a/Mage.Sets/src/mage/cards/k/KusariGama.java b/Mage.Sets/src/mage/cards/k/KusariGama.java index 1d7345d908..3a99387f23 100644 --- a/Mage.Sets/src/mage/cards/k/KusariGama.java +++ b/Mage.Sets/src/mage/cards/k/KusariGama.java @@ -79,7 +79,7 @@ class KusariGamaAbility extends TriggeredAbilityImpl { @Override public boolean checkEventType(GameEvent event, Game game) { - return event.getType() == GameEvent.EventType.DAMAGED_CREATURE; + return event.getType() == GameEvent.EventType.DAMAGED_PERMANENT; } @Override diff --git a/Mage.Sets/src/mage/cards/l/LashknifeBarrier.java b/Mage.Sets/src/mage/cards/l/LashknifeBarrier.java index 8d25e0ce91..620f2fd552 100644 --- a/Mage.Sets/src/mage/cards/l/LashknifeBarrier.java +++ b/Mage.Sets/src/mage/cards/l/LashknifeBarrier.java @@ -71,13 +71,13 @@ class LashknifeBarrierEffect extends ReplacementEffectImpl { @Override public boolean checksEventType(GameEvent event, Game game) { - return event.getType() == GameEvent.EventType.DAMAGE_CREATURE; + return event.getType() == EventType.DAMAGE_PERMANENT; } @Override public boolean applies(GameEvent event, Ability source, Game game) { Permanent creature = game.getPermanent(event.getTargetId()); - return creature != null && creature.isControlledBy(source.getControllerId()); + return creature != null && creature.isPlaneswalker() && creature.isControlledBy(source.getControllerId()); } } diff --git a/Mage.Sets/src/mage/cards/l/LeylinePhantom.java b/Mage.Sets/src/mage/cards/l/LeylinePhantom.java index 7dbd70df82..8fd8e7f965 100644 --- a/Mage.Sets/src/mage/cards/l/LeylinePhantom.java +++ b/Mage.Sets/src/mage/cards/l/LeylinePhantom.java @@ -58,7 +58,8 @@ class LeylinePhantomTriggeredAbility extends TriggeredAbilityImpl { @Override public boolean checkEventType(GameEvent event, Game game) { - return event.getType() == GameEvent.EventType.DAMAGED_CREATURE || event.getType() == GameEvent.EventType.DAMAGED_PLANESWALKER || event.getType() == GameEvent.EventType.DAMAGED_PLAYER; + return event.getType() == GameEvent.EventType.DAMAGED_PERMANENT + || event.getType() == GameEvent.EventType.DAMAGED_PLAYER; } @Override diff --git a/Mage.Sets/src/mage/cards/l/Lichenthrope.java b/Mage.Sets/src/mage/cards/l/Lichenthrope.java index 8d9d96d0fe..da95aba932 100644 --- a/Mage.Sets/src/mage/cards/l/Lichenthrope.java +++ b/Mage.Sets/src/mage/cards/l/Lichenthrope.java @@ -18,7 +18,7 @@ import mage.constants.TargetController; import mage.constants.Zone; import mage.counters.CounterType; import mage.game.Game; -import mage.game.events.DamageCreatureEvent; +import mage.game.events.DamageEvent; import mage.game.events.GameEvent; import mage.game.permanent.Permanent; @@ -66,7 +66,7 @@ class LichenthropeEffect extends ReplacementEffectImpl { @Override public boolean replaceEvent(GameEvent event, Ability source, Game game) { - DamageCreatureEvent damageEvent = (DamageCreatureEvent) event; + DamageEvent damageEvent = (DamageEvent) event; Permanent p = game.getPermanent(source.getSourceId()); if (p != null) { p.addCounters(CounterType.M1M1.createInstance(damageEvent.getAmount()), source.getControllerId(), source, game); @@ -76,7 +76,7 @@ class LichenthropeEffect extends ReplacementEffectImpl { @Override public boolean checksEventType(GameEvent event, Game game) { - return event.getType() == GameEvent.EventType.DAMAGE_CREATURE; + return event.getType() == GameEvent.EventType.DAMAGE_PERMANENT; } @Override diff --git a/Mage.Sets/src/mage/cards/l/LightOfSanction.java b/Mage.Sets/src/mage/cards/l/LightOfSanction.java index 9e7b26ca19..af50bd818a 100644 --- a/Mage.Sets/src/mage/cards/l/LightOfSanction.java +++ b/Mage.Sets/src/mage/cards/l/LightOfSanction.java @@ -54,9 +54,9 @@ class LightOfSanctionEffect extends PreventionEffectImpl { @Override public boolean applies(GameEvent event, Ability source, Game game) { - if (event.getType() == GameEvent.EventType.DAMAGE_CREATURE) { + if (event.getType() == GameEvent.EventType.DAMAGE_PERMANENT) { Permanent permanent = game.getPermanent(event.getTargetId()); - if (permanent != null && permanent.isControlledBy(source.getControllerId())) { + if (permanent != null && permanent.isCreature() && permanent.isControlledBy(source.getControllerId())) { MageObject damageSource = game.getObject(event.getSourceId()); if (damageSource instanceof Controllable) { return ((Controllable) damageSource).isControlledBy(source.getControllerId()); diff --git a/Mage.Sets/src/mage/cards/l/Luminesce.java b/Mage.Sets/src/mage/cards/l/Luminesce.java index 7e3ada0d93..7aa6198705 100644 --- a/Mage.Sets/src/mage/cards/l/Luminesce.java +++ b/Mage.Sets/src/mage/cards/l/Luminesce.java @@ -56,8 +56,7 @@ class LuminescePreventionEffect extends PreventionEffectImpl { public boolean applies(GameEvent event, Ability source, Game game) { if (super.applies(event, source, game)) { if (event.getType() == GameEvent.EventType.DAMAGE_PLAYER - || event.getType() == GameEvent.EventType.DAMAGE_CREATURE - || event.getType() == GameEvent.EventType.DAMAGE_PLANESWALKER) { + || event.getType() == GameEvent.EventType.DAMAGE_PERMANENT) { MageObject sourceObject = game.getObject(event.getSourceId()); if (sourceObject != null && (sourceObject.getColor(game).shares(ObjectColor.BLACK) || sourceObject.getColor(game).shares(ObjectColor.RED))) { diff --git a/Mage.Sets/src/mage/cards/m/MasterOfCruelties.java b/Mage.Sets/src/mage/cards/m/MasterOfCruelties.java index cb0dd27840..78dcd13103 100644 --- a/Mage.Sets/src/mage/cards/m/MasterOfCruelties.java +++ b/Mage.Sets/src/mage/cards/m/MasterOfCruelties.java @@ -150,9 +150,8 @@ class MasterOfCrueltiesNoDamageEffect extends ContinuousRuleModifyingEffectImpl @Override public boolean checksEventType(GameEvent event, Game game) { switch (event.getType()) { - case DAMAGE_CREATURE: + case DAMAGE_PERMANENT: case DAMAGE_PLAYER: - case DAMAGE_PLANESWALKER: return true; default: return false; diff --git a/Mage.Sets/src/mage/cards/m/MirrorwoodTreefolk.java b/Mage.Sets/src/mage/cards/m/MirrorwoodTreefolk.java index 0b4e763110..906b070e4c 100644 --- a/Mage.Sets/src/mage/cards/m/MirrorwoodTreefolk.java +++ b/Mage.Sets/src/mage/cards/m/MirrorwoodTreefolk.java @@ -73,7 +73,7 @@ class MirrorwoodTreefolkEffect extends RedirectionEffect { @Override public boolean checksEventType(GameEvent event, Game game) { - return event.getType() == GameEvent.EventType.DAMAGE_CREATURE; + return event.getType() == GameEvent.EventType.DAMAGE_PERMANENT; } @Override diff --git a/Mage.Sets/src/mage/cards/n/NestedGhoul.java b/Mage.Sets/src/mage/cards/n/NestedGhoul.java index b02044d0a8..bf65048e36 100644 --- a/Mage.Sets/src/mage/cards/n/NestedGhoul.java +++ b/Mage.Sets/src/mage/cards/n/NestedGhoul.java @@ -59,7 +59,7 @@ class NestedGhoulTriggeredAbility extends TriggeredAbilityImpl { @Override public boolean checkEventType(GameEvent event, Game game) { - return event.getType() == GameEvent.EventType.DAMAGED_CREATURE; + return event.getType() == GameEvent.EventType.DAMAGED_PERMANENT; } @Override diff --git a/Mage.Sets/src/mage/cards/n/NikoAris.java b/Mage.Sets/src/mage/cards/n/NikoAris.java index d6240a7374..2d5442fef7 100644 --- a/Mage.Sets/src/mage/cards/n/NikoAris.java +++ b/Mage.Sets/src/mage/cards/n/NikoAris.java @@ -156,8 +156,7 @@ class NikoArisDamageTriggeredAbility extends DelayedTriggeredAbility { public boolean checkEventType(GameEvent event, Game game) { switch (event.getType()) { case DAMAGED_PLAYER: - case DAMAGED_CREATURE: - case DAMAGED_PLANESWALKER: + case DAMAGED_PERMANENT: return true; } return false; diff --git a/Mage.Sets/src/mage/cards/n/NoblePurpose.java b/Mage.Sets/src/mage/cards/n/NoblePurpose.java index 44a79d138e..ff867527a5 100644 --- a/Mage.Sets/src/mage/cards/n/NoblePurpose.java +++ b/Mage.Sets/src/mage/cards/n/NoblePurpose.java @@ -55,9 +55,8 @@ class NoblePurposeTriggeredAbility extends TriggeredAbilityImpl { @Override public boolean checkEventType(GameEvent event, Game game) { - return event.getType() == GameEvent.EventType.DAMAGED_CREATURE - || event.getType() == GameEvent.EventType.DAMAGED_PLAYER - || event.getType() == GameEvent.EventType.DAMAGED_PLANESWALKER; + return event.getType() == GameEvent.EventType.DAMAGED_PERMANENT + || event.getType() == GameEvent.EventType.DAMAGED_PLAYER; } @Override diff --git a/Mage.Sets/src/mage/cards/o/OboshThePreypiercer.java b/Mage.Sets/src/mage/cards/o/OboshThePreypiercer.java index 8383689f01..f2a0ecb5f0 100644 --- a/Mage.Sets/src/mage/cards/o/OboshThePreypiercer.java +++ b/Mage.Sets/src/mage/cards/o/OboshThePreypiercer.java @@ -88,8 +88,7 @@ class OboshThePreypiercerEffect extends ReplacementEffectImpl { @Override public boolean checksEventType(GameEvent event, Game game) { return event.getType().equals(GameEvent.EventType.DAMAGE_PLAYER) - || event.getType().equals(GameEvent.EventType.DAMAGE_CREATURE) - || event.getType().equals(GameEvent.EventType.DAMAGE_PLANESWALKER); + || event.getType().equals(GameEvent.EventType.DAMAGED_PERMANENT); } @Override diff --git a/Mage.Sets/src/mage/cards/o/OpalEyeKondasYojimbo.java b/Mage.Sets/src/mage/cards/o/OpalEyeKondasYojimbo.java index 62807a8286..012724a3cc 100644 --- a/Mage.Sets/src/mage/cards/o/OpalEyeKondasYojimbo.java +++ b/Mage.Sets/src/mage/cards/o/OpalEyeKondasYojimbo.java @@ -83,8 +83,7 @@ class OpalEyeKondasYojimboRedirectionEffect extends ReplacementEffectImpl { @Override public boolean checksEventType(GameEvent event, Game game) { - return event.getType() == GameEvent.EventType.DAMAGE_CREATURE || - event.getType() == GameEvent.EventType.DAMAGE_PLANESWALKER || + return event.getType() == GameEvent.EventType.DAMAGE_PERMANENT || event.getType() == GameEvent.EventType.DAMAGE_PLAYER; } diff --git a/Mage.Sets/src/mage/cards/o/OraclesAttendants.java b/Mage.Sets/src/mage/cards/o/OraclesAttendants.java index 186e2653c9..b0dca23a9e 100644 --- a/Mage.Sets/src/mage/cards/o/OraclesAttendants.java +++ b/Mage.Sets/src/mage/cards/o/OraclesAttendants.java @@ -15,7 +15,7 @@ import mage.constants.Duration; import mage.constants.Outcome; import mage.constants.Zone; import mage.game.Game; -import mage.game.events.DamageCreatureEvent; +import mage.game.events.DamageEvent; import mage.game.events.GameEvent; import mage.game.events.GameEvent.EventType; import mage.game.permanent.Permanent; @@ -80,7 +80,7 @@ class OraclesAttendantsReplacementEffect extends ReplacementEffectImpl { @Override public boolean replaceEvent(GameEvent event, Ability source, Game game) { Permanent permanent = game.getPermanent(source.getSourceId()); - DamageCreatureEvent damageEvent = (DamageCreatureEvent) event; + DamageEvent damageEvent = (DamageEvent) event; if (permanent != null) { permanent.damage(damageEvent.getAmount(), damageEvent.getSourceId(), source, game, damageEvent.isCombatDamage(), damageEvent.isPreventable()); return true; @@ -90,7 +90,7 @@ class OraclesAttendantsReplacementEffect extends ReplacementEffectImpl { @Override public boolean checksEventType(GameEvent event, Game game) { - return event.getType() == GameEvent.EventType.DAMAGE_CREATURE; + return event.getType() == EventType.DAMAGE_PERMANENT; } @Override diff --git a/Mage.Sets/src/mage/cards/o/Overblaze.java b/Mage.Sets/src/mage/cards/o/Overblaze.java index c47b0204ef..09f45adf68 100644 --- a/Mage.Sets/src/mage/cards/o/Overblaze.java +++ b/Mage.Sets/src/mage/cards/o/Overblaze.java @@ -61,9 +61,8 @@ class OverblazeEffect extends ReplacementEffectImpl { @Override public boolean checksEventType(GameEvent event, Game game) { - return event.getType() == GameEvent.EventType.DAMAGE_CREATURE - || event.getType() == GameEvent.EventType.DAMAGE_PLAYER - || event.getType() == GameEvent.EventType.DAMAGE_PLANESWALKER; + return event.getType() == GameEvent.EventType.DAMAGE_PERMANENT + || event.getType() == GameEvent.EventType.DAMAGE_PLAYER; } @Override diff --git a/Mage.Sets/src/mage/cards/p/PaladinOfPrahv.java b/Mage.Sets/src/mage/cards/p/PaladinOfPrahv.java index 45bfa9e5ac..185d778a14 100644 --- a/Mage.Sets/src/mage/cards/p/PaladinOfPrahv.java +++ b/Mage.Sets/src/mage/cards/p/PaladinOfPrahv.java @@ -75,9 +75,8 @@ class PaladinOfPrahvTriggeredAbility extends DelayedTriggeredAbility { @Override public boolean checkEventType(GameEvent event, Game game) { switch(event.getType()) { - case DAMAGED_CREATURE: + case DAMAGED_PERMANENT: case DAMAGED_PLAYER: - case DAMAGED_PLANESWALKER: return true; } return false; diff --git a/Mage.Sets/src/mage/cards/p/PalisadeGiant.java b/Mage.Sets/src/mage/cards/p/PalisadeGiant.java index bb85add7e4..42f26f03da 100644 --- a/Mage.Sets/src/mage/cards/p/PalisadeGiant.java +++ b/Mage.Sets/src/mage/cards/p/PalisadeGiant.java @@ -75,9 +75,8 @@ class PalisadeGiantReplacementEffect extends ReplacementEffectImpl { @Override public boolean checksEventType(GameEvent event, Game game) { switch (event.getType()) { - case DAMAGE_CREATURE: + case DAMAGE_PERMANENT: case DAMAGE_PLAYER: - case DAMAGE_PLANESWALKER: return true; default: return false; @@ -89,7 +88,7 @@ class PalisadeGiantReplacementEffect extends ReplacementEffectImpl { if (event.getType() == GameEvent.EventType.DAMAGE_PLAYER && event.getPlayerId().equals(source.getControllerId())) { return true; } - if (event.getType() == GameEvent.EventType.DAMAGE_CREATURE || event.getType() == GameEvent.EventType.DAMAGE_PLANESWALKER) { + if (event.getType() == GameEvent.EventType.DAMAGE_PERMANENT) { Permanent targetPermanent = game.getPermanent(event.getTargetId()); Permanent sourcePermanent = game.getPermanent(source.getSourceId()); if (targetPermanent != null && diff --git a/Mage.Sets/src/mage/cards/p/PalladiaMorsTheRuiner.java b/Mage.Sets/src/mage/cards/p/PalladiaMorsTheRuiner.java index e32f033102..4b38ca8ff3 100644 --- a/Mage.Sets/src/mage/cards/p/PalladiaMorsTheRuiner.java +++ b/Mage.Sets/src/mage/cards/p/PalladiaMorsTheRuiner.java @@ -100,9 +100,8 @@ class PalladiaMorsTheRuinerWatcher extends Watcher { @Override public void watch(GameEvent event, Game game) { switch (event.getType()) { - case DAMAGED_CREATURE: + case DAMAGED_PERMANENT: case DAMAGED_PLAYER: - case DAMAGED_PLANESWALKER: break; default: return; diff --git a/Mage.Sets/src/mage/cards/p/PhyrexianNegator.java b/Mage.Sets/src/mage/cards/p/PhyrexianNegator.java index 56a803f6dd..3f22d7d60f 100644 --- a/Mage.Sets/src/mage/cards/p/PhyrexianNegator.java +++ b/Mage.Sets/src/mage/cards/p/PhyrexianNegator.java @@ -63,7 +63,7 @@ class PhyrexianNegatorTriggeredAbility extends TriggeredAbilityImpl { @Override public boolean checkEventType(GameEvent event, Game game) { - return event.getType() == GameEvent.EventType.DAMAGED_CREATURE; + return event.getType() == GameEvent.EventType.DAMAGED_PERMANENT; } @Override diff --git a/Mage.Sets/src/mage/cards/p/PhyrexianObliterator.java b/Mage.Sets/src/mage/cards/p/PhyrexianObliterator.java index 389587460f..7a31730446 100644 --- a/Mage.Sets/src/mage/cards/p/PhyrexianObliterator.java +++ b/Mage.Sets/src/mage/cards/p/PhyrexianObliterator.java @@ -66,7 +66,7 @@ class PhyrexianObliteratorTriggeredAbility extends TriggeredAbilityImpl { @Override public boolean checkEventType(GameEvent event, Game game) { - return event.getType() == GameEvent.EventType.DAMAGED_CREATURE; + return event.getType() == GameEvent.EventType.DAMAGED_PERMANENT; } @Override diff --git a/Mage.Sets/src/mage/cards/p/PhyrexianTotem.java b/Mage.Sets/src/mage/cards/p/PhyrexianTotem.java index 54c1bdcde9..5fb1dfdf75 100644 --- a/Mage.Sets/src/mage/cards/p/PhyrexianTotem.java +++ b/Mage.Sets/src/mage/cards/p/PhyrexianTotem.java @@ -98,7 +98,7 @@ class PhyrexianTotemTriggeredAbility extends TriggeredAbilityImpl { @Override public boolean checkEventType(GameEvent event, Game game) { - return event.getType() == GameEvent.EventType.DAMAGED_CREATURE; + return event.getType() == GameEvent.EventType.DAMAGED_PERMANENT; } @Override diff --git a/Mage.Sets/src/mage/cards/p/PhyrexianUnlife.java b/Mage.Sets/src/mage/cards/p/PhyrexianUnlife.java index 22120169f3..84bdcd712f 100644 --- a/Mage.Sets/src/mage/cards/p/PhyrexianUnlife.java +++ b/Mage.Sets/src/mage/cards/p/PhyrexianUnlife.java @@ -1,42 +1,34 @@ - package mage.cards.p; -import java.util.UUID; import mage.abilities.Ability; import mage.abilities.common.SimpleStaticAbility; import mage.abilities.effects.ReplacementEffectImpl; import mage.abilities.effects.common.continuous.DontLoseByZeroOrLessLifeEffect; -import mage.abilities.keyword.LifelinkAbility; import mage.cards.CardImpl; import mage.cards.CardSetInfo; import mage.constants.CardType; import mage.constants.Duration; import mage.constants.Outcome; -import mage.constants.Zone; -import mage.counters.CounterType; import mage.game.Game; -import mage.game.events.DamagePlayerEvent; -import mage.game.events.DamagedPlayerEvent; +import mage.game.events.DamageEvent; import mage.game.events.GameEvent; -import mage.game.permanent.Permanent; import mage.players.Player; +import java.util.UUID; + /** - * * @author BetaSteward */ public final class PhyrexianUnlife extends CardImpl { public PhyrexianUnlife(UUID ownerId, CardSetInfo setInfo) { - super(ownerId,setInfo,new CardType[]{CardType.ENCHANTMENT},"{2}{W}"); - + super(ownerId, setInfo, new CardType[]{CardType.ENCHANTMENT}, "{2}{W}"); // You don't lose the game for having 0 or less life. - this.addAbility(new SimpleStaticAbility(Zone.BATTLEFIELD, new DontLoseByZeroOrLessLifeEffect(Duration.WhileOnBattlefield))); + this.addAbility(new SimpleStaticAbility(new DontLoseByZeroOrLessLifeEffect(Duration.WhileOnBattlefield))); // As long as you have 0 or less life, all damage is dealt to you as though its source had infect. - this.addAbility(new SimpleStaticAbility(Zone.BATTLEFIELD, new PhyrexianUnlifeEffect2())); - + this.addAbility(new SimpleStaticAbility(new PhyrexianUnlifeEffect())); } private PhyrexianUnlife(final PhyrexianUnlife card) { @@ -49,72 +41,61 @@ public final class PhyrexianUnlife extends CardImpl { } } -class PhyrexianUnlifeEffect2 extends ReplacementEffectImpl { +class PhyrexianUnlifeEffect extends ReplacementEffectImpl { - int lastCheckedDamageStepNum = 0; - boolean startedWithLifeAboveZero = false; + private int lastCheckedDamageStepNum = 0; + private boolean startedWithLifeAboveZero = false; - public PhyrexianUnlifeEffect2() { + PhyrexianUnlifeEffect() { super(Duration.WhileOnBattlefield, Outcome.Benefit); staticText = "As long as you have 0 or less life, all damage is dealt to you as though its source had infect"; } - public PhyrexianUnlifeEffect2(final PhyrexianUnlifeEffect2 effect) { + private PhyrexianUnlifeEffect(final PhyrexianUnlifeEffect effect) { super(effect); this.lastCheckedDamageStepNum = effect.lastCheckedDamageStepNum; this.startedWithLifeAboveZero = effect.startedWithLifeAboveZero; } @Override - public PhyrexianUnlifeEffect2 copy() { - return new PhyrexianUnlifeEffect2(this); + public PhyrexianUnlifeEffect copy() { + return new PhyrexianUnlifeEffect(this); } @Override public boolean replaceEvent(GameEvent event, Ability source, Game game) { - DamagePlayerEvent damageEvent = (DamagePlayerEvent) event; - int actualDamage = damageEvent.getAmount(); - if (actualDamage > 0) { - Player player = game.getPlayer(damageEvent.getPlayerId()); - Permanent damageSource = game.getPermanent(damageEvent.getSourceId()); - player.addCounters(CounterType.POISON.createInstance(actualDamage), source.getControllerId(), source, game); - if (damageSource != null && damageSource.getAbilities().containsKey(LifelinkAbility.getInstance().getId())) { - Player controlPlayer = game.getPlayer(damageSource.getControllerId()); - controlPlayer.gainLife(actualDamage, game, source); - } - game.fireEvent(new DamagedPlayerEvent(damageEvent.getPlayerId(), damageEvent.getSourceId(), damageEvent.getPlayerId(), actualDamage, damageEvent.isCombatDamage())); - } + ((DamageEvent) event).setAsThoughInfect(true); return true; } - + @Override public boolean checksEventType(GameEvent event, Game game) { return event.getType() == GameEvent.EventType.DAMAGE_PLAYER; } - + @Override public boolean applies(GameEvent event, Ability source, Game game) { - if (event.getPlayerId().equals(source.getControllerId())) { - Player player = game.getPlayer(source.getControllerId()); - if (player != null) { - // The decision if the player has more than 0 life has to be checked only at start of a combat damage step - // and all damage in the same step has to be handled the same beause by the rules it's all done at once - if (((DamagePlayerEvent) event).isCombatDamage()) { - if (lastCheckedDamageStepNum != game.getState().getStepNum()) { - lastCheckedDamageStepNum = game.getState().getStepNum(); - startedWithLifeAboveZero = player.getLife() > 0; - } - if (startedWithLifeAboveZero) { - return false; - } - } - if (player.getLife() <= 0) { - return true; - } + if (!event.getPlayerId().equals(source.getControllerId())) { + return false; + } + Player player = game.getPlayer(source.getControllerId()); + if (player == null) { + return false; + } + // The decision if the player has more than 0 life has to be checked only at start of a combat damage step + // and all damage in the same step has to be handled the same beause by the rules it's all done at once + if (((DamageEvent) event).isCombatDamage()) { + if (lastCheckedDamageStepNum != game.getState().getStepNum()) { + lastCheckedDamageStepNum = game.getState().getStepNum(); + startedWithLifeAboveZero = player.getLife() > 0; + } + if (startedWithLifeAboveZero) { + return false; } } - + if (player.getLife() < 1) { + return true; + } return false; } - } diff --git a/Mage.Sets/src/mage/cards/p/Phytohydra.java b/Mage.Sets/src/mage/cards/p/Phytohydra.java index 44a4ec16c8..68ec49d7f1 100644 --- a/Mage.Sets/src/mage/cards/p/Phytohydra.java +++ b/Mage.Sets/src/mage/cards/p/Phytohydra.java @@ -11,7 +11,7 @@ import mage.cards.CardSetInfo; import mage.constants.*; import mage.counters.CounterType; import mage.game.Game; -import mage.game.events.DamageCreatureEvent; +import mage.game.events.DamageEvent; import mage.game.events.GameEvent; import mage.game.permanent.Permanent; @@ -55,7 +55,7 @@ class PhytohydraEffect extends ReplacementEffectImpl { @Override public boolean replaceEvent(GameEvent event, Ability source, Game game) { - DamageCreatureEvent damageEvent = (DamageCreatureEvent) event; + DamageEvent damageEvent = (DamageEvent) event; Permanent p = game.getPermanent(source.getSourceId()); if (p != null) { p.addCounters(CounterType.P1P1.createInstance(damageEvent.getAmount()), source.getControllerId(), source, game); @@ -65,7 +65,7 @@ class PhytohydraEffect extends ReplacementEffectImpl { @Override public boolean checksEventType(GameEvent event, Game game) { - return event.getType() == GameEvent.EventType.DAMAGE_CREATURE; + return event.getType() == GameEvent.EventType.DAMAGE_PERMANENT; } @Override diff --git a/Mage.Sets/src/mage/cards/p/PiousWarrior.java b/Mage.Sets/src/mage/cards/p/PiousWarrior.java index 3d1f0ee0a4..d2ec1767b5 100644 --- a/Mage.Sets/src/mage/cards/p/PiousWarrior.java +++ b/Mage.Sets/src/mage/cards/p/PiousWarrior.java @@ -13,9 +13,8 @@ import mage.constants.SubType; import mage.constants.Outcome; import mage.constants.Zone; import mage.game.Game; -import mage.game.events.DamagedCreatureEvent; +import mage.game.events.DamagedEvent; import mage.game.events.GameEvent; -import mage.game.events.GameEvent.EventType; import mage.players.Player; /** @@ -64,12 +63,12 @@ class PiousWarriorTriggeredAbility extends TriggeredAbilityImpl { @Override public boolean checkEventType(GameEvent event, Game game) { - return event.getType() == GameEvent.EventType.DAMAGED_CREATURE; + return event.getType() == GameEvent.EventType.DAMAGED_PERMANENT; } @Override public boolean checkTrigger(GameEvent event, Game game) { - if (event.getTargetId().equals(this.sourceId) && ((DamagedCreatureEvent)event).isCombatDamage() ) { + if (event.getTargetId().equals(this.sourceId) && ((DamagedEvent)event).isCombatDamage() ) { this.getEffects().get(0).setValue("damageAmount", event.getAmount()); return true; } diff --git a/Mage.Sets/src/mage/cards/p/PrismaticStrands.java b/Mage.Sets/src/mage/cards/p/PrismaticStrands.java index 41597c57dc..fa7530e69c 100644 --- a/Mage.Sets/src/mage/cards/p/PrismaticStrands.java +++ b/Mage.Sets/src/mage/cards/p/PrismaticStrands.java @@ -116,8 +116,7 @@ class PrismaticStrandsPreventionEffect extends PreventionEffectImpl { public boolean applies(GameEvent event, Ability source, Game game) { if (super.applies(event, source, game)) { if (event.getType() == GameEvent.EventType.DAMAGE_PLAYER - || event.getType() == GameEvent.EventType.DAMAGE_CREATURE - || event.getType() == GameEvent.EventType.DAMAGE_PLANESWALKER) { + || event.getType() == GameEvent.EventType.DAMAGE_PERMANENT) { MageObject sourceObject = game.getObject(event.getSourceId()); if (sourceObject != null && sourceObject.getColor(game).shares(this.color)) { return true; diff --git a/Mage.Sets/src/mage/cards/p/PutridWarrior.java b/Mage.Sets/src/mage/cards/p/PutridWarrior.java index dbe9d123ca..7ea5af224e 100644 --- a/Mage.Sets/src/mage/cards/p/PutridWarrior.java +++ b/Mage.Sets/src/mage/cards/p/PutridWarrior.java @@ -71,8 +71,8 @@ class PutridWarriorDealsDamageTriggeredAbility extends TriggeredAbilityImpl { @Override public boolean checkEventType(GameEvent event, Game game) { - return event.getType() == GameEvent.EventType.DAMAGED_PLAYER || event.getType() == GameEvent.EventType.DAMAGED_CREATURE - || event.getType() == GameEvent.EventType.DAMAGED_PLANESWALKER; + return event.getType() == GameEvent.EventType.DAMAGED_PLAYER + || event.getType() == GameEvent.EventType.DAMAGED_PERMANENT; } @Override diff --git a/Mage.Sets/src/mage/cards/p/PyromancersGauntlet.java b/Mage.Sets/src/mage/cards/p/PyromancersGauntlet.java index 74c2d5c465..416d45ff55 100644 --- a/Mage.Sets/src/mage/cards/p/PyromancersGauntlet.java +++ b/Mage.Sets/src/mage/cards/p/PyromancersGauntlet.java @@ -54,8 +54,7 @@ class PyromancersGauntletReplacementEffect extends ReplacementEffectImpl { @Override public boolean checksEventType(GameEvent event, Game game) { return event.getType() == GameEvent.EventType.DAMAGE_PLAYER - || event.getType() == GameEvent.EventType.DAMAGE_CREATURE - || event.getType() == GameEvent.EventType.DAMAGE_PLANESWALKER; + || event.getType() == GameEvent.EventType.DAMAGE_PERMANENT; } @Override diff --git a/Mage.Sets/src/mage/cards/p/PyromancersSwath.java b/Mage.Sets/src/mage/cards/p/PyromancersSwath.java index 78425bc185..64c9d4e69d 100644 --- a/Mage.Sets/src/mage/cards/p/PyromancersSwath.java +++ b/Mage.Sets/src/mage/cards/p/PyromancersSwath.java @@ -56,9 +56,8 @@ class PyromancersSwathReplacementEffect extends ReplacementEffectImpl { @Override public boolean checksEventType(GameEvent event, Game game) { switch (event.getType()) { - case DAMAGE_CREATURE: + case DAMAGE_PERMANENT: case DAMAGE_PLAYER: - case DAMAGE_PLANESWALKER: return true; default: return false; diff --git a/Mage.Sets/src/mage/cards/q/QuestForPureFlame.java b/Mage.Sets/src/mage/cards/q/QuestForPureFlame.java index 56567bf9b3..d2891e216e 100644 --- a/Mage.Sets/src/mage/cards/q/QuestForPureFlame.java +++ b/Mage.Sets/src/mage/cards/q/QuestForPureFlame.java @@ -106,9 +106,8 @@ class QuestForPureFlameEffect extends ReplacementEffectImpl { @Override public boolean checksEventType(GameEvent event, Game game) { - return event.getType() == GameEvent.EventType.DAMAGE_CREATURE - || event.getType() == GameEvent.EventType.DAMAGE_PLAYER - || event.getType() == GameEvent.EventType.DAMAGE_PLANESWALKER; + return event.getType() == GameEvent.EventType.DAMAGE_PERMANENT + || event.getType() == GameEvent.EventType.DAMAGE_PLAYER; } @Override diff --git a/Mage.Sets/src/mage/cards/r/RamThrough.java b/Mage.Sets/src/mage/cards/r/RamThrough.java index ee1eddbab7..0dbccc0a84 100644 --- a/Mage.Sets/src/mage/cards/r/RamThrough.java +++ b/Mage.Sets/src/mage/cards/r/RamThrough.java @@ -2,7 +2,6 @@ package mage.cards.r; import mage.abilities.Ability; import mage.abilities.effects.OneShotEffect; -import mage.abilities.keyword.DeathtouchAbility; import mage.abilities.keyword.TrampleAbility; import mage.cards.CardImpl; import mage.cards.CardSetInfo; @@ -17,8 +16,6 @@ import mage.target.common.TargetCreaturePermanent; import java.util.UUID; -import static mage.game.combat.CombatGroup.getLethalDamage; - /** * @author TheElk801 */ @@ -79,10 +76,7 @@ class RamThroughEffect extends OneShotEffect { if (!myPermanent.getAbilities().containsKey(TrampleAbility.getInstance().getId())) { return anotherPermanent.damage(power, myPermanent.getId(), source, game, false, true) > 0; } - int lethal = getLethalDamage(anotherPermanent, game); - if (myPermanent.getAbilities().containsKey(DeathtouchAbility.getInstance().getId())) { - lethal = Math.min(lethal, 1); - } + int lethal = anotherPermanent.getLethalDamage(myPermanent.getId(), game); lethal = Math.min(lethal, power); anotherPermanent.damage(lethal, myPermanent.getId(), source, game); Player player = game.getPlayer(anotherPermanent.getControllerId()); diff --git a/Mage.Sets/src/mage/cards/r/ReaperOfSheoldred.java b/Mage.Sets/src/mage/cards/r/ReaperOfSheoldred.java index 6892df8335..c831450626 100644 --- a/Mage.Sets/src/mage/cards/r/ReaperOfSheoldred.java +++ b/Mage.Sets/src/mage/cards/r/ReaperOfSheoldred.java @@ -66,7 +66,7 @@ class ReaperOfSheoldredTriggeredAbility extends TriggeredAbilityImpl { @Override public boolean checkEventType(GameEvent event, Game game) { - return event.getType() == GameEvent.EventType.DAMAGED_CREATURE; + return event.getType() == GameEvent.EventType.DAMAGED_PERMANENT; } @Override diff --git a/Mage.Sets/src/mage/cards/r/ReidaneGodOfTheWorthy.java b/Mage.Sets/src/mage/cards/r/ReidaneGodOfTheWorthy.java index 4b71765918..4acef9309d 100644 --- a/Mage.Sets/src/mage/cards/r/ReidaneGodOfTheWorthy.java +++ b/Mage.Sets/src/mage/cards/r/ReidaneGodOfTheWorthy.java @@ -175,8 +175,7 @@ class ValkmiraProtectorsShieldPreventionEffect extends PreventionEffectImpl { return isOpponent && source.isControlledBy(event.getTargetId()) && super.applies(event, source, game); - case DAMAGE_CREATURE: - case DAMAGE_PLANESWALKER: + case DAMAGE_PERMANENT: isOpponent = game.getOpponents(game.getControllerId(event.getSourceId())).contains(source.getControllerId()); Permanent permanent = game.getPermanent(event.getTargetId()); return isOpponent diff --git a/Mage.Sets/src/mage/cards/r/Repercussion.java b/Mage.Sets/src/mage/cards/r/Repercussion.java index dbb49d2798..1f3eff928d 100644 --- a/Mage.Sets/src/mage/cards/r/Repercussion.java +++ b/Mage.Sets/src/mage/cards/r/Repercussion.java @@ -55,15 +55,17 @@ class RepercussionTriggeredAbility extends TriggeredAbilityImpl { @Override public boolean checkEventType(GameEvent event, Game game) { - return event.getType() == GameEvent.EventType.DAMAGED_CREATURE; + return event.getType() == GameEvent.EventType.DAMAGED_PERMANENT; } @Override public boolean checkTrigger(GameEvent event, Game game) { - for (Effect effect : getEffects()) { - effect.setValue(PLAYER_DAMAGE_AMOUNT_KEY, event.getAmount()); - effect.setValue(TRIGGERING_CREATURE_KEY, new MageObjectReference(event.getTargetId(), game)); + Permanent permanent = game.getPermanent(event.getTargetId()); + if (permanent == null || !permanent.isCreature()) { + return false; } + getEffects().setValue(PLAYER_DAMAGE_AMOUNT_KEY, event.getAmount()); + getEffects().setValue(TRIGGERING_CREATURE_KEY, new MageObjectReference(event.getTargetId(), game)); return true; } diff --git a/Mage.Sets/src/mage/cards/r/Reverberation.java b/Mage.Sets/src/mage/cards/r/Reverberation.java index ce74ee4079..4a59ccffda 100644 --- a/Mage.Sets/src/mage/cards/r/Reverberation.java +++ b/Mage.Sets/src/mage/cards/r/Reverberation.java @@ -64,8 +64,7 @@ class ReverberationEffect extends ReplacementEffectImpl { @Override public boolean checksEventType(GameEvent event, Game game) { - return event.getType() == GameEvent.EventType.DAMAGE_CREATURE || - event.getType() == GameEvent.EventType.DAMAGE_PLANESWALKER || + return event.getType() == GameEvent.EventType.DAMAGE_PERMANENT || event.getType() == GameEvent.EventType.DAMAGE_PLAYER; } diff --git a/Mage.Sets/src/mage/cards/r/RiteOfPassage.java b/Mage.Sets/src/mage/cards/r/RiteOfPassage.java index b342e06277..03adcc80c1 100644 --- a/Mage.Sets/src/mage/cards/r/RiteOfPassage.java +++ b/Mage.Sets/src/mage/cards/r/RiteOfPassage.java @@ -62,7 +62,7 @@ class RiteOfPassageTriggeredAbility extends TriggeredAbilityImpl { @Override public boolean checkEventType(GameEvent event, Game game) { - return event.getType() == GameEvent.EventType.DAMAGED_CREATURE; + return event.getType() == GameEvent.EventType.DAMAGED_PERMANENT; } @Override @@ -70,10 +70,8 @@ class RiteOfPassageTriggeredAbility extends TriggeredAbilityImpl { UUID targetId = event.getTargetId(); Permanent permanent = game.getPermanent(targetId); if (permanent != null && filter.match(permanent, getSourceId(), getControllerId(), game)) { - for (Effect effect : this.getEffects()) { - effect.setTargetPointer(new FixedTarget(event.getTargetId())); - return true; - } + getEffects().setTargetPointer(new FixedTarget(event.getTargetId(), game)); + return true; } return false; } diff --git a/Mage.Sets/src/mage/cards/s/SavingGrace.java b/Mage.Sets/src/mage/cards/s/SavingGrace.java index e44fe7e5e6..741e49f40c 100644 --- a/Mage.Sets/src/mage/cards/s/SavingGrace.java +++ b/Mage.Sets/src/mage/cards/s/SavingGrace.java @@ -77,9 +77,8 @@ class SavingGraceReplacementEffect extends ReplacementEffectImpl { @Override public boolean checksEventType(GameEvent event, Game game) { switch (event.getType()) { - case DAMAGE_CREATURE: case DAMAGE_PLAYER: - case DAMAGE_PLANESWALKER: + case DAMAGE_PERMANENT: return true; default: return false; @@ -88,10 +87,10 @@ class SavingGraceReplacementEffect extends ReplacementEffectImpl { @Override public boolean applies(GameEvent event, Ability source, Game game) { - if (event.getType() == GameEvent.EventType.DAMAGE_PLAYER && event.getPlayerId().equals(source.getControllerId())) { - return true; + if (event.getType() == GameEvent.EventType.DAMAGE_PLAYER) { + return event.getPlayerId().equals(source.getControllerId()); } - if (event.getType() == GameEvent.EventType.DAMAGE_CREATURE || event.getType() == GameEvent.EventType.DAMAGE_PLANESWALKER) { + if (event.getType() == GameEvent.EventType.DAMAGE_PERMANENT) { Permanent targetPermanent = game.getPermanent(event.getTargetId()); if (targetPermanent != null && targetPermanent.isControlledBy(source.getControllerId())) { diff --git a/Mage.Sets/src/mage/cards/s/ShacklesOfTreachery.java b/Mage.Sets/src/mage/cards/s/ShacklesOfTreachery.java index ce86f7e659..12af6a0c8b 100644 --- a/Mage.Sets/src/mage/cards/s/ShacklesOfTreachery.java +++ b/Mage.Sets/src/mage/cards/s/ShacklesOfTreachery.java @@ -89,9 +89,8 @@ class ShacklesOfTreacheryTriggeredAbility extends TriggeredAbilityImpl { @Override public boolean checkEventType(GameEvent event, Game game) { - return event.getType() == GameEvent.EventType.DAMAGED_CREATURE - || event.getType() == GameEvent.EventType.DAMAGED_PLAYER - || event.getType() == GameEvent.EventType.DAMAGED_PLANESWALKER; + return event.getType() == GameEvent.EventType.DAMAGED_PERMANENT + || event.getType() == GameEvent.EventType.DAMAGED_PLAYER; } @Override diff --git a/Mage.Sets/src/mage/cards/s/ShamanEnKor.java b/Mage.Sets/src/mage/cards/s/ShamanEnKor.java index 1aebf0e245..f66e8fc807 100644 --- a/Mage.Sets/src/mage/cards/s/ShamanEnKor.java +++ b/Mage.Sets/src/mage/cards/s/ShamanEnKor.java @@ -95,7 +95,7 @@ class ShamanEnKorRedirectFromTargetEffect extends RedirectionEffect { @Override public boolean checksEventType(GameEvent event, Game game) { - return event.getType() == GameEvent.EventType.DAMAGE_CREATURE; + return event.getType() == EventType.DAMAGE_PERMANENT; } @Override diff --git a/Mage.Sets/src/mage/cards/s/ShieldDancer.java b/Mage.Sets/src/mage/cards/s/ShieldDancer.java index afcf974ff8..788c24f719 100644 --- a/Mage.Sets/src/mage/cards/s/ShieldDancer.java +++ b/Mage.Sets/src/mage/cards/s/ShieldDancer.java @@ -68,7 +68,7 @@ class ShieldDancerRedirectionEffect extends RedirectionEffect { @Override public boolean checksEventType(GameEvent event, Game game) { - return event.getType() == GameEvent.EventType.DAMAGE_CREATURE; + return event.getType() == EventType.DAMAGE_PERMANENT; } @Override diff --git a/Mage.Sets/src/mage/cards/s/ShrivelingRot.java b/Mage.Sets/src/mage/cards/s/ShrivelingRot.java index fd0089978a..2b2dc3c01b 100644 --- a/Mage.Sets/src/mage/cards/s/ShrivelingRot.java +++ b/Mage.Sets/src/mage/cards/s/ShrivelingRot.java @@ -1,12 +1,11 @@ package mage.cards.s; -import java.util.UUID; import mage.abilities.Ability; import mage.abilities.DelayedTriggeredAbility; import mage.abilities.Mode; -import mage.abilities.effects.OneShotEffect; import mage.abilities.effects.Effect; +import mage.abilities.effects.OneShotEffect; import mage.abilities.effects.common.CreateDelayedTriggeredAbilityEffect; import mage.abilities.effects.common.DestroyTargetEffect; import mage.abilities.keyword.EntwineAbility; @@ -18,24 +17,25 @@ import mage.constants.Outcome; import mage.constants.Zone; import mage.game.Game; import mage.game.events.GameEvent; +import mage.game.events.ZoneChangeEvent; import mage.game.permanent.Permanent; import mage.players.Player; import mage.target.targetpointer.FixedTarget; -import mage.game.events.ZoneChangeEvent; + +import java.util.UUID; /** - * * @author L_J */ public final class ShrivelingRot extends CardImpl { public ShrivelingRot(UUID ownerId, CardSetInfo setInfo) { - super(ownerId,setInfo,new CardType[]{CardType.INSTANT},"{2}{B}{B}"); + super(ownerId, setInfo, new CardType[]{CardType.INSTANT}, "{2}{B}{B}"); // Choose one - // Until end of turn, whenever a creature is dealt damage, destroy it. this.getSpellAbility().addEffect(new CreateDelayedTriggeredAbilityEffect(new ShrivelingRotDestroyTriggeredAbility())); - + // Until end of turn, whenever a creature dies, that creature's controller loses life equal to its toughness. Mode mode = new Mode(); mode.addEffect(new CreateDelayedTriggeredAbilityEffect(new ShrivelingRotLoseLifeTriggeredAbility())); @@ -72,14 +72,16 @@ class ShrivelingRotDestroyTriggeredAbility extends DelayedTriggeredAbility { @Override public boolean checkEventType(GameEvent event, Game game) { - return event.getType() == GameEvent.EventType.DAMAGED_CREATURE; + return event.getType() == GameEvent.EventType.DAMAGED_PERMANENT; } @Override public boolean checkTrigger(GameEvent event, Game game) { - for (Effect effect : this.getEffects()) { - effect.setTargetPointer(new FixedTarget(event.getTargetId())); + Permanent permanent = game.getPermanent(event.getTargetId()); + if (permanent == null || !permanent.isCreature()) { + return false; } + getEffects().setTargetPointer(new FixedTarget(event.getTargetId(), game)); return true; } diff --git a/Mage.Sets/src/mage/cards/s/SivvisValor.java b/Mage.Sets/src/mage/cards/s/SivvisValor.java index 3ca8971efb..71eb4e01c3 100644 --- a/Mage.Sets/src/mage/cards/s/SivvisValor.java +++ b/Mage.Sets/src/mage/cards/s/SivvisValor.java @@ -81,7 +81,7 @@ class SivvisValorEffect extends ReplacementEffectImpl { @Override public boolean checksEventType(GameEvent event, Game game) { - return event.getType() == GameEvent.EventType.DAMAGE_CREATURE; + return event.getType() == GameEvent.EventType.DAMAGE_PERMANENT; } @Override diff --git a/Mage.Sets/src/mage/cards/s/SosukeSonOfSeshiro.java b/Mage.Sets/src/mage/cards/s/SosukeSonOfSeshiro.java index 33a0e10dae..25dd0700ee 100644 --- a/Mage.Sets/src/mage/cards/s/SosukeSonOfSeshiro.java +++ b/Mage.Sets/src/mage/cards/s/SosukeSonOfSeshiro.java @@ -14,16 +14,14 @@ import mage.cards.CardSetInfo; import mage.constants.*; import mage.filter.common.FilterCreaturePermanent; import mage.game.Game; -import mage.game.events.DamagedCreatureEvent; +import mage.game.events.DamagedEvent; import mage.game.events.GameEvent; -import mage.game.events.GameEvent.EventType; import mage.game.permanent.Permanent; import mage.target.targetpointer.FixedTarget; import java.util.UUID; /** - * * @author LevelX */ public final class SosukeSonOfSeshiro extends CardImpl { @@ -31,11 +29,11 @@ public final class SosukeSonOfSeshiro extends CardImpl { private static final FilterCreaturePermanent filter = new FilterCreaturePermanent("Snake creatures"); static { - filter.add(SubType.SNAKE.getPredicate()); + filter.add(SubType.SNAKE.getPredicate()); } public SosukeSonOfSeshiro(UUID ownerId, CardSetInfo setInfo) { - super(ownerId,setInfo,new CardType[]{CardType.CREATURE},"{2}{G}{G}"); + super(ownerId, setInfo, new CardType[]{CardType.CREATURE}, "{2}{G}{G}"); addSuperType(SuperType.LEGENDARY); this.subtype.add(SubType.SNAKE); this.subtype.add(SubType.WARRIOR); @@ -79,21 +77,25 @@ class SosukeSonOfSeshiroTriggeredAbility extends TriggeredAbilityImpl { @Override public boolean checkEventType(GameEvent event, Game game) { - return event.getType() == GameEvent.EventType.DAMAGED_CREATURE; + return event.getType() == GameEvent.EventType.DAMAGED_PERMANENT; } @Override public boolean checkTrigger(GameEvent event, Game game) { - if (((DamagedCreatureEvent) event).isCombatDamage()) { - Permanent sourceCreature = game.getPermanent(event.getSourceId()); - Permanent targetCreature = game.getPermanent(event.getTargetId()); - if (sourceCreature != null && sourceCreature.isControlledBy(this.getControllerId()) - && targetCreature != null && sourceCreature.hasSubtype(SubType.WARRIOR, game)) { - this.getEffects().get(0).setTargetPointer(new FixedTarget(targetCreature.getId())); - return true; - } + if (!((DamagedEvent) event).isCombatDamage()) { + return false; } - return false; + Permanent sourceCreature = game.getPermanent(event.getSourceId()); + Permanent targetCreature = game.getPermanent(event.getTargetId()); + if (sourceCreature == null + || !sourceCreature.isControlledBy(this.getControllerId()) + || targetCreature == null + || !targetCreature.isCreature() + || !sourceCreature.hasSubtype(SubType.WARRIOR, game)) { + return false; + } + this.getEffects().setTargetPointer(new FixedTarget(targetCreature, game)); + return true; } @Override diff --git a/Mage.Sets/src/mage/cards/s/SoulScarMage.java b/Mage.Sets/src/mage/cards/s/SoulScarMage.java index 80a150347f..cca5bb549e 100644 --- a/Mage.Sets/src/mage/cards/s/SoulScarMage.java +++ b/Mage.Sets/src/mage/cards/s/SoulScarMage.java @@ -1,7 +1,6 @@ package mage.cards.s; -import java.util.UUID; import mage.MageInt; import mage.abilities.Ability; import mage.abilities.common.SimpleStaticAbility; @@ -11,20 +10,17 @@ import mage.abilities.effects.common.counter.AddCountersTargetEffect; import mage.abilities.keyword.ProwessAbility; import mage.cards.CardImpl; import mage.cards.CardSetInfo; -import mage.constants.CardType; -import mage.constants.SubType; -import mage.constants.Duration; -import mage.constants.Outcome; -import mage.constants.Zone; +import mage.constants.*; import mage.counters.CounterType; import mage.game.Game; -import mage.game.events.DamageCreatureEvent; +import mage.game.events.DamageEvent; import mage.game.events.GameEvent; import mage.game.permanent.Permanent; import mage.target.targetpointer.FixedTarget; +import java.util.UUID; + /** - * * @author stravant */ public final class SoulScarMage extends CardImpl { @@ -84,19 +80,15 @@ class SoulScarMageDamageReplacementEffect extends ReplacementEffectImpl { @Override public boolean checksEventType(GameEvent event, Game game) { - return event.getType() == GameEvent.EventType.DAMAGE_CREATURE; + return event.getType() == GameEvent.EventType.DAMAGE_PERMANENT; } @Override public boolean applies(GameEvent event, Ability source, Game game) { - UUID sourceControllerId = game.getControllerId(event.getSourceId()); - UUID targetControllerId = game.getControllerId(event.getTargetId()); - UUID controllerId = source.getControllerId(); - boolean weControlSource = controllerId.equals(sourceControllerId); - boolean opponentControlsTarget = game.getOpponents(sourceControllerId).contains(targetControllerId); - boolean isNoncombatDamage = !((DamageCreatureEvent) event).isCombatDamage(); - return weControlSource - && isNoncombatDamage - && opponentControlsTarget; + Permanent permanent = game.getPermanent(event.getTargetId()); + return permanent != null + && permanent.isCreature() + && !((DamageEvent) event).isCombatDamage() + && game.getOpponents(permanent.getControllerId()).contains(source.getControllerId()); } } diff --git a/Mage.Sets/src/mage/cards/s/SoulsOfTheFaultless.java b/Mage.Sets/src/mage/cards/s/SoulsOfTheFaultless.java index 7bf09e3310..f646bb6204 100644 --- a/Mage.Sets/src/mage/cards/s/SoulsOfTheFaultless.java +++ b/Mage.Sets/src/mage/cards/s/SoulsOfTheFaultless.java @@ -15,9 +15,8 @@ import mage.constants.SubType; import mage.constants.Outcome; import mage.constants.Zone; import mage.game.Game; -import mage.game.events.DamagedCreatureEvent; +import mage.game.events.DamagedEvent; import mage.game.events.GameEvent; -import mage.game.events.GameEvent.EventType; import mage.game.permanent.Permanent; import mage.players.Player; @@ -67,13 +66,13 @@ class SoulsOfTheFaultlessTriggeredAbility extends TriggeredAbilityImpl { @Override public boolean checkEventType(GameEvent event, Game game) { - return event.getType() == GameEvent.EventType.DAMAGED_CREATURE; + return event.getType() == GameEvent.EventType.DAMAGED_PERMANENT; } @Override public boolean checkTrigger(GameEvent event, Game game) { if (event.getTargetId().equals(this.sourceId) - && ((DamagedCreatureEvent) event).isCombatDamage()) { + && ((DamagedEvent) event).isCombatDamage()) { Permanent source = game.getPermanent(event.getSourceId()); if (source == null) { source = (Permanent) game.getLastKnownInformation(event.getSourceId(), Zone.BATTLEFIELD); diff --git a/Mage.Sets/src/mage/cards/s/Spiritualize.java b/Mage.Sets/src/mage/cards/s/Spiritualize.java index faecdc64ef..27bf9dd816 100644 --- a/Mage.Sets/src/mage/cards/s/Spiritualize.java +++ b/Mage.Sets/src/mage/cards/s/Spiritualize.java @@ -65,8 +65,7 @@ class SpiritualizeTriggeredAbility extends DelayedTriggeredAbility { @Override public boolean checkEventType(GameEvent event, Game game) { return event.getType() == GameEvent.EventType.DAMAGED_PLAYER - || event.getType() == GameEvent.EventType.DAMAGED_CREATURE - || event.getType() == GameEvent.EventType.DAMAGED_PLANESWALKER; + || event.getType() == GameEvent.EventType.DAMAGED_PERMANENT; } @Override diff --git a/Mage.Sets/src/mage/cards/s/Spitemare.java b/Mage.Sets/src/mage/cards/s/Spitemare.java index e03a6b3fcf..6303fe9bde 100644 --- a/Mage.Sets/src/mage/cards/s/Spitemare.java +++ b/Mage.Sets/src/mage/cards/s/Spitemare.java @@ -65,7 +65,7 @@ class SpitemareTriggeredAbility extends TriggeredAbilityImpl { @Override public boolean checkEventType(GameEvent event, Game game) { - return event.getType() == GameEvent.EventType.DAMAGED_CREATURE; + return event.getType() == GameEvent.EventType.DAMAGED_PERMANENT; } @Override diff --git a/Mage.Sets/src/mage/cards/s/StormwildCapridor.java b/Mage.Sets/src/mage/cards/s/StormwildCapridor.java index 0c9e257ec2..2ff429f95d 100644 --- a/Mage.Sets/src/mage/cards/s/StormwildCapridor.java +++ b/Mage.Sets/src/mage/cards/s/StormwildCapridor.java @@ -13,7 +13,7 @@ import mage.constants.Duration; import mage.constants.SubType; import mage.counters.CounterType; import mage.game.Game; -import mage.game.events.DamageCreatureEvent; +import mage.game.events.DamageEvent; import mage.game.events.GameEvent; import mage.game.permanent.Permanent; @@ -91,7 +91,7 @@ class StormwildCapridorEffect extends PreventionEffectImpl { || !super.applies(event, source, game)) { return false; } - DamageCreatureEvent damageEvent = (DamageCreatureEvent) event; + DamageEvent damageEvent = (DamageEvent) event; return !damageEvent.isCombatDamage(); } diff --git a/Mage.Sets/src/mage/cards/s/StuffyDoll.java b/Mage.Sets/src/mage/cards/s/StuffyDoll.java index fe0380d109..9110c01780 100644 --- a/Mage.Sets/src/mage/cards/s/StuffyDoll.java +++ b/Mage.Sets/src/mage/cards/s/StuffyDoll.java @@ -71,7 +71,7 @@ class StuffyDollTriggeredAbility extends TriggeredAbilityImpl { @Override public boolean checkEventType(GameEvent event, Game game) { - return event.getType() == GameEvent.EventType.DAMAGED_CREATURE; + return event.getType() == GameEvent.EventType.DAMAGED_PERMANENT; } @Override diff --git a/Mage.Sets/src/mage/cards/s/SulfuricVapors.java b/Mage.Sets/src/mage/cards/s/SulfuricVapors.java index acf4f9fba3..72c5531010 100644 --- a/Mage.Sets/src/mage/cards/s/SulfuricVapors.java +++ b/Mage.Sets/src/mage/cards/s/SulfuricVapors.java @@ -59,8 +59,7 @@ class SulfuricVaporsEffect extends ReplacementEffectImpl { @Override public boolean checksEventType(GameEvent event, Game game) { - return event.getType() == GameEvent.EventType.DAMAGE_CREATURE || - event.getType() == GameEvent.EventType.DAMAGE_PLANESWALKER || + return event.getType() == GameEvent.EventType.DAMAGE_PERMANENT || event.getType() == GameEvent.EventType.DAMAGE_PLAYER; } diff --git a/Mage.Sets/src/mage/cards/s/SunhomeEnforcer.java b/Mage.Sets/src/mage/cards/s/SunhomeEnforcer.java index 577ad55e27..3c794f83ec 100644 --- a/Mage.Sets/src/mage/cards/s/SunhomeEnforcer.java +++ b/Mage.Sets/src/mage/cards/s/SunhomeEnforcer.java @@ -66,9 +66,8 @@ class SunhomeEnforcerTriggeredAbility extends TriggeredAbilityImpl { @Override public boolean checkEventType(GameEvent event, Game game) { - return event.getType() == GameEvent.EventType.DAMAGED_CREATURE - || event.getType() == GameEvent.EventType.DAMAGED_PLAYER - || event.getType() == GameEvent.EventType.DAMAGED_PLANESWALKER; + return event.getType() == GameEvent.EventType.DAMAGED_PERMANENT + || event.getType() == GameEvent.EventType.DAMAGED_PLAYER; } @Override diff --git a/Mage.Sets/src/mage/cards/s/SuperDuperDeathRay.java b/Mage.Sets/src/mage/cards/s/SuperDuperDeathRay.java index 458ddcbb4b..49159e55ae 100644 --- a/Mage.Sets/src/mage/cards/s/SuperDuperDeathRay.java +++ b/Mage.Sets/src/mage/cards/s/SuperDuperDeathRay.java @@ -5,7 +5,6 @@ import mage.abilities.Ability; import mage.abilities.common.SimpleStaticAbility; import mage.abilities.effects.OneShotEffect; import mage.abilities.effects.common.InfoEffect; -import mage.abilities.keyword.DeathtouchAbility; import mage.cards.CardImpl; import mage.cards.CardSetInfo; import mage.constants.CardType; @@ -17,8 +16,6 @@ import mage.target.common.TargetCreaturePermanent; import java.util.UUID; -import static mage.game.combat.CombatGroup.getLethalDamage; - /** * @author TheElk801 */ @@ -70,10 +67,7 @@ class SuperDuperDeathRayEffect extends OneShotEffect { if (permanent == null || sourceObject == null) { return false; } - int lethal = getLethalDamage(permanent, game); - if (sourceObject.getAbilities().containsKey(DeathtouchAbility.getInstance().getId())) { - lethal = Math.min(lethal, 1); - } + int lethal = permanent.getLethalDamage(source.getSourceId(), game); lethal = Math.min(lethal, 4); permanent.damage(lethal, source.getSourceId(), source, game); Player player = game.getPlayer(permanent.getControllerId()); diff --git a/Mage.Sets/src/mage/cards/s/SwansOfBrynArgoll.java b/Mage.Sets/src/mage/cards/s/SwansOfBrynArgoll.java index f5880c5c32..5b8bb2b7e1 100644 --- a/Mage.Sets/src/mage/cards/s/SwansOfBrynArgoll.java +++ b/Mage.Sets/src/mage/cards/s/SwansOfBrynArgoll.java @@ -119,7 +119,7 @@ class SwansOfBrynArgollEffect extends PreventionEffectImpl { @Override public boolean applies(GameEvent event, Ability source, Game game) { - return event.getType() == GameEvent.EventType.DAMAGE_CREATURE + return event.getType() == EventType.DAMAGE_PERMANENT && event.getTargetId().equals(source.getSourceId()); } diff --git a/Mage.Sets/src/mage/cards/s/SwordOfKaldra.java b/Mage.Sets/src/mage/cards/s/SwordOfKaldra.java index 1a086e6280..6a0e04b51c 100644 --- a/Mage.Sets/src/mage/cards/s/SwordOfKaldra.java +++ b/Mage.Sets/src/mage/cards/s/SwordOfKaldra.java @@ -1,11 +1,9 @@ package mage.cards.s; -import java.util.UUID; import mage.abilities.TriggeredAbilityImpl; import mage.abilities.common.SimpleStaticAbility; import mage.abilities.costs.mana.ManaCostsImpl; -import mage.abilities.effects.Effect; import mage.abilities.effects.common.ExileTargetEffect; import mage.abilities.effects.common.continuous.BoostEquippedEffect; import mage.abilities.keyword.EquipAbility; @@ -14,18 +12,18 @@ import mage.cards.CardSetInfo; import mage.constants.*; import mage.game.Game; import mage.game.events.GameEvent; -import mage.game.events.GameEvent.EventType; import mage.game.permanent.Permanent; import mage.target.targetpointer.FixedTarget; +import java.util.UUID; + /** - * * @author LevelX2 */ public final class SwordOfKaldra extends CardImpl { public SwordOfKaldra(UUID ownerId, CardSetInfo setInfo) { - super(ownerId,setInfo,new CardType[]{CardType.ARTIFACT},"{4}"); + super(ownerId, setInfo, new CardType[]{CardType.ARTIFACT}, "{4}"); addSuperType(SuperType.LEGENDARY); this.subtype.add(SubType.EQUIPMENT); @@ -64,7 +62,7 @@ class SwordOfKaldraTriggeredAbility extends TriggeredAbilityImpl { @Override public boolean checkEventType(GameEvent event, Game game) { - return event.getType() == GameEvent.EventType.DAMAGED_CREATURE; + return event.getType() == GameEvent.EventType.DAMAGED_PERMANENT; } @Override @@ -73,9 +71,7 @@ class SwordOfKaldraTriggeredAbility extends TriggeredAbilityImpl { if (equipment != null && equipment.getAttachedTo() != null && event.getSourceId().equals(equipment.getAttachedTo())) { - for (Effect effect : this.getEffects()) { - effect.setTargetPointer(new FixedTarget(event.getTargetId())); - } + getEffects().setTargetPointer(new FixedTarget(event.getTargetId())); return true; } return false; diff --git a/Mage.Sets/src/mage/cards/t/Tamanoa.java b/Mage.Sets/src/mage/cards/t/Tamanoa.java index 5390e72df5..4712488b90 100644 --- a/Mage.Sets/src/mage/cards/t/Tamanoa.java +++ b/Mage.Sets/src/mage/cards/t/Tamanoa.java @@ -63,9 +63,8 @@ class TamanoaDealsDamageTriggeredAbility extends TriggeredAbilityImpl { @Override public boolean checkEventType(GameEvent event, Game game) { - return event.getType() == GameEvent.EventType.DAMAGED_CREATURE - || event.getType() == GameEvent.EventType.DAMAGED_PLAYER - || event.getType() == GameEvent.EventType.DAMAGED_PLANESWALKER; + return event.getType() == GameEvent.EventType.DAMAGED_PERMANENT + || event.getType() == GameEvent.EventType.DAMAGED_PLAYER; } @Override diff --git a/Mage.Sets/src/mage/cards/t/TempleAltisaur.java b/Mage.Sets/src/mage/cards/t/TempleAltisaur.java index 7ca73f5db8..5ee3f4ab5b 100644 --- a/Mage.Sets/src/mage/cards/t/TempleAltisaur.java +++ b/Mage.Sets/src/mage/cards/t/TempleAltisaur.java @@ -72,7 +72,7 @@ class TempleAltisaurPreventEffect extends PreventionEffectImpl { @Override public boolean applies(GameEvent event, Ability source, Game game) { - if (event.getType() == GameEvent.EventType.DAMAGE_CREATURE) { + if (event.getType() == GameEvent.EventType.DAMAGE_PERMANENT) { Permanent permanent = game.getPermanent(event.getTargetId()); if (permanent != null && !permanent.getId().equals(source.getSourceId()) diff --git a/Mage.Sets/src/mage/cards/t/Tephraderm.java b/Mage.Sets/src/mage/cards/t/Tephraderm.java index 446d7c0911..bfd2a109ef 100644 --- a/Mage.Sets/src/mage/cards/t/Tephraderm.java +++ b/Mage.Sets/src/mage/cards/t/Tephraderm.java @@ -64,7 +64,7 @@ class TephradermCreatureDamageTriggeredAbility extends TriggeredAbilityImpl { @Override public boolean checkEventType(GameEvent event, Game game) { - return event.getType() == GameEvent.EventType.DAMAGED_CREATURE; + return event.getType() == GameEvent.EventType.DAMAGED_PERMANENT; } @Override @@ -110,7 +110,7 @@ class TephradermSpellDamageTriggeredAbility extends TriggeredAbilityImpl { @Override public boolean checkEventType(GameEvent event, Game game) { - return event.getType() == GameEvent.EventType.DAMAGED_CREATURE; + return event.getType() == GameEvent.EventType.DAMAGED_PERMANENT; } @Override diff --git a/Mage.Sets/src/mage/cards/t/TheFallen.java b/Mage.Sets/src/mage/cards/t/TheFallen.java index 40b393dea9..65e16a5df6 100644 --- a/Mage.Sets/src/mage/cards/t/TheFallen.java +++ b/Mage.Sets/src/mage/cards/t/TheFallen.java @@ -1,25 +1,21 @@ package mage.cards.t; -import java.util.*; import mage.MageInt; import mage.abilities.Ability; import mage.abilities.common.BeginningOfUpkeepTriggeredAbility; import mage.abilities.effects.OneShotEffect; import mage.cards.CardImpl; import mage.cards.CardSetInfo; -import mage.constants.CardType; -import mage.constants.SubType; -import mage.constants.Outcome; -import mage.constants.TargetController; -import mage.constants.WatcherScope; +import mage.constants.*; import mage.game.Game; import mage.game.events.GameEvent; import mage.game.permanent.Permanent; import mage.watchers.Watcher; +import java.util.*; + /** - * * @author L_J */ public final class TheFallen extends CardImpl { @@ -85,20 +81,26 @@ class TheFallenWatcher extends Watcher { @Override public void watch(GameEvent event, Game game) { - if (event.getType() == GameEvent.EventType.DAMAGED_PLAYER - || event.getType() == GameEvent.EventType.DAMAGED_PLANESWALKER) { - Permanent permanent = game.getPermanentOrLKIBattlefield(event.getSourceId()); - if (permanent != null) { - Set toAdd; - if (playersAndWalkersDealtDamageThisGame.get(event.getSourceId()) == null) { - toAdd = new HashSet<>(); - } else { - toAdd = playersAndWalkersDealtDamageThisGame.get(event.getSourceId()); - } - toAdd.add(event.getPlayerId()); - playersAndWalkersDealtDamageThisGame.put(event.getSourceId(), toAdd); - } + if (event.getType() != GameEvent.EventType.DAMAGED_PLAYER + && event.getType() != GameEvent.EventType.DAMAGED_PERMANENT) { + return; } + Permanent damaged = game.getPermanent(event.getTargetId()); + if (damaged != null && !damaged.isPlaneswalker()) { + return; + } + Permanent permanent = game.getPermanentOrLKIBattlefield(event.getSourceId()); + if (permanent == null) { + return; + } + Set toAdd; + if (playersAndWalkersDealtDamageThisGame.get(event.getSourceId()) == null) { + toAdd = new HashSet<>(); + } else { + toAdd = playersAndWalkersDealtDamageThisGame.get(event.getSourceId()); + } + toAdd.add(event.getPlayerId()); + playersAndWalkersDealtDamageThisGame.put(event.getSourceId(), toAdd); } public Set getPlayersAndWalkersDealtDamageThisGame(UUID creatureId) { diff --git a/Mage.Sets/src/mage/cards/t/TheFlameOfKeld.java b/Mage.Sets/src/mage/cards/t/TheFlameOfKeld.java index b76864c3af..951bc53e6b 100644 --- a/Mage.Sets/src/mage/cards/t/TheFlameOfKeld.java +++ b/Mage.Sets/src/mage/cards/t/TheFlameOfKeld.java @@ -72,8 +72,7 @@ class TheFlameOfKeldDamageEffect extends ReplacementEffectImpl { @Override public boolean checksEventType(GameEvent event, Game game) { switch (event.getType()) { - case DAMAGE_CREATURE: - case DAMAGE_PLANESWALKER: + case DAMAGE_PERMANENT: case DAMAGE_PLAYER: return true; default: diff --git a/Mage.Sets/src/mage/cards/t/ThirstingAxe.java b/Mage.Sets/src/mage/cards/t/ThirstingAxe.java index 87ccb691b8..44faef4166 100644 --- a/Mage.Sets/src/mage/cards/t/ThirstingAxe.java +++ b/Mage.Sets/src/mage/cards/t/ThirstingAxe.java @@ -1,9 +1,6 @@ package mage.cards.t; -import java.util.HashSet; -import java.util.Set; -import java.util.UUID; import mage.MageObjectReference; import mage.abilities.Ability; import mage.abilities.TriggeredAbility; @@ -22,20 +19,23 @@ import mage.cards.CardImpl; import mage.cards.CardSetInfo; import mage.constants.*; import mage.game.Game; -import mage.game.events.DamagedCreatureEvent; +import mage.game.events.DamagedEvent; import mage.game.events.GameEvent; import mage.game.permanent.Permanent; import mage.watchers.Watcher; +import java.util.HashSet; +import java.util.Set; +import java.util.UUID; + /** - * * @author Quercitron */ public final class ThirstingAxe extends CardImpl { public ThirstingAxe(UUID ownerId, CardSetInfo setInfo) { - super(ownerId,setInfo,new CardType[]{CardType.ARTIFACT},"{3}"); + super(ownerId, setInfo, new CardType[]{CardType.ARTIFACT}, "{3}"); this.subtype.add(SubType.EQUIPMENT); // Equipped creature gets +4/+0. @@ -47,7 +47,7 @@ public final class ThirstingAxe extends CardImpl { AttachedCondition.instance, new InvertCondition(new EquippedDealtCombatDamageToCreatureCondition())); String triggeredAbilityText = "At the beginning of your end step, if equipped creature " + - "didn't deal combat damage to a creature this turn, sacrifice it."; + "didn't deal combat damage to a creature this turn, sacrifice it."; ConditionalInterveningIfTriggeredAbility sacrificeTriggeredAbility = new ConditionalInterveningIfTriggeredAbility(ability, condition, triggeredAbilityText); this.addAbility(sacrificeTriggeredAbility, new CombatDamageToCreatureWatcher()); @@ -85,7 +85,6 @@ class CombatDamageToCreatureWatcher extends Watcher { // which objects dealt combat damage to creature during the turn private final Set dealtCombatDamageToCreature; - public CombatDamageToCreatureWatcher() { super(WatcherScope.GAME); dealtCombatDamageToCreature = new HashSet<>(); @@ -93,12 +92,16 @@ class CombatDamageToCreatureWatcher extends Watcher { @Override public void watch(GameEvent event, Game game) { - if (event.getType() == GameEvent.EventType.DAMAGED_CREATURE) { - if (((DamagedCreatureEvent) event).isCombatDamage()) { - MageObjectReference damageSource = new MageObjectReference(event.getSourceId(), game); - dealtCombatDamageToCreature.add(damageSource); - } + if (event.getType() != GameEvent.EventType.DAMAGED_PERMANENT + || !((DamagedEvent) event).isCombatDamage()) { + return; } + Permanent permanent = game.getPermanent(event.getTargetId()); + if (permanent == null || !permanent.isCreature()) { + return; + } + MageObjectReference damageSource = new MageObjectReference(event.getSourceId(), game); + dealtCombatDamageToCreature.add(damageSource); } @Override diff --git a/Mage.Sets/src/mage/cards/t/ToralfGodOfFury.java b/Mage.Sets/src/mage/cards/t/ToralfGodOfFury.java index fdc9c4d7cb..a9ea1493fe 100644 --- a/Mage.Sets/src/mage/cards/t/ToralfGodOfFury.java +++ b/Mage.Sets/src/mage/cards/t/ToralfGodOfFury.java @@ -103,12 +103,7 @@ class ToralfGodOfFuryTriggeredAbility extends TriggeredAbilityImpl { @Override public boolean checkEventType(GameEvent event, Game game) { - switch (event.getType()) { - case DAMAGED_CREATURE: - case DAMAGED_PLANESWALKER: - return true; - } - return false; + return event.getType() == GameEvent.EventType.DAMAGED_PERMANENT; } @Override diff --git a/Mage.Sets/src/mage/cards/t/TorbranThaneOfRedFell.java b/Mage.Sets/src/mage/cards/t/TorbranThaneOfRedFell.java index 418850d4f3..2a07471bfb 100644 --- a/Mage.Sets/src/mage/cards/t/TorbranThaneOfRedFell.java +++ b/Mage.Sets/src/mage/cards/t/TorbranThaneOfRedFell.java @@ -65,8 +65,7 @@ class TorbranThaneOfRedFellEffect extends ReplacementEffectImpl { @Override public boolean checksEventType(GameEvent event, Game game) { switch (event.getType()) { - case DAMAGE_CREATURE: - case DAMAGE_PLANESWALKER: + case DAMAGE_PERMANENT: case DAMAGE_PLAYER: return true; default: diff --git a/Mage.Sets/src/mage/cards/t/ToweringWaveMystic.java b/Mage.Sets/src/mage/cards/t/ToweringWaveMystic.java index 0af73635a3..50dc1ee42b 100644 --- a/Mage.Sets/src/mage/cards/t/ToweringWaveMystic.java +++ b/Mage.Sets/src/mage/cards/t/ToweringWaveMystic.java @@ -59,9 +59,8 @@ class ToweringWaveMysticTriggeredAbility extends TriggeredAbilityImpl { @Override public boolean checkEventType(GameEvent event, Game game) { - return event.getType() == GameEvent.EventType.DAMAGED_CREATURE - || event.getType() == GameEvent.EventType.DAMAGED_PLAYER - || event.getType() == GameEvent.EventType.DAMAGED_PLANESWALKER; + return event.getType() == GameEvent.EventType.DAMAGED_PERMANENT + || event.getType() == GameEvent.EventType.DAMAGED_PLAYER; } @Override diff --git a/Mage.Sets/src/mage/cards/t/TreacherousLink.java b/Mage.Sets/src/mage/cards/t/TreacherousLink.java index 9f16e3e448..408d5d942c 100644 --- a/Mage.Sets/src/mage/cards/t/TreacherousLink.java +++ b/Mage.Sets/src/mage/cards/t/TreacherousLink.java @@ -70,7 +70,7 @@ class TreacherousLinkEffect extends ReplacementEffectImpl { @Override public boolean checksEventType(GameEvent event, Game game) { - return event.getType() == GameEvent.EventType.DAMAGE_CREATURE; + return event.getType() == GameEvent.EventType.DAMAGE_PERMANENT; } @Override diff --git a/Mage.Sets/src/mage/cards/t/TresserhornSkyknight.java b/Mage.Sets/src/mage/cards/t/TresserhornSkyknight.java index 91d8815018..8256f5f728 100644 --- a/Mage.Sets/src/mage/cards/t/TresserhornSkyknight.java +++ b/Mage.Sets/src/mage/cards/t/TresserhornSkyknight.java @@ -17,8 +17,8 @@ import mage.constants.Zone; import mage.filter.common.FilterCreaturePermanent; import mage.filter.predicate.mageobject.AbilityPredicate; import mage.game.Game; +import mage.game.events.DamageEvent; import mage.game.events.GameEvent; -import mage.game.events.DamageCreatureEvent; import mage.game.permanent.Permanent; /** @@ -75,8 +75,8 @@ class TresserhornSkyknightEffect extends PreventionEffectImpl { @Override public boolean applies(GameEvent event, Ability source, Game game) { - if (super.applies(event, source, game) && event instanceof DamageCreatureEvent && event.getAmount() > 0) { - DamageCreatureEvent damageEvent = (DamageCreatureEvent) event; + if (super.applies(event, source, game) && event instanceof DamageEvent && event.getAmount() > 0) { + DamageEvent damageEvent = (DamageEvent) event; if (event.getTargetId().equals(source.getSourceId())) { Permanent permanent = game.getPermanentOrLKIBattlefield(damageEvent.getSourceId()); if (permanent != null && filter.match(permanent, game)) { diff --git a/Mage.Sets/src/mage/cards/u/UmezawasJitte.java b/Mage.Sets/src/mage/cards/u/UmezawasJitte.java index e96c5e62a9..1aa461fba2 100644 --- a/Mage.Sets/src/mage/cards/u/UmezawasJitte.java +++ b/Mage.Sets/src/mage/cards/u/UmezawasJitte.java @@ -91,8 +91,7 @@ class UmezawasJitteAbility extends TriggeredAbilityImpl { @Override public boolean checkEventType(GameEvent event, Game game) { switch(event.getType()) { - case DAMAGED_CREATURE: - case DAMAGED_PLANESWALKER: + case DAMAGED_PERMANENT: case DAMAGED_PLAYER: case COMBAT_DAMAGE_STEP_PRE: return true; diff --git a/Mage.Sets/src/mage/cards/v/VengefulPharaoh.java b/Mage.Sets/src/mage/cards/v/VengefulPharaoh.java index bc0b646596..1cd2770598 100644 --- a/Mage.Sets/src/mage/cards/v/VengefulPharaoh.java +++ b/Mage.Sets/src/mage/cards/v/VengefulPharaoh.java @@ -1,7 +1,6 @@ package mage.cards.v; -import java.util.UUID; import mage.MageInt; import mage.MageObjectReference; import mage.abilities.Ability; @@ -12,26 +11,26 @@ import mage.cards.Card; import mage.cards.CardImpl; import mage.cards.CardSetInfo; import mage.constants.CardType; -import mage.constants.SubType; import mage.constants.Outcome; +import mage.constants.SubType; import mage.constants.Zone; import mage.game.Game; import mage.game.events.DamagedEvent; import mage.game.events.GameEvent; -import mage.game.events.GameEvent.EventType; import mage.game.permanent.Permanent; import mage.game.turn.Step; import mage.players.Player; import mage.target.common.TargetAttackingCreature; +import java.util.UUID; + /** - * * @author North */ public final class VengefulPharaoh extends CardImpl { public VengefulPharaoh(UUID ownerId, CardSetInfo setInfo) { - super(ownerId,setInfo,new CardType[]{CardType.CREATURE},"{2}{B}{B}{B}"); + super(ownerId, setInfo, new CardType[]{CardType.CREATURE}, "{2}{B}{B}{B}"); this.subtype.add(SubType.ZOMBIE); this.power = new MageInt(5); @@ -94,7 +93,8 @@ class VengefulPharaohTriggeredAbility extends TriggeredAbilityImpl { @Override public boolean checkEventType(GameEvent event, Game game) { - return event.getType() == GameEvent.EventType.DAMAGED_PLAYER || event.getType() == GameEvent.EventType.DAMAGED_PLANESWALKER; + return event.getType() == GameEvent.EventType.DAMAGED_PLAYER + || event.getType() == GameEvent.EventType.DAMAGED_PERMANENT; } @Override @@ -107,9 +107,9 @@ class VengefulPharaohTriggeredAbility extends TriggeredAbilityImpl { return true; } } - if (event.getType() == GameEvent.EventType.DAMAGED_PLANESWALKER && ((DamagedEvent) event).isCombatDamage()) { + if (event.getType() == GameEvent.EventType.DAMAGED_PERMANENT && ((DamagedEvent) event).isCombatDamage()) { Permanent permanent = game.getPermanent(event.getTargetId()); - if (permanent != null && permanent.isControlledBy(this.getControllerId())) { + if (permanent != null && permanent.isPlaneswalker() && permanent.isControlledBy(this.getControllerId())) { if (!game.getPhase().getStep().equals(stepTriggeredPlansewalker) || game.getTurnNum() != turnTriggeredPlaneswalker) { stepTriggeredPlansewalker = game.getPhase().getStep(); turnTriggeredPlaneswalker = game.getTurnNum(); diff --git a/Mage.Sets/src/mage/cards/v/Vigor.java b/Mage.Sets/src/mage/cards/v/Vigor.java index 9772a51914..f486190caa 100644 --- a/Mage.Sets/src/mage/cards/v/Vigor.java +++ b/Mage.Sets/src/mage/cards/v/Vigor.java @@ -82,12 +82,14 @@ class VigorReplacementEffect extends ReplacementEffectImpl { @Override public boolean checksEventType(GameEvent event, Game game) { - return event.getType() == GameEvent.EventType.DAMAGE_CREATURE; + return event.getType() == GameEvent.EventType.DAMAGE_PERMANENT; } @Override public boolean applies(GameEvent event, Ability source, Game game) { - return event.getPlayerId().equals(source.getControllerId()) + Permanent permanent = game.getPermanent(event.getTargetId()); + return permanent != null + && permanent.isCreature() && !event.getTargetId().equals(source.getSourceId()); } diff --git a/Mage.Sets/src/mage/cards/v/VigorousCharge.java b/Mage.Sets/src/mage/cards/v/VigorousCharge.java index cc39a0d8ee..c9aa8c211f 100644 --- a/Mage.Sets/src/mage/cards/v/VigorousCharge.java +++ b/Mage.Sets/src/mage/cards/v/VigorousCharge.java @@ -70,9 +70,8 @@ class VigorousChargeTriggeredAbility extends TriggeredAbilityImpl { @Override public boolean checkEventType(GameEvent event, Game game) { - return event.getType() == GameEvent.EventType.DAMAGED_CREATURE - || event.getType() == GameEvent.EventType.DAMAGED_PLAYER - || event.getType() == GameEvent.EventType.DAMAGED_PLANESWALKER; + return event.getType() == GameEvent.EventType.DAMAGED_PERMANENT + || event.getType() == GameEvent.EventType.DAMAGED_PLAYER; } @Override diff --git a/Mage.Sets/src/mage/cards/v/VolatileRig.java b/Mage.Sets/src/mage/cards/v/VolatileRig.java index 73dc22d2ed..0b27123826 100644 --- a/Mage.Sets/src/mage/cards/v/VolatileRig.java +++ b/Mage.Sets/src/mage/cards/v/VolatileRig.java @@ -2,18 +2,18 @@ package mage.cards.v; import mage.MageInt; import mage.abilities.Ability; -import mage.abilities.TriggeredAbilityImpl; import mage.abilities.common.AttacksEachCombatStaticAbility; +import mage.abilities.common.DealtDamageToSourceTriggeredAbility; import mage.abilities.common.DiesSourceTriggeredAbility; import mage.abilities.effects.OneShotEffect; import mage.abilities.keyword.TrampleAbility; import mage.cards.CardImpl; import mage.cards.CardSetInfo; -import mage.constants.*; +import mage.constants.CardType; +import mage.constants.Outcome; +import mage.constants.SubType; import mage.filter.StaticFilters; import mage.game.Game; -import mage.game.events.GameEvent; -import mage.game.events.GameEvent.EventType; import mage.game.permanent.Permanent; import mage.players.Player; @@ -39,7 +39,7 @@ public final class VolatileRig extends CardImpl { this.addAbility(new AttacksEachCombatStaticAbility()); // Whenever Volatile Rig is dealt damage, flip a coin. If you lose the flip, sacrifice Volatile Rig. - this.addAbility(new VolatileRigTriggeredAbility()); + this.addAbility(new DealtDamageToSourceTriggeredAbility(new VolatileRigEffect(), false)); // When Volatile Rig dies, flip a coin. If you lose the flip, it deals 4 damage to each creature and each player. this.addAbility(new DiesSourceTriggeredAbility(new VolatileRigEffect2())); @@ -56,60 +56,6 @@ public final class VolatileRig extends CardImpl { } } -class VolatileRigTriggeredAbility extends TriggeredAbilityImpl { - - private boolean triggerdThisCombatStep = false; - - public VolatileRigTriggeredAbility() { - super(Zone.BATTLEFIELD, new VolatileRigEffect()); - } - - public VolatileRigTriggeredAbility(final VolatileRigTriggeredAbility effect) { - super(effect); - this.triggerdThisCombatStep = effect.triggerdThisCombatStep; - } - - @Override - public VolatileRigTriggeredAbility copy() { - return new VolatileRigTriggeredAbility(this); - } - - @Override - public boolean checkEventType(GameEvent event, Game game) { - return event.getType() == GameEvent.EventType.COMBAT_DAMAGE_STEP_POST - || event.getType() == GameEvent.EventType.DAMAGED_CREATURE; - } - - @Override - public boolean checkTrigger(GameEvent event, Game game) { - /* - * If Volatile Rig is dealt damage by multiple sources at the same time - * (for example, multiple blocking creatures), its first triggered ability - * will trigger only once. - */ - if (triggerdThisCombatStep && event.getType() == GameEvent.EventType.COMBAT_DAMAGE_STEP_POST) { - triggerdThisCombatStep = false; - } - - if (event.getType() == GameEvent.EventType.DAMAGED_CREATURE && event.getTargetId().equals(this.sourceId)) { - if (game.getPhase().getStep().getType() == PhaseStep.COMBAT_DAMAGE) { - if (triggerdThisCombatStep) { - return false; - } else { - triggerdThisCombatStep = true; - } - } - return true; - } - return false; - } - - @Override - public String getRule() { - return "Whenever {this} is dealt damage, " + super.getRule(); - } -} - class VolatileRigEffect extends OneShotEffect { VolatileRigEffect() { @@ -117,7 +63,7 @@ class VolatileRigEffect extends OneShotEffect { staticText = "flip a coin. If you lose the flip, sacrifice {this}"; } - VolatileRigEffect(final VolatileRigEffect effect) { + private VolatileRigEffect(final VolatileRigEffect effect) { super(effect); } diff --git a/Mage.Sets/src/mage/cards/v/VraskaSwarmsEminence.java b/Mage.Sets/src/mage/cards/v/VraskaSwarmsEminence.java index 3dc008f4ed..2285bde5e1 100644 --- a/Mage.Sets/src/mage/cards/v/VraskaSwarmsEminence.java +++ b/Mage.Sets/src/mage/cards/v/VraskaSwarmsEminence.java @@ -1,6 +1,5 @@ package mage.cards.v; -import java.util.UUID; import mage.abilities.LoyaltyAbility; import mage.abilities.TriggeredAbilityImpl; import mage.abilities.common.PlaneswalkerEntersWithLoyaltyCountersAbility; @@ -24,6 +23,8 @@ import mage.game.permanent.Permanent; import mage.game.permanent.token.AssassinToken2; import mage.target.targetpointer.FixedTarget; +import java.util.UUID; + /** * @author TheElk801 */ @@ -84,21 +85,23 @@ class VraskaSwarmsEminenceTriggeredAbility extends TriggeredAbilityImpl { @Override public boolean checkEventType(GameEvent event, Game game) { return event.getType() == GameEvent.EventType.DAMAGED_PLAYER - || event.getType() == GameEvent.EventType.DAMAGED_PLANESWALKER; + || event.getType() == GameEvent.EventType.DAMAGED_PERMANENT; } @Override public boolean checkTrigger(GameEvent event, Game game) { Permanent permanent = game.getPermanent(event.getSourceId()); - if (permanent != null && filter.match(permanent, getSourceId(), getControllerId(), game)) { - for (Effect effect : this.getEffects()) { - effect.setValue("damage", event.getAmount()); - effect.setValue("sourceId", event.getSourceId()); - effect.setTargetPointer(new FixedTarget(permanent.getId(), permanent.getZoneChangeCounter(game))); - } - return true; + if (permanent == null || !filter.match(permanent, getSourceId(), getControllerId(), game)) { + return false; } - return false; + Permanent damaged = game.getPermanentOrLKIBattlefield(event.getTargetId()); + if (damaged != null && !damaged.isPlaneswalker()) { + return false; + } + getEffects().setValue("damage", event.getAmount()); + getEffects().setValue("sourceId", event.getSourceId()); + getEffects().setTargetPointer(new FixedTarget(permanent.getId(), permanent.getZoneChangeCounter(game))); + return true; } @Override diff --git a/Mage.Sets/src/mage/cards/v/VraskaTheUnseen.java b/Mage.Sets/src/mage/cards/v/VraskaTheUnseen.java index 552e6dccd2..d329426ab1 100644 --- a/Mage.Sets/src/mage/cards/v/VraskaTheUnseen.java +++ b/Mage.Sets/src/mage/cards/v/VraskaTheUnseen.java @@ -12,9 +12,8 @@ import mage.cards.CardImpl; import mage.cards.CardSetInfo; import mage.constants.*; import mage.game.Game; -import mage.game.events.DamagedPlaneswalkerEvent; +import mage.game.events.DamagedEvent; import mage.game.events.GameEvent; -import mage.game.events.GameEvent.EventType; import mage.game.permanent.Permanent; import mage.game.permanent.token.AssassinToken; import mage.target.common.TargetNonlandPermanent; @@ -115,12 +114,12 @@ class VraskaTheUnseenTriggeredAbility extends TriggeredAbilityImpl { @Override public boolean checkEventType(GameEvent event, Game game) { - return event.getType() == GameEvent.EventType.DAMAGED_PLANESWALKER; + return event.getType() == GameEvent.EventType.DAMAGED_PERMANENT; } @Override public boolean checkTrigger(GameEvent event, Game game) { - if (((DamagedPlaneswalkerEvent) event).isCombatDamage() && getSourceId().equals(event.getTargetId())) { + if (((DamagedEvent) event).isCombatDamage() && getSourceId().equals(event.getTargetId())) { Permanent sourceOfDamage = game.getPermanent(event.getSourceId()); if (sourceOfDamage != null && sourceOfDamage.isCreature()) { Effect effect = this.getEffects().get(0); diff --git a/Mage.Sets/src/mage/cards/w/WallOfEssence.java b/Mage.Sets/src/mage/cards/w/WallOfEssence.java index 0960198005..bb45ba86be 100644 --- a/Mage.Sets/src/mage/cards/w/WallOfEssence.java +++ b/Mage.Sets/src/mage/cards/w/WallOfEssence.java @@ -1,7 +1,6 @@ package mage.cards.w; -import java.util.UUID; import mage.MageInt; import mage.abilities.Ability; import mage.abilities.TriggeredAbilityImpl; @@ -10,23 +9,24 @@ import mage.abilities.keyword.DefenderAbility; import mage.cards.CardImpl; import mage.cards.CardSetInfo; import mage.constants.CardType; -import mage.constants.SubType; import mage.constants.Outcome; +import mage.constants.SubType; import mage.constants.Zone; import mage.game.Game; -import mage.game.events.DamagedCreatureEvent; +import mage.game.events.DamagedEvent; import mage.game.events.GameEvent; -import mage.game.events.GameEvent.EventType; +import mage.game.permanent.Permanent; import mage.players.Player; +import java.util.UUID; + /** - * * @author LevelX2 */ public final class WallOfEssence extends CardImpl { public WallOfEssence(UUID ownerId, CardSetInfo setInfo) { - super(ownerId,setInfo,new CardType[]{CardType.CREATURE},"{1}{W}"); + super(ownerId, setInfo, new CardType[]{CardType.CREATURE}, "{1}{W}"); this.subtype.add(SubType.WALL); this.power = new MageInt(0); @@ -65,16 +65,20 @@ class WallOfEssenceTriggeredAbility extends TriggeredAbilityImpl { @Override public boolean checkEventType(GameEvent event, Game game) { - return event.getType() == GameEvent.EventType.DAMAGED_CREATURE; + return event.getType() == GameEvent.EventType.DAMAGED_PERMANENT; } @Override public boolean checkTrigger(GameEvent event, Game game) { - if (event.getTargetId().equals(this.sourceId) && ((DamagedCreatureEvent)event).isCombatDamage() ) { - this.getEffects().get(0).setValue("damageAmount", event.getAmount()); - return true; + Permanent permanent = game.getPermanent(event.getTargetId()); + if (permanent == null + || !permanent.isCreature() + || !event.getTargetId().equals(this.sourceId) + || !((DamagedEvent) event).isCombatDamage()) { + return false; } - return false; + this.getEffects().setValue("damageAmount", event.getAmount()); + return true; } @Override @@ -86,10 +90,10 @@ class WallOfEssenceTriggeredAbility extends TriggeredAbilityImpl { class PiousWarriorGainLifeEffect extends OneShotEffect { - public PiousWarriorGainLifeEffect() { - super(Outcome.GainLife); - staticText = "you gain that much life"; - } + public PiousWarriorGainLifeEffect() { + super(Outcome.GainLife); + staticText = "you gain that much life"; + } public PiousWarriorGainLifeEffect(final PiousWarriorGainLifeEffect effect) { super(effect); diff --git a/Mage.Sets/src/mage/cards/w/WallOfHope.java b/Mage.Sets/src/mage/cards/w/WallOfHope.java index bacf6084db..748e6eb814 100644 --- a/Mage.Sets/src/mage/cards/w/WallOfHope.java +++ b/Mage.Sets/src/mage/cards/w/WallOfHope.java @@ -64,13 +64,13 @@ class WallOfHopeTriggeredAbility extends TriggeredAbilityImpl { @Override public boolean checkEventType(GameEvent event, Game game) { - return event.getType() == GameEvent.EventType.DAMAGED_CREATURE; + return event.getType() == GameEvent.EventType.DAMAGED_PERMANENT; } @Override public boolean checkTrigger(GameEvent event, Game game) { if (event.getTargetId().equals(this.sourceId)) { - this.getEffects().get(0).setValue("damageAmount", event.getAmount()); + this.getEffects().setValue("damageAmount", event.getAmount()); return true; } return false; diff --git a/Mage.Sets/src/mage/cards/w/WallOfShadows.java b/Mage.Sets/src/mage/cards/w/WallOfShadows.java index 1184812f5b..e02a55a677 100644 --- a/Mage.Sets/src/mage/cards/w/WallOfShadows.java +++ b/Mage.Sets/src/mage/cards/w/WallOfShadows.java @@ -23,7 +23,7 @@ import mage.filter.common.FilterCreaturePermanent; import mage.filter.predicate.Predicate; import mage.filter.predicate.permanent.BlockedByIdPredicate; import mage.game.Game; -import mage.game.events.DamageCreatureEvent; +import mage.game.events.DamageEvent; import mage.game.events.GameEvent; import mage.game.permanent.Permanent; import mage.game.stack.StackObject; @@ -87,11 +87,11 @@ class WallOfShadowsEffect extends PreventionEffectImpl { @Override public boolean applies(GameEvent event, Ability source, Game game) { if (!super.applies(event, source, game) - || !(event instanceof DamageCreatureEvent) + || !(event instanceof DamageEvent) || event.getAmount() <= 0) { return false; } - DamageCreatureEvent damageEvent = (DamageCreatureEvent) event; + DamageEvent damageEvent = (DamageEvent) event; if (!event.getTargetId().equals(source.getSourceId())) { return false; } diff --git a/Mage.Sets/src/mage/cards/w/WallOfSouls.java b/Mage.Sets/src/mage/cards/w/WallOfSouls.java index dbb5ed0d81..212be31f1b 100644 --- a/Mage.Sets/src/mage/cards/w/WallOfSouls.java +++ b/Mage.Sets/src/mage/cards/w/WallOfSouls.java @@ -14,9 +14,8 @@ import mage.constants.SubType; import mage.constants.Outcome; import mage.constants.Zone; import mage.game.Game; -import mage.game.events.DamagedCreatureEvent; +import mage.game.events.DamagedEvent; import mage.game.events.GameEvent; -import mage.game.events.GameEvent.EventType; import mage.target.common.TargetOpponentOrPlaneswalker; /** @@ -67,12 +66,12 @@ class WallOfSoulsTriggeredAbility extends TriggeredAbilityImpl { @Override public boolean checkEventType(GameEvent event, Game game) { - return event.getType() == GameEvent.EventType.DAMAGED_CREATURE; + return event.getType() == GameEvent.EventType.DAMAGED_PERMANENT; } @Override public boolean checkTrigger(GameEvent event, Game game) { - if (event.getTargetId().equals(this.sourceId) && ((DamagedCreatureEvent) event).isCombatDamage()) { + if (event.getTargetId().equals(this.sourceId) && ((DamagedEvent) event).isCombatDamage()) { this.getEffects().get(0).setValue("damage", event.getAmount()); return true; } diff --git a/Mage.Sets/src/mage/cards/w/WallOfVapor.java b/Mage.Sets/src/mage/cards/w/WallOfVapor.java index 8b57b717db..5146cec754 100644 --- a/Mage.Sets/src/mage/cards/w/WallOfVapor.java +++ b/Mage.Sets/src/mage/cards/w/WallOfVapor.java @@ -16,8 +16,8 @@ import mage.constants.Zone; import mage.filter.common.FilterCreaturePermanent; import mage.filter.predicate.permanent.BlockedByIdPredicate; import mage.game.Game; +import mage.game.events.DamageEvent; import mage.game.events.GameEvent; -import mage.game.events.DamageCreatureEvent; import mage.game.permanent.Permanent; /** @@ -67,8 +67,8 @@ class WallOfVaporEffect extends PreventionEffectImpl { @Override public boolean applies(GameEvent event, Ability source, Game game) { - if (super.applies(event, source, game) && event instanceof DamageCreatureEvent && event.getAmount() > 0) { - DamageCreatureEvent damageEvent = (DamageCreatureEvent) event; + if (super.applies(event, source, game) && event instanceof DamageEvent && event.getAmount() > 0) { + DamageEvent damageEvent = (DamageEvent) event; if (event.getTargetId().equals(source.getSourceId())) { Permanent permanent = game.getPermanentOrLKIBattlefield(damageEvent.getSourceId()); FilterCreaturePermanent filter = new FilterCreaturePermanent(); diff --git a/Mage.Sets/src/mage/cards/w/WellLaidPlans.java b/Mage.Sets/src/mage/cards/w/WellLaidPlans.java index dd5a9b1b74..4ca87d2804 100644 --- a/Mage.Sets/src/mage/cards/w/WellLaidPlans.java +++ b/Mage.Sets/src/mage/cards/w/WellLaidPlans.java @@ -55,7 +55,7 @@ class WellLaidPlansPreventionEffect extends PreventionEffectImpl { @Override public boolean applies(GameEvent event, Ability source, Game game) { - if (event.getType() != GameEvent.EventType.DAMAGE_CREATURE) { + if (event.getType() != GameEvent.EventType.DAMAGE_PERMANENT) { return false; } Permanent attacker = game.getPermanentOrLKIBattlefield(event.getSourceId()); diff --git a/Mage.Sets/src/mage/cards/z/ZagrasThiefOfHeartbeats.java b/Mage.Sets/src/mage/cards/z/ZagrasThiefOfHeartbeats.java index 3dd08a71ed..f6ccdac878 100644 --- a/Mage.Sets/src/mage/cards/z/ZagrasThiefOfHeartbeats.java +++ b/Mage.Sets/src/mage/cards/z/ZagrasThiefOfHeartbeats.java @@ -16,7 +16,7 @@ import mage.cards.CardSetInfo; import mage.constants.*; import mage.filter.StaticFilters; import mage.game.Game; -import mage.game.events.DamagedPlaneswalkerEvent; +import mage.game.events.DamagedEvent; import mage.game.events.GameEvent; import mage.game.permanent.Permanent; import mage.target.targetpointer.FixedTarget; @@ -88,12 +88,12 @@ class ZagrasThiefOfHeartbeatsTriggeredAbility extends TriggeredAbilityImpl { @Override public boolean checkEventType(GameEvent event, Game game) { - return event.getType() == GameEvent.EventType.DAMAGED_PLANESWALKER; + return event.getType() == GameEvent.EventType.DAMAGED_PERMANENT; } @Override public boolean checkTrigger(GameEvent event, Game game) { - if (!((DamagedPlaneswalkerEvent) event).isCombatDamage()) { + if (!((DamagedEvent) event).isCombatDamage()) { return false; } Permanent permanent = game.getPermanentOrLKIBattlefield(event.getSourceId()); @@ -102,6 +102,10 @@ class ZagrasThiefOfHeartbeatsTriggeredAbility extends TriggeredAbilityImpl { || !permanent.isControlledBy(getControllerId())) { return false; } + Permanent damaged = game.getPermanentOrLKIBattlefield(event.getTargetId()); + if (damaged == null || !permanent.isPlaneswalker()) { + return false; + } this.getEffects().clear(); this.addEffect(new DestroyTargetEffect().setTargetPointer(new FixedTarget(event.getTargetId(), game))); return true; diff --git a/Mage.Tests/src/test/java/org/mage/test/cards/damage/ExcessDamageTest.java b/Mage.Tests/src/test/java/org/mage/test/cards/damage/ExcessDamageTest.java new file mode 100644 index 0000000000..b0ab321223 --- /dev/null +++ b/Mage.Tests/src/test/java/org/mage/test/cards/damage/ExcessDamageTest.java @@ -0,0 +1,139 @@ +package org.mage.test.cards.damage; + +import mage.constants.PhaseStep; +import mage.constants.Zone; +import org.junit.Test; +import org.mage.test.serverside.base.CardTestPlayerBase; + +/** + * @author TheElk801 + */ +public class ExcessDamageTest extends CardTestPlayerBase { + + private static final String spill = "Flame Spill"; + private static final String bear = "Grizzly Bears"; + private static final String jab = "Flame Jab"; + private static final String spirit = "Pestilent Spirit"; + private static final String myr = "Darksteel Myr"; + private static final String gideon = "Gideon Jura"; + private static final String leyline = "Leyline of Punishment"; + private static final String bolt = "Lightning Bolt"; + private static final String aegar = "Aegar, the Freezing Flame"; + + @Test + public void testExcessDamageRegular() { + addCard(Zone.BATTLEFIELD, playerA, "Mountain", 3); + addCard(Zone.BATTLEFIELD, playerA, bear); + addCard(Zone.HAND, playerA, spill); + + setStrictChooseMode(true); + castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerA, spill, bear); + + setStopAt(1, PhaseStep.END_TURN); + execute(); + assertAllCommandsUsed(); + + assertGraveyardCount(playerA, bear, 1); + assertPermanentCount(playerA, bear, 0); + assertLife(playerA, 20 - 2); + } + + @Test + public void testExcessDamageAlreadyDamaged() { + addCard(Zone.BATTLEFIELD, playerA, "Mountain", 4); + addCard(Zone.BATTLEFIELD, playerA, bear); + addCard(Zone.HAND, playerA, spill); + addCard(Zone.HAND, playerA, jab); + + setStrictChooseMode(true); + castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerA, jab, bear); + castSpell(1, PhaseStep.POSTCOMBAT_MAIN, playerA, spill, bear); + + setStopAt(1, PhaseStep.END_TURN); + execute(); + assertAllCommandsUsed(); + + assertGraveyardCount(playerA, bear, 1); + assertPermanentCount(playerA, bear, 0); + assertLife(playerA, 20 - 3); + } + + @Test + public void testExcessDamageDeathtouch() { + addCard(Zone.BATTLEFIELD, playerA, "Mountain", 3); + addCard(Zone.BATTLEFIELD, playerA, bear); + addCard(Zone.BATTLEFIELD, playerA, spirit); + addCard(Zone.HAND, playerA, spill); + + setStrictChooseMode(true); + castSpell(1, PhaseStep.POSTCOMBAT_MAIN, playerA, spill, bear); + + setStopAt(1, PhaseStep.END_TURN); + execute(); + assertAllCommandsUsed(); + + assertGraveyardCount(playerA, bear, 1); + assertPermanentCount(playerA, bear, 0); + assertLife(playerA, 20 - 3); + } + + @Test + public void testExcessDamageIndestructible() { + addCard(Zone.BATTLEFIELD, playerA, "Mountain", 3); + addCard(Zone.BATTLEFIELD, playerA, myr); + addCard(Zone.HAND, playerA, spill); + + setStrictChooseMode(true); + castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerA, spill, myr); + + setStopAt(1, PhaseStep.END_TURN); + execute(); + assertAllCommandsUsed(); + + assertGraveyardCount(playerA, myr, 0); + assertPermanentCount(playerA, myr, 1); + assertLife(playerA, 20 - 3); + } + + @Test + public void testExcessDamagePlaneswalker() { + addCard(Zone.BATTLEFIELD, playerA, "Mountain", 4); + addCard(Zone.BATTLEFIELD, playerA, gideon); + addCard(Zone.BATTLEFIELD, playerA, leyline); + addCard(Zone.HAND, playerA, spill); + addCard(Zone.HAND, playerA, bolt); + + setStrictChooseMode(true); + castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerA, bolt, gideon); + activateAbility(1, PhaseStep.PRECOMBAT_MAIN, playerA, "0:"); + + castSpell(1, PhaseStep.POSTCOMBAT_MAIN, playerA, spill, gideon); + + setStopAt(1, PhaseStep.END_TURN); + execute(); + assertAllCommandsUsed(); + + assertGraveyardCount(playerA, gideon, 1); + assertPermanentCount(playerA, gideon, 0); + assertLife(playerA, 20 - 1); + } + + @Test + public void testAegarTheFreezingFlame() { + addCard(Zone.BATTLEFIELD, playerA, "Mountain"); + addCard(Zone.BATTLEFIELD, playerA, aegar); + addCard(Zone.HAND, playerA, bolt); + addCard(Zone.BATTLEFIELD, playerB, bear); + + setStrictChooseMode(true); + castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerA, bolt, bear); + + setStopAt(1, PhaseStep.END_TURN); + execute(); + assertAllCommandsUsed(); + + assertHandCount(playerA, 1); + assertGraveyardCount(playerA, bolt, 1); + assertGraveyardCount(playerB, bear, 1); + } +} diff --git a/Mage.Tests/src/test/java/org/mage/test/cards/planeswalker/GideonTest.java b/Mage.Tests/src/test/java/org/mage/test/cards/planeswalker/GideonTest.java index 1be98c454c..bf4b85a803 100644 --- a/Mage.Tests/src/test/java/org/mage/test/cards/planeswalker/GideonTest.java +++ b/Mage.Tests/src/test/java/org/mage/test/cards/planeswalker/GideonTest.java @@ -7,7 +7,6 @@ import mage.constants.Zone; import mage.counters.CounterType; import mage.game.permanent.Permanent; import org.junit.Assert; -import org.junit.Ignore; import org.junit.Test; import org.mage.test.serverside.base.CardTestPlayerBase; @@ -142,23 +141,44 @@ public class GideonTest extends CardTestPlayerBase { assertGraveyardCount(playerB, "Kytheon, Hero of Akros", 1); } - @Ignore @Test - public void testGideonJura() { - // TODO: this test fails because of how damage is currently handled + public void testGideonJuraNoPrevention() { addCard(Zone.BATTLEFIELD, playerA, "Mountain"); addCard(Zone.BATTLEFIELD, playerA, "Gideon Jura"); addCard(Zone.BATTLEFIELD, playerA, "Leyline of Punishment"); addCard(Zone.HAND, playerA, "Lightning Bolt"); + setStrictChooseMode(true); activateAbility(1, PhaseStep.PRECOMBAT_MAIN, playerA, "0:"); castSpell(1, PhaseStep.POSTCOMBAT_MAIN, playerA, "Lightning Bolt", "Gideon Jura"); setStopAt(1, PhaseStep.END_TURN); execute(); + assertAllCommandsUsed(); assertType("Gideon Jura", CardType.CREATURE, true); assertDamageReceived(playerA, "Gideon Jura", 3); assertCounterCount(playerA, "Gideon Jura", CounterType.LOYALTY, 3); } + + @Test + public void testGideonJuraNoPreventionCombat() { + addCard(Zone.BATTLEFIELD, playerA, "Gideon Jura"); + addCard(Zone.BATTLEFIELD, playerA, "Leyline of Punishment"); + addCard(Zone.BATTLEFIELD, playerB, "Grizzly Bears"); + + setStrictChooseMode(true); + activateAbility(1, PhaseStep.PRECOMBAT_MAIN, playerA, "0:"); + attack(1, playerA, "Gideon Jura", playerB); + block(1, playerB, "Grizzly Bears", "Gideon Jura"); + + setStopAt(1, PhaseStep.END_TURN); + execute(); + assertAllCommandsUsed(); + + assertType("Gideon Jura", CardType.CREATURE, true); + assertDamageReceived(playerA, "Gideon Jura", 2); + assertCounterCount(playerA, "Gideon Jura", CounterType.LOYALTY, 4); + assertGraveyardCount(playerB, "Grizzly Bears", 1); + } } diff --git a/Mage.Tests/src/test/java/org/mage/test/combat/DamageDistributionTest.java b/Mage.Tests/src/test/java/org/mage/test/combat/DamageDistributionTest.java index cb268a8524..5299ed5260 100644 --- a/Mage.Tests/src/test/java/org/mage/test/combat/DamageDistributionTest.java +++ b/Mage.Tests/src/test/java/org/mage/test/combat/DamageDistributionTest.java @@ -9,7 +9,6 @@ import org.junit.Test; import org.mage.test.serverside.base.CardTestPlayerBase; /** - * * @author ayrat */ public class DamageDistributionTest extends CardTestPlayerBase { diff --git a/Mage/src/main/java/mage/abilities/common/DealsCombatDamageToACreatureTriggeredAbility.java b/Mage/src/main/java/mage/abilities/common/DealsCombatDamageToACreatureTriggeredAbility.java index b52fe3d4b7..a274a331ef 100644 --- a/Mage/src/main/java/mage/abilities/common/DealsCombatDamageToACreatureTriggeredAbility.java +++ b/Mage/src/main/java/mage/abilities/common/DealsCombatDamageToACreatureTriggeredAbility.java @@ -2,24 +2,24 @@ package mage.abilities.common; -import mage.constants.Zone; import mage.abilities.TriggeredAbilityImpl; import mage.abilities.effects.Effect; +import mage.constants.Zone; import mage.game.Game; -import mage.game.events.DamagedCreatureEvent; +import mage.game.events.DamagedEvent; import mage.game.events.GameEvent; +import mage.game.permanent.Permanent; import mage.target.targetpointer.FixedTarget; /** - * * @author LevelX */ public class DealsCombatDamageToACreatureTriggeredAbility extends TriggeredAbilityImpl { - private boolean setTargetPointer; + private final boolean setTargetPointer; public DealsCombatDamageToACreatureTriggeredAbility(Effect effect, boolean optional) { - this(effect, optional, false); + this(effect, optional, false); } public DealsCombatDamageToACreatureTriggeredAbility(Effect effect, boolean optional, boolean setTargetPointer) { @@ -28,38 +28,41 @@ public class DealsCombatDamageToACreatureTriggeredAbility extends TriggeredAbili } public DealsCombatDamageToACreatureTriggeredAbility(final DealsCombatDamageToACreatureTriggeredAbility ability) { - super(ability); - this.setTargetPointer = ability.setTargetPointer; + super(ability); + this.setTargetPointer = ability.setTargetPointer; } @Override public DealsCombatDamageToACreatureTriggeredAbility copy() { - return new DealsCombatDamageToACreatureTriggeredAbility(this); + return new DealsCombatDamageToACreatureTriggeredAbility(this); } @Override public boolean checkEventType(GameEvent event, Game game) { - return event.getType() == GameEvent.EventType.DAMAGED_CREATURE; + return event.getType() == GameEvent.EventType.DAMAGED_PERMANENT; } @Override public boolean checkTrigger(GameEvent event, Game game) { - if (event.getSourceId().equals(this.sourceId) - && ((DamagedCreatureEvent) event).isCombatDamage()) { - if (setTargetPointer) { - for (Effect effect : this.getEffects()) { - effect.setTargetPointer(new FixedTarget(event.getTargetId())); - effect.setValue("damage", event.getAmount()); - } - } - return true; + Permanent permanent = game.getPermanent(event.getTargetId()); + if (permanent == null + || !permanent.isCreature() + || !event.getSourceId().equals(this.sourceId) + || !((DamagedEvent) event).isCombatDamage()) { + return false; } - return false; + if (setTargetPointer) { + for (Effect effect : this.getEffects()) { + effect.setTargetPointer(new FixedTarget(event.getTargetId(), game)); + effect.setValue("damage", event.getAmount()); + } + } + return true; } @Override public String getRule() { - return "Whenever {this} deals combat damage to a creature, " + super.getRule(); + return "Whenever {this} deals combat damage to a creature, " + super.getRule(); } } diff --git a/Mage/src/main/java/mage/abilities/common/DealsCombatDamageToAPlayerTriggeredAbility.java b/Mage/src/main/java/mage/abilities/common/DealsCombatDamageToAPlayerTriggeredAbility.java index e05f4cf3bb..dd9bb2a0b8 100644 --- a/Mage/src/main/java/mage/abilities/common/DealsCombatDamageToAPlayerTriggeredAbility.java +++ b/Mage/src/main/java/mage/abilities/common/DealsCombatDamageToAPlayerTriggeredAbility.java @@ -6,7 +6,7 @@ import mage.constants.Zone; import mage.game.Game; import mage.game.events.DamagedEvent; import mage.game.events.GameEvent; -import mage.players.Player; +import mage.game.permanent.Permanent; import mage.target.targetpointer.FixedTarget; /** @@ -60,28 +60,34 @@ public class DealsCombatDamageToAPlayerTriggeredAbility extends TriggeredAbility @Override public boolean checkEventType(GameEvent event, Game game) { return event.getType() == GameEvent.EventType.DAMAGED_PLAYER - || (orPlaneswalker && event.getType() == GameEvent.EventType.DAMAGED_PLANESWALKER); + || event.getType() == GameEvent.EventType.DAMAGED_PERMANENT; } @Override public boolean checkTrigger(GameEvent event, Game game) { - if (event.getSourceId().equals(getSourceId()) - && ((DamagedEvent) event).isCombatDamage()) { - if (onlyOpponents && event.getType() == GameEvent.EventType.DAMAGED_PLAYER) { - Player controller = game.getPlayer(getControllerId()); - if (controller == null || !controller.hasOpponent(event.getPlayerId(), 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; } - } - if (setTargetPointer) { - for (Effect effect : this.getAllEffects()) { - effect.setTargetPointer(new FixedTarget(event.getPlayerId())); - effect.setValue("damage", event.getAmount()); + break; + case DAMAGED_PERMANENT: + Permanent permanent = game.getPermanent(event.getTargetId()); + if (permanent == null + || !permanent.isPlaneswalker() + || !orPlaneswalker) { + return false; } - } - return true; } - return false; + if (setTargetPointer) { + getAllEffects().setTargetPointer(new FixedTarget(event.getPlayerId())); + getAllEffects().setValue("damage", event.getAmount()); + } + return true; } @Override diff --git a/Mage/src/main/java/mage/abilities/common/DealsDamageAttachedTriggeredAbility.java b/Mage/src/main/java/mage/abilities/common/DealsDamageAttachedTriggeredAbility.java index 67bd54fa2d..d0e35b23a2 100644 --- a/Mage/src/main/java/mage/abilities/common/DealsDamageAttachedTriggeredAbility.java +++ b/Mage/src/main/java/mage/abilities/common/DealsDamageAttachedTriggeredAbility.java @@ -28,9 +28,8 @@ public class DealsDamageAttachedTriggeredAbility extends TriggeredAbilityImpl { @Override public boolean checkEventType(GameEvent event, Game game) { - return event.getType() == GameEvent.EventType.DAMAGED_CREATURE - || event.getType() == GameEvent.EventType.DAMAGED_PLAYER - || event.getType() == GameEvent.EventType.DAMAGED_PLANESWALKER; + return event.getType() == GameEvent.EventType.DAMAGED_PERMANENT + || event.getType() == GameEvent.EventType.DAMAGED_PLAYER; } @Override diff --git a/Mage/src/main/java/mage/abilities/common/DealsDamageGainLifeSourceTriggeredAbility.java b/Mage/src/main/java/mage/abilities/common/DealsDamageGainLifeSourceTriggeredAbility.java index b1ba53cfad..14d3fca3b7 100644 --- a/Mage/src/main/java/mage/abilities/common/DealsDamageGainLifeSourceTriggeredAbility.java +++ b/Mage/src/main/java/mage/abilities/common/DealsDamageGainLifeSourceTriggeredAbility.java @@ -33,9 +33,8 @@ public class DealsDamageGainLifeSourceTriggeredAbility extends TriggeredAbilityI } @Override public boolean checkEventType(GameEvent event, Game game) { - return event.getType() == GameEvent.EventType.DAMAGED_CREATURE - || event.getType() == GameEvent.EventType.DAMAGED_PLAYER - || event.getType() == GameEvent.EventType.DAMAGED_PLANESWALKER; + return event.getType() == GameEvent.EventType.DAMAGED_PERMANENT + || event.getType() == GameEvent.EventType.DAMAGED_PLAYER; } @Override diff --git a/Mage/src/main/java/mage/abilities/common/DealsDamageToACreatureAllTriggeredAbility.java b/Mage/src/main/java/mage/abilities/common/DealsDamageToACreatureAllTriggeredAbility.java index bab40c4e4c..3c7402e585 100644 --- a/Mage/src/main/java/mage/abilities/common/DealsDamageToACreatureAllTriggeredAbility.java +++ b/Mage/src/main/java/mage/abilities/common/DealsDamageToACreatureAllTriggeredAbility.java @@ -6,14 +6,12 @@ import mage.constants.SetTargetPointer; import mage.constants.Zone; import mage.filter.FilterPermanent; import mage.game.Game; -import mage.game.events.DamagedCreatureEvent; +import mage.game.events.DamagedEvent; import mage.game.events.GameEvent; -import mage.game.events.GameEvent.EventType; import mage.game.permanent.Permanent; import mage.target.targetpointer.FixedTarget; /** - * * @author LevelX2 */ public class DealsDamageToACreatureAllTriggeredAbility extends TriggeredAbilityImpl { @@ -27,15 +25,15 @@ public class DealsDamageToACreatureAllTriggeredAbility extends TriggeredAbilityI * * @param effect * @param optional - * @param filterPermanent The filter that restricts which permanets have to - * trigger + * @param filterPermanent The filter that restricts which permanets have to + * trigger * @param setTargetPointer The target to be set to target pointer of the - * effect.
- * - PLAYER = player controlling the damage source.
- * - PERMANENT = source permanent.
- * - PERMANENT_TARGET = damaged creature. + * effect.
+ * - PLAYER = player controlling the damage source.
+ * - PERMANENT = source permanent.
+ * - PERMANENT_TARGET = damaged creature. * @param combatDamageOnly The flag to determine if only combat damage has - * to trigger + * to trigger */ public DealsDamageToACreatureAllTriggeredAbility(Effect effect, boolean optional, FilterPermanent filterPermanent, SetTargetPointer setTargetPointer, boolean combatDamageOnly) { super(Zone.BATTLEFIELD, effect, optional); @@ -58,37 +56,42 @@ public class DealsDamageToACreatureAllTriggeredAbility extends TriggeredAbilityI @Override public boolean checkEventType(GameEvent event, Game game) { - return event.getType() == GameEvent.EventType.DAMAGED_CREATURE; + return event.getType() == GameEvent.EventType.DAMAGED_PERMANENT; } @Override public boolean checkTrigger(GameEvent event, Game game) { - if (!combatDamageOnly || ((DamagedCreatureEvent) event).isCombatDamage()) { - Permanent permanent = game.getPermanentOrLKIBattlefield(event.getSourceId()); - if (permanent != null && filterPermanent.match(permanent, getSourceId(), getControllerId(), game)) { - for (Effect effect : this.getEffects()) { - effect.setValue("damage", event.getAmount()); - effect.setValue("sourceId", event.getSourceId()); - switch (setTargetPointer) { - case PLAYER: - effect.setTargetPointer(new FixedTarget(permanent.getControllerId())); - break; - case PERMANENT: - effect.setTargetPointer(new FixedTarget(permanent, game)); - break; - case PERMANENT_TARGET: - Permanent permanent_target = game.getPermanentOrLKIBattlefield(event.getTargetId()); - if (permanent_target != null) { - effect.setTargetPointer(new FixedTarget(permanent_target, game)); - } - break; - } - - } - return true; - } + Permanent permanent = game.getPermanent(event.getTargetId()); + if (permanent == null || !permanent.isCreature()) { + return false; } - return false; + if (combatDamageOnly && !((DamagedEvent) event).isCombatDamage()) { + return false; + } + permanent = game.getPermanentOrLKIBattlefield(event.getSourceId()); + if (permanent == null || !filterPermanent.match(permanent, getSourceId(), getControllerId(), game)) { + return false; + } + for (Effect effect : this.getEffects()) { + effect.setValue("damage", event.getAmount()); + effect.setValue("sourceId", event.getSourceId()); + switch (setTargetPointer) { + case PLAYER: + effect.setTargetPointer(new FixedTarget(permanent.getControllerId())); + break; + case PERMANENT: + effect.setTargetPointer(new FixedTarget(permanent, game)); + break; + case PERMANENT_TARGET: + Permanent permanent_target = game.getPermanentOrLKIBattlefield(event.getTargetId()); + if (permanent_target != null) { + effect.setTargetPointer(new FixedTarget(permanent_target, game)); + } + break; + } + + } + return true; } @Override diff --git a/Mage/src/main/java/mage/abilities/common/DealsDamageToACreatureAttachedTriggeredAbility.java b/Mage/src/main/java/mage/abilities/common/DealsDamageToACreatureAttachedTriggeredAbility.java index 10a3024d06..2fa50eb6e3 100644 --- a/Mage/src/main/java/mage/abilities/common/DealsDamageToACreatureAttachedTriggeredAbility.java +++ b/Mage/src/main/java/mage/abilities/common/DealsDamageToACreatureAttachedTriggeredAbility.java @@ -6,7 +6,7 @@ import mage.abilities.TriggeredAbilityImpl; import mage.abilities.effects.Effect; import mage.constants.Zone; import mage.game.Game; -import mage.game.events.DamagedCreatureEvent; +import mage.game.events.DamagedEvent; import mage.game.events.GameEvent; import mage.game.permanent.Permanent; import mage.target.targetpointer.FixedTarget; @@ -40,12 +40,12 @@ public class DealsDamageToACreatureAttachedTriggeredAbility extends TriggeredAbi @Override public boolean checkEventType(GameEvent event, Game game) { - return event.getType() == GameEvent.EventType.DAMAGED_CREATURE; + return event.getType() == GameEvent.EventType.DAMAGED_PERMANENT; } @Override public boolean checkTrigger(GameEvent event, Game game) { - if (!combatOnly || ((DamagedCreatureEvent) event).isCombatDamage()) { + if (!combatOnly || ((DamagedEvent) event).isCombatDamage()) { Permanent attachment = game.getPermanent(this.getSourceId()); if (attachment != null && attachment.isAttachedTo(event.getSourceId())) { diff --git a/Mage/src/main/java/mage/abilities/common/DealsDamageToACreatureTriggeredAbility.java b/Mage/src/main/java/mage/abilities/common/DealsDamageToACreatureTriggeredAbility.java index faa6551756..44b81118df 100644 --- a/Mage/src/main/java/mage/abilities/common/DealsDamageToACreatureTriggeredAbility.java +++ b/Mage/src/main/java/mage/abilities/common/DealsDamageToACreatureTriggeredAbility.java @@ -6,7 +6,7 @@ import mage.abilities.TriggeredAbilityImpl; import mage.abilities.effects.Effect; import mage.filter.common.FilterCreaturePermanent; import mage.game.Game; -import mage.game.events.DamagedCreatureEvent; +import mage.game.events.DamagedEvent; import mage.game.events.GameEvent; import mage.game.permanent.Permanent; import mage.target.targetpointer.FixedTarget; @@ -46,13 +46,13 @@ public class DealsDamageToACreatureTriggeredAbility extends TriggeredAbilityImpl @Override public boolean checkEventType(GameEvent event, Game game) { - return event.getType() == GameEvent.EventType.DAMAGED_CREATURE; + return event.getType() == GameEvent.EventType.DAMAGED_PERMANENT; } @Override public boolean checkTrigger(GameEvent event, Game game) { if (event.getSourceId().equals(this.sourceId) - && (!combatOnly || ((DamagedCreatureEvent) event).isCombatDamage())) { + && (!combatOnly || ((DamagedEvent) event).isCombatDamage())) { if (filter != null) { Permanent creature = game.getPermanentOrLKIBattlefield(event.getTargetId()); if (creature == null || !filter.match(creature, getSourceId(), getControllerId(), game)) { diff --git a/Mage/src/main/java/mage/abilities/common/DealsDamageToAPlayerTriggeredAbility.java b/Mage/src/main/java/mage/abilities/common/DealsDamageToAPlayerTriggeredAbility.java index 289743355a..775b7db563 100644 --- a/Mage/src/main/java/mage/abilities/common/DealsDamageToAPlayerTriggeredAbility.java +++ b/Mage/src/main/java/mage/abilities/common/DealsDamageToAPlayerTriggeredAbility.java @@ -7,6 +7,7 @@ import mage.abilities.effects.Effect; import mage.constants.Zone; import mage.game.Game; import mage.game.events.GameEvent; +import mage.game.permanent.Permanent; import mage.target.targetpointer.FixedTarget; /** @@ -44,21 +45,27 @@ public class DealsDamageToAPlayerTriggeredAbility extends TriggeredAbilityImpl { @Override public boolean checkEventType(GameEvent event, Game game) { return event.getType() == GameEvent.EventType.DAMAGED_PLAYER - || (orPlaneswalker && event.getType() == GameEvent.EventType.DAMAGED_PLANESWALKER); + || event.getType() == GameEvent.EventType.DAMAGED_PERMANENT; } @Override public boolean checkTrigger(GameEvent event, Game game) { - if (event.getSourceId().equals(this.sourceId)) { - if (setTargetPointer) { - for (Effect effect : this.getEffects()) { - effect.setTargetPointer(new FixedTarget(event.getPlayerId())); - effect.setValue("damage", event.getAmount()); - } - } - return true; + if (!event.getSourceId().equals(this.sourceId)) { + return false; } - return false; + if (event.getType() == GameEvent.EventType.DAMAGED_PERMANENT) { + Permanent permanent = game.getPermanent(event.getTargetId()); + if (permanent == null + || !permanent.isPlaneswalker() + || !orPlaneswalker) { + return false; + } + } + if (setTargetPointer) { + getEffects().setTargetPointer(new FixedTarget(event.getPlayerId())); + getEffects().setValue("damage", event.getAmount()); + } + return true; } @Override diff --git a/Mage/src/main/java/mage/abilities/common/DealtDamageAttachedTriggeredAbility.java b/Mage/src/main/java/mage/abilities/common/DealtDamageAttachedTriggeredAbility.java index 65d6407e3c..a23a25a99e 100644 --- a/Mage/src/main/java/mage/abilities/common/DealtDamageAttachedTriggeredAbility.java +++ b/Mage/src/main/java/mage/abilities/common/DealtDamageAttachedTriggeredAbility.java @@ -41,7 +41,7 @@ public class DealtDamageAttachedTriggeredAbility extends TriggeredAbilityImpl { @Override public boolean checkEventType(GameEvent event, Game game) { - return event.getType() == GameEvent.EventType.DAMAGED_CREATURE; + return event.getType() == GameEvent.EventType.DAMAGED_PERMANENT; } @Override diff --git a/Mage/src/main/java/mage/abilities/common/DealtDamageToSourceTriggeredAbility.java b/Mage/src/main/java/mage/abilities/common/DealtDamageToSourceTriggeredAbility.java index bbd23b4cbb..9f99078951 100644 --- a/Mage/src/main/java/mage/abilities/common/DealtDamageToSourceTriggeredAbility.java +++ b/Mage/src/main/java/mage/abilities/common/DealtDamageToSourceTriggeredAbility.java @@ -5,7 +5,7 @@ import mage.abilities.TriggeredAbilityImpl; import mage.abilities.effects.Effect; import mage.constants.Zone; import mage.game.Game; -import mage.game.events.DamagedCreatureEvent; +import mage.game.events.DamagedEvent; import mage.game.events.GameEvent; /** @@ -46,12 +46,12 @@ public class DealtDamageToSourceTriggeredAbility extends TriggeredAbilityImpl { @Override public boolean checkEventType(GameEvent event, Game game) { - return event.getType() == GameEvent.EventType.DAMAGED_CREATURE || event.getType() == GameEvent.EventType.COMBAT_DAMAGE_STEP_POST; + return event.getType() == GameEvent.EventType.DAMAGED_PERMANENT || event.getType() == GameEvent.EventType.COMBAT_DAMAGE_STEP_POST; } @Override public boolean checkTrigger(GameEvent event, Game game) { - if (event.getType() == GameEvent.EventType.DAMAGED_CREATURE && event.getTargetId().equals(getSourceId())) { + if (event.getType() == GameEvent.EventType.DAMAGED_PERMANENT && event.getTargetId().equals(getSourceId())) { if (useValue) { // TODO: this ability should only trigger once for multiple creatures dealing combat damage. // If the damaged creature uses the amount (e.g. Boros Reckoner), this will still trigger separately instead of all at once @@ -60,7 +60,7 @@ public class DealtDamageToSourceTriggeredAbility extends TriggeredAbilityImpl { } return true; } else { - if (((DamagedCreatureEvent) event).isCombatDamage()) { + if (((DamagedEvent) event).isCombatDamage()) { if (!usedForCombatDamageStep) { usedForCombatDamageStep = true; return true; diff --git a/Mage/src/main/java/mage/abilities/common/DestroyPlaneswalkerWhenDamagedTriggeredAbility.java b/Mage/src/main/java/mage/abilities/common/DestroyPlaneswalkerWhenDamagedTriggeredAbility.java index 1d8eabc2bd..4e31e7ec9a 100644 --- a/Mage/src/main/java/mage/abilities/common/DestroyPlaneswalkerWhenDamagedTriggeredAbility.java +++ b/Mage/src/main/java/mage/abilities/common/DestroyPlaneswalkerWhenDamagedTriggeredAbility.java @@ -35,22 +35,23 @@ public class DestroyPlaneswalkerWhenDamagedTriggeredAbility extends TriggeredAbi @Override public boolean checkEventType(GameEvent event, Game game) { - return event.getType() == GameEvent.EventType.DAMAGED_PLANESWALKER; + return event.getType() == GameEvent.EventType.DAMAGED_PERMANENT; } @Override public boolean checkTrigger(GameEvent event, Game game) { Permanent permanent = getSourcePermanentIfItStillExists(game); - if (permanent != null) { - boolean applies = filter != null ? - filter.match(permanent, game) : event.getSourceId().equals(getSourceId()); - if (applies) { - Effect effect = new DestroyTargetEffect(); - effect.setTargetPointer(new FixedTarget(event.getTargetId(), game)); - this.getEffects().clear(); - this.addEffect(effect); - return true; - } + if (permanent == null) { + return false; + } + boolean applies = filter != null ? + permanent.isPlaneswalker() && filter.match(permanent, game) : event.getSourceId().equals(getSourceId()); + if (applies) { + Effect effect = new DestroyTargetEffect(); + effect.setTargetPointer(new FixedTarget(event.getTargetId(), game)); + this.getEffects().clear(); + this.addEffect(effect); + return true; } return false; } diff --git a/Mage/src/main/java/mage/abilities/effects/PreventionEffectImpl.java b/Mage/src/main/java/mage/abilities/effects/PreventionEffectImpl.java index 80e1a17f97..b98933c64e 100644 --- a/Mage/src/main/java/mage/abilities/effects/PreventionEffectImpl.java +++ b/Mage/src/main/java/mage/abilities/effects/PreventionEffectImpl.java @@ -96,9 +96,8 @@ public abstract class PreventionEffectImpl extends ReplacementEffectImpl impleme @Override public boolean checksEventType(GameEvent event, Game game) { switch (event.getType()) { - case DAMAGE_CREATURE: + case DAMAGE_PERMANENT: case DAMAGE_PLAYER: - case DAMAGE_PLANESWALKER: return true; } return false; diff --git a/Mage/src/main/java/mage/abilities/effects/RedirectionEffect.java b/Mage/src/main/java/mage/abilities/effects/RedirectionEffect.java index d5c0efaeeb..404791d020 100644 --- a/Mage/src/main/java/mage/abilities/effects/RedirectionEffect.java +++ b/Mage/src/main/java/mage/abilities/effects/RedirectionEffect.java @@ -52,9 +52,8 @@ public abstract class RedirectionEffect extends ReplacementEffectImpl { @Override public boolean checksEventType(GameEvent event, Game game) { switch (event.getType()) { - case DAMAGE_CREATURE: + case DAMAGE_PERMANENT: case DAMAGE_PLAYER: - case DAMAGE_PLANESWALKER: return true; } return false; diff --git a/Mage/src/main/java/mage/abilities/effects/common/continuous/AssignNoCombatDamageSourceEffect.java b/Mage/src/main/java/mage/abilities/effects/common/continuous/AssignNoCombatDamageSourceEffect.java index 0ec383d15b..81c3ad03b2 100644 --- a/Mage/src/main/java/mage/abilities/effects/common/continuous/AssignNoCombatDamageSourceEffect.java +++ b/Mage/src/main/java/mage/abilities/effects/common/continuous/AssignNoCombatDamageSourceEffect.java @@ -51,9 +51,8 @@ public class AssignNoCombatDamageSourceEffect extends ReplacementEffectImpl { @Override public boolean checksEventType(GameEvent event, Game game) { switch (event.getType()) { - case DAMAGE_CREATURE: + case DAMAGE_PERMANENT: case DAMAGE_PLAYER: - case DAMAGE_PLANESWALKER: return true; default: return false; diff --git a/Mage/src/main/java/mage/game/combat/CombatGroup.java b/Mage/src/main/java/mage/game/combat/CombatGroup.java index 0b501594ca..831e2544d8 100644 --- a/Mage/src/main/java/mage/game/combat/CombatGroup.java +++ b/Mage/src/main/java/mage/game/combat/CombatGroup.java @@ -8,7 +8,6 @@ import mage.abilities.keyword.*; import mage.constants.AsThoughEffectType; import mage.constants.Outcome; import mage.filter.StaticFilters; -import mage.filter.common.FilterCreaturePermanent; import mage.game.Game; import mage.game.events.BlockerDeclaredEvent; import mage.game.events.DeclareBlockerEvent; @@ -214,6 +213,12 @@ public class CombatGroup implements Serializable, Copyable { permanent.applyDamage(game); } } + if (defenderIsPlaneswalker) { + Permanent permanent = game.getPermanent(defenderId); + if (permanent != null) { + permanent.applyDamage(game); + } + } } /** @@ -896,27 +901,6 @@ public class CombatGroup implements Serializable, Copyable { } private static int getLethalDamage(Permanent blocker, Permanent attacker, Game game) { - int lethalDamage; - if (attacker.getAbilities().containsKey(DeathtouchAbility.getInstance().getId())) { - lethalDamage = 1; - } else { - lethalDamage = getLethalDamage(blocker, game); - } - return lethalDamage; - } - - public static int getLethalDamage(Permanent damagedPermanent, Game game) { - List usePowerInsteadOfToughnessForDamageLethalityFilters = game.getState().getActivePowerInsteadOfToughnessForDamageLethalityFilters(); - /* - * for handling Zilortha, Strength Incarnate: - * 2020-04-17 - * Any time the game is checking whether damage is lethal or if a creature should be destroyed for having lethal damage marked on it, use the power of your creatures rather than their toughness to check the damage against. This includes being assigned trample damage, damage from Flame Spill, and so on. - */ - boolean usePowerInsteadOfToughnessForDamageLethality = usePowerInsteadOfToughnessForDamageLethalityFilters.stream() - .anyMatch(filter -> filter.match(damagedPermanent, game)); - int lethalDamageThreshold = usePowerInsteadOfToughnessForDamageLethality ? - // Zilortha, Strength Incarnate, 2020-04-17: A creature with 0 power isn’t destroyed unless it has at least 1 damage marked on it. - Math.max(damagedPermanent.getPower().getValue(), 1) : damagedPermanent.getToughness().getValue(); - return Math.max(lethalDamageThreshold - damagedPermanent.getDamage(), 0); + return blocker.getLethalDamage(attacker.getId(), game); } } diff --git a/Mage/src/main/java/mage/game/command/emblems/AjaniSteadfastEmblem.java b/Mage/src/main/java/mage/game/command/emblems/AjaniSteadfastEmblem.java index ce2123de09..fe662cca7b 100644 --- a/Mage/src/main/java/mage/game/command/emblems/AjaniSteadfastEmblem.java +++ b/Mage/src/main/java/mage/game/command/emblems/AjaniSteadfastEmblem.java @@ -58,9 +58,9 @@ class AjaniSteadfastPreventEffect extends PreventionEffectImpl { return super.applies(event, source, game); } - if (event.getType() == GameEvent.EventType.DAMAGE_PLANESWALKER) { + if (event.getType() == GameEvent.EventType.DAMAGE_PERMANENT) { Permanent permanent = game.getPermanent(event.getTargetId()); - if (permanent != null && permanent.isControlledBy(source.getControllerId())) { + if (permanent != null && permanent.isPlaneswalker() && permanent.isControlledBy(source.getControllerId())) { return super.applies(event, source, game); } } diff --git a/Mage/src/main/java/mage/game/events/DamageCreatureEvent.java b/Mage/src/main/java/mage/game/events/DamageCreatureEvent.java deleted file mode 100644 index 9e3d1372db..0000000000 --- a/Mage/src/main/java/mage/game/events/DamageCreatureEvent.java +++ /dev/null @@ -1,14 +0,0 @@ -package mage.game.events; - -import java.util.UUID; - -/** - * - * @author BetaSteward_at_googlemail.com - */ -public class DamageCreatureEvent extends DamageEvent { - - public DamageCreatureEvent(UUID targetId, UUID damageSourceId, UUID targetControllerId, int amount, boolean preventable, boolean combat) { - super(GameEvent.EventType.DAMAGE_CREATURE, targetId, damageSourceId, targetControllerId, amount, preventable, combat); - } -} diff --git a/Mage/src/main/java/mage/game/events/DamageEvent.java b/Mage/src/main/java/mage/game/events/DamageEvent.java index 83b94ba537..431d1f7447 100644 --- a/Mage/src/main/java/mage/game/events/DamageEvent.java +++ b/Mage/src/main/java/mage/game/events/DamageEvent.java @@ -3,12 +3,13 @@ package mage.game.events; import java.util.UUID; /** - * * @author BetaSteward_at_googlemail.com */ public abstract class DamageEvent extends GameEvent { protected boolean combat; + private boolean asThoughInfect = false; + private boolean asThoughWither = false; public DamageEvent(EventType type, UUID targetId, UUID damageSourceId, UUID targetControllerId, int amount, boolean preventable, boolean combat) { super(type, targetId, null, targetControllerId, amount, preventable); @@ -24,4 +25,19 @@ public abstract class DamageEvent extends GameEvent { return flag; } + public void setAsThoughInfect(boolean asThoughInfect) { + this.asThoughInfect = asThoughInfect; + } + + public boolean isAsThoughInfect() { + return asThoughInfect; + } + + public void setAsThoughWither(boolean asThoughWither) { + this.asThoughWither = asThoughWither; + } + + public boolean isAsThoughWither() { + return asThoughWither; + } } diff --git a/Mage/src/main/java/mage/game/events/DamagePermanentEvent.java b/Mage/src/main/java/mage/game/events/DamagePermanentEvent.java new file mode 100644 index 0000000000..e0866cebdc --- /dev/null +++ b/Mage/src/main/java/mage/game/events/DamagePermanentEvent.java @@ -0,0 +1,13 @@ +package mage.game.events; + +import java.util.UUID; + +/** + * @author TheElk801 + */ +public class DamagePermanentEvent extends DamageEvent { + + public DamagePermanentEvent(UUID targetId, UUID damageSourceId, UUID targetControllerId, int amount, boolean preventable, boolean combat) { + super(EventType.DAMAGE_PERMANENT, targetId, damageSourceId, targetControllerId, amount, preventable, combat); + } +} diff --git a/Mage/src/main/java/mage/game/events/DamagePlaneswalkerEvent.java b/Mage/src/main/java/mage/game/events/DamagePlaneswalkerEvent.java deleted file mode 100644 index 5c7481c810..0000000000 --- a/Mage/src/main/java/mage/game/events/DamagePlaneswalkerEvent.java +++ /dev/null @@ -1,14 +0,0 @@ -package mage.game.events; - -import java.util.UUID; - -/** - * - * @author BetaSteward_at_googlemail.com - */ -public class DamagePlaneswalkerEvent extends DamageEvent { - - public DamagePlaneswalkerEvent(UUID targetId, UUID damageSourceId, UUID targetControllerId, int amount, boolean preventable, boolean combat) { - super(GameEvent.EventType.DAMAGE_PLANESWALKER, targetId, damageSourceId, targetControllerId, amount, preventable, combat); - } -} diff --git a/Mage/src/main/java/mage/game/events/DamagedBatchEvent.java b/Mage/src/main/java/mage/game/events/DamagedBatchEvent.java index a5e9885dcd..1d04ed124a 100644 --- a/Mage/src/main/java/mage/game/events/DamagedBatchEvent.java +++ b/Mage/src/main/java/mage/game/events/DamagedBatchEvent.java @@ -33,11 +33,8 @@ public abstract class DamagedBatchEvent extends GameEvent { if (damagedEvent instanceof DamagedPlayerEvent) { event = new DamagedPlayerBatchEvent(); event.addEvent(damagedEvent); - } else if (damagedEvent instanceof DamagedCreatureEvent) { - event = new DamagedCreatureBatchEvent(); - event.addEvent(damagedEvent); - } else if (damagedEvent instanceof DamagedPlaneswalkerEvent) { - event = new DamagedPlaneswalkerBatchEvent(); + } else if (damagedEvent instanceof DamagedPermanentEvent) { + event = new DamagedPermanentBatchEvent(); event.addEvent(damagedEvent); } return event; diff --git a/Mage/src/main/java/mage/game/events/DamagedCreatureBatchEvent.java b/Mage/src/main/java/mage/game/events/DamagedCreatureBatchEvent.java deleted file mode 100644 index 57fb3afc27..0000000000 --- a/Mage/src/main/java/mage/game/events/DamagedCreatureBatchEvent.java +++ /dev/null @@ -1,11 +0,0 @@ -package mage.game.events; - -/** - * @author TheElk801 - */ -public class DamagedCreatureBatchEvent extends DamagedBatchEvent { - - public DamagedCreatureBatchEvent() { - super(GameEvent.EventType.DAMAGED_CREATURE_BATCH, DamagedCreatureEvent.class); - } -} diff --git a/Mage/src/main/java/mage/game/events/DamagedCreatureEvent.java b/Mage/src/main/java/mage/game/events/DamagedCreatureEvent.java deleted file mode 100644 index 7272b5643e..0000000000 --- a/Mage/src/main/java/mage/game/events/DamagedCreatureEvent.java +++ /dev/null @@ -1,16 +0,0 @@ - - -package mage.game.events; - -import java.util.UUID; - -/** - * - * @author BetaSteward_at_googlemail.com - */ -public class DamagedCreatureEvent extends DamagedEvent { - - public DamagedCreatureEvent(UUID targetId, UUID attackerId, UUID playerId, int amount, boolean combat) { - super(GameEvent.EventType.DAMAGED_CREATURE, targetId, attackerId, playerId, amount, combat); - } -} diff --git a/Mage/src/main/java/mage/game/events/DamagedPermanentBatchEvent.java b/Mage/src/main/java/mage/game/events/DamagedPermanentBatchEvent.java new file mode 100644 index 0000000000..7ee26d5efd --- /dev/null +++ b/Mage/src/main/java/mage/game/events/DamagedPermanentBatchEvent.java @@ -0,0 +1,11 @@ +package mage.game.events; + +/** + * @author TheElk801 + */ +public class DamagedPermanentBatchEvent extends DamagedBatchEvent { + + public DamagedPermanentBatchEvent() { + super(EventType.DAMAGED_PERMANENT_BATCH, DamagedPermanentEvent.class); + } +} diff --git a/Mage/src/main/java/mage/game/events/DamagedPermanentEvent.java b/Mage/src/main/java/mage/game/events/DamagedPermanentEvent.java new file mode 100644 index 0000000000..9c97987751 --- /dev/null +++ b/Mage/src/main/java/mage/game/events/DamagedPermanentEvent.java @@ -0,0 +1,13 @@ +package mage.game.events; + +import java.util.UUID; + +/** + * @author TheElk801 + */ +public class DamagedPermanentEvent extends DamagedEvent { + + public DamagedPermanentEvent(UUID targetId, UUID attackerId, UUID playerId, int amount, boolean combat) { + super(EventType.DAMAGED_PERMANENT, targetId, attackerId, playerId, amount, combat); + } +} diff --git a/Mage/src/main/java/mage/game/events/DamagedPlaneswalkerBatchEvent.java b/Mage/src/main/java/mage/game/events/DamagedPlaneswalkerBatchEvent.java deleted file mode 100644 index 9f74c2edb6..0000000000 --- a/Mage/src/main/java/mage/game/events/DamagedPlaneswalkerBatchEvent.java +++ /dev/null @@ -1,11 +0,0 @@ -package mage.game.events; - -/** - * @author TheElk801 - */ -public class DamagedPlaneswalkerBatchEvent extends DamagedBatchEvent { - - public DamagedPlaneswalkerBatchEvent() { - super(GameEvent.EventType.DAMAGED_PLANESWALKER_BATCH, DamagedPlaneswalkerEvent.class); - } -} diff --git a/Mage/src/main/java/mage/game/events/DamagedPlaneswalkerEvent.java b/Mage/src/main/java/mage/game/events/DamagedPlaneswalkerEvent.java deleted file mode 100644 index ed3092047c..0000000000 --- a/Mage/src/main/java/mage/game/events/DamagedPlaneswalkerEvent.java +++ /dev/null @@ -1,16 +0,0 @@ -package mage.game.events; - -import java.util.UUID; - -/** - * - * @author BetaSteward_at_googlemail.com - */ -public class DamagedPlaneswalkerEvent extends DamagedEvent { - - public DamagedPlaneswalkerEvent(UUID targetId, UUID attackerId, UUID playerId, int amount, boolean combat) { - super(GameEvent.EventType.DAMAGED_PLANESWALKER, targetId, null, playerId, amount, combat); - this.setSourceId(attackerId); - } - -} diff --git a/Mage/src/main/java/mage/game/events/GameEvent.java b/Mage/src/main/java/mage/game/events/GameEvent.java index 3268df767d..e2c5e3c94b 100644 --- a/Mage/src/main/java/mage/game/events/GameEvent.java +++ b/Mage/src/main/java/mage/game/events/GameEvent.java @@ -359,8 +359,9 @@ public class GameEvent implements Serializable { flag not used for this event */ OPTION_USED, - DAMAGE_CREATURE, DAMAGED_CREATURE, DAMAGED_CREATURE_BATCH, - DAMAGE_PLANESWALKER, DAMAGED_PLANESWALKER, DAMAGED_PLANESWALKER_BATCH, + DAMAGE_PERMANENT, + DAMAGED_PERMANENT, + DAMAGED_PERMANENT_BATCH, DESTROY_PERMANENT, /* DESTROY_PERMANENT_BY_LEGENDARY_RULE targetId id of the permanent to destroy @@ -492,8 +493,7 @@ public class GameEvent implements Serializable { return new GameEvent(customEventType, targetId, source, playerId); } - private GameEvent(EventType type, UUID customEventType, UUID targetId, Ability source, UUID playerId, int amount, boolean flag) - { + private GameEvent(EventType type, UUID customEventType, UUID targetId, Ability source, UUID playerId, int amount, boolean flag) { this(type, customEventType, targetId, source, playerId, amount, flag, null); } diff --git a/Mage/src/main/java/mage/game/permanent/Permanent.java b/Mage/src/main/java/mage/game/permanent/Permanent.java index 1e11940375..f1f195758c 100644 --- a/Mage/src/main/java/mage/game/permanent/Permanent.java +++ b/Mage/src/main/java/mage/game/permanent/Permanent.java @@ -101,7 +101,7 @@ public interface Permanent extends Card, Controllable { /** * @param attachment - * @param source can be null for default checks like state base + * @param source can be null for default checks like state base * @param game * @param silentMode - use it to ignore warning message for users (e.g. for * checking only) @@ -123,8 +123,8 @@ public interface Permanent extends Card, Controllable { * Uses in replace events only * * @param damage - * @param attackerId id of the permanent or player who make damage (source.getSourceId() in most cases) - * @param source can be null for default game actions like combat + * @param attackerId id of the permanent or player who make damage (source.getSourceId() in most cases) + * @param source can be null for default game actions like combat * @param game * @param combat * @param preventable @@ -137,8 +137,8 @@ public interface Permanent extends Card, Controllable { * Uses in combat only to deal damage at the same time * * @param damage - * @param attackerId id of the permanent or player who make damage (source.getSourceId() in most cases) - * @param source can be null for default game actions like combat + * @param attackerId id of the permanent or player who make damage (source.getSourceId() in most cases) + * @param source can be null for default game actions like combat * @param game * @param preventable * @param combat @@ -150,6 +150,8 @@ public interface Permanent extends Card, Controllable { int applyDamage(Game game); + int getLethalDamage(UUID attackerId, Game game); + void removeAllDamage(Game game); void reset(Game game); @@ -159,7 +161,6 @@ public interface Permanent extends Card, Controllable { boolean destroy(Ability source, Game game, boolean noRegen); /** - * * @param source can be null for state base actions * @param game * @return diff --git a/Mage/src/main/java/mage/game/permanent/PermanentImpl.java b/Mage/src/main/java/mage/game/permanent/PermanentImpl.java index 7e5365d342..e78dee5f1c 100644 --- a/Mage/src/main/java/mage/game/permanent/PermanentImpl.java +++ b/Mage/src/main/java/mage/game/permanent/PermanentImpl.java @@ -50,15 +50,17 @@ public abstract class PermanentImpl extends CardImpl implements Permanent { private static final Logger logger = Logger.getLogger(PermanentImpl.class); - static class MarkedDamageInfo implements Serializable { + private static class MarkedDamageInfo implements Serializable { - public MarkedDamageInfo(Counter counter, MageObject sourceObject) { + private final Counter counter; + private final MageObject sourceObject; + private final boolean addCounters; + + private MarkedDamageInfo(Counter counter, MageObject sourceObject, boolean addCounters) { this.counter = counter; this.sourceObject = sourceObject; + this.addCounters = addCounters; } - - Counter counter; - MageObject sourceObject; } private static final ThreadLocalStringBuilder threadLocalBuilder = new ThreadLocalStringBuilder(300); @@ -146,7 +148,7 @@ public abstract class PermanentImpl extends CardImpl implements Permanent { if (permanent.markedDamage != null) { markedDamage = new ArrayList<>(); for (MarkedDamageInfo mdi : permanent.markedDamage) { - markedDamage.add(new MarkedDamageInfo(mdi.counter.copy(), mdi.sourceObject)); + markedDamage.add(new MarkedDamageInfo(mdi.counter.copy(), mdi.sourceObject, mdi.addCounters)); } } if (permanent.info != null) { @@ -864,71 +866,127 @@ public abstract class PermanentImpl extends CardImpl implements Permanent { */ private int doDamage(int damageAmount, UUID attackerId, Ability source, Game game, boolean preventable, boolean combat, boolean markDamage, List appliedEffects) { int damageDone = 0; - if (damageAmount > 0 && canDamage(game.getObject(attackerId), game)) { - if (this.isPlaneswalker()) { - damageDone = damagePlaneswalker(damageAmount, attackerId, source, game, preventable, combat, markDamage, appliedEffects); + if (damageAmount < 1 || !canDamage(game.getObject(attackerId), game)) { + return 0; + } + DamageEvent event = new DamagePermanentEvent(objectId, attackerId, controllerId, damageAmount, preventable, combat); + event.setAppliedEffects(appliedEffects); + if (game.replaceEvent(event)) { + return 0; + } + int actualDamage = checkProtectionAbilities(event, attackerId, source, game); + if (actualDamage < 1) { + return 0; + } + int lethal = getLethalDamage(attackerId, game); + MageObject attacker = game.getObject(attackerId); + if (this.isCreature()) { + if (checkWither(event, attacker, game)) { + if (markDamage) { + // mark damage only + markDamage(CounterType.M1M1.createInstance(actualDamage), attacker, true); + } else { + Ability damageSourceAbility = null; + if (attacker instanceof Permanent) { + damageSourceAbility = ((Permanent) attacker).getSpellAbility(); + } + // deal damage immediately + addCounters(CounterType.M1M1.createInstance(actualDamage), game.getControllerId(attackerId), damageSourceAbility, game); + } } else { - damageDone = damageCreature(damageAmount, attackerId, source, game, preventable, combat, markDamage, appliedEffects); - } - if (damageDone > 0) { - UUID sourceControllerId = null; - Abilities sourceAbilities = null; - MageObject attacker = game.getPermanentOrLKIBattlefield(attackerId); - if (attacker == null) { - StackObject stackObject = game.getStack().getStackObject(attackerId); - if (stackObject != null) { - attacker = stackObject.getStackAbility().getSourceObject(game); - } else { - attacker = game.getObject(attackerId); - } - if (attacker instanceof Spell) { - sourceAbilities = ((Spell) attacker).getAbilities(game); - sourceControllerId = ((Spell) attacker).getControllerId(); - } else if (attacker instanceof Card) { - sourceAbilities = ((Card) attacker).getAbilities(game); - sourceControllerId = ((Card) attacker).getOwnerId(); - } else if (attacker instanceof CommandObject) { - sourceControllerId = ((CommandObject) attacker).getControllerId(); - sourceAbilities = attacker.getAbilities(); - } else { - attacker = null; - } - } else { - sourceAbilities = ((Permanent) attacker).getAbilities(game); - sourceControllerId = ((Permanent) attacker).getControllerId(); - } - if (attacker != null && sourceAbilities != null) { - if (sourceAbilities.containsKey(LifelinkAbility.getInstance().getId())) { - if (markDamage) { - game.getPermanent(attackerId).markLifelink(damageDone); - } else { - Player player = game.getPlayer(sourceControllerId); - player.gainLife(damageDone, game, source); - } - } - if (sourceAbilities.containsKey(DeathtouchAbility.getInstance().getId())) { - deathtouched = true; - } - if (dealtDamageByThisTurn == null) { - dealtDamageByThisTurn = new HashSet<>(); - } - // Unstable ability - Earl of Squirrel - if (sourceAbilities.containsKey(SquirrellinkAbility.getInstance().getId())) { - Player player = game.getPlayer(sourceControllerId); - new SquirrelToken().putOntoBattlefield(damageDone, game, source, player.getId()); - } - dealtDamageByThisTurn.add(new MageObjectReference(attacker, game)); - } - if (attacker == null) { - game.informPlayers(getLogName() + " gets " + damageDone + " damage"); - } else { - game.informPlayers(attacker.getLogName() + " deals " + damageDone + " damage to " + getLogName()); - } + this.damage = CardUtil.overflowInc(this.damage, actualDamage); } } + if (this.isPlaneswalker()) { + int loyalty = getCounters(game).getCount(CounterType.LOYALTY); + int countersToRemove = Math.min(actualDamage, loyalty); + if (attacker != null && markDamage) { + markDamage(CounterType.LOYALTY.createInstance(countersToRemove), attacker, false); + } else { + removeCounters(CounterType.LOYALTY.getName(), countersToRemove, source, game); + } + } + DamagedEvent damagedEvent = new DamagedPermanentEvent(this.getId(), attackerId, this.getControllerId(), actualDamage, combat); + damagedEvent.setExcess(actualDamage - lethal); + game.fireEvent(damagedEvent); + game.getState().addSimultaneousDamage(damagedEvent, game); + damageDone = actualDamage; + if (damageDone < 1) { + return 0; + } + UUID sourceControllerId = null; + Abilities sourceAbilities = null; + attacker = game.getPermanentOrLKIBattlefield(attackerId); + if (attacker == null) { + StackObject stackObject = game.getStack().getStackObject(attackerId); + if (stackObject != null) { + attacker = stackObject.getStackAbility().getSourceObject(game); + } else { + attacker = game.getObject(attackerId); + } + if (attacker instanceof Spell) { + sourceAbilities = ((Spell) attacker).getAbilities(game); + sourceControllerId = ((Spell) attacker).getControllerId(); + } else if (attacker instanceof Card) { + sourceAbilities = ((Card) attacker).getAbilities(game); + sourceControllerId = ((Card) attacker).getOwnerId(); + } else if (attacker instanceof CommandObject) { + sourceControllerId = ((CommandObject) attacker).getControllerId(); + sourceAbilities = attacker.getAbilities(); + } else { + attacker = null; + } + } else { + sourceAbilities = ((Permanent) attacker).getAbilities(game); + sourceControllerId = ((Permanent) attacker).getControllerId(); + } + if (attacker != null && sourceAbilities != null) { + if (sourceAbilities.containsKey(LifelinkAbility.getInstance().getId())) { + if (markDamage) { + game.getPermanent(attackerId).markLifelink(damageDone); + } else { + Player player = game.getPlayer(sourceControllerId); + player.gainLife(damageDone, game, source); + } + } + if (sourceAbilities.containsKey(DeathtouchAbility.getInstance().getId())) { + deathtouched = true; + } + if (dealtDamageByThisTurn == null) { + dealtDamageByThisTurn = new HashSet<>(); + } + // Unstable ability - Earl of Squirrel + if (sourceAbilities.containsKey(SquirrellinkAbility.getInstance().getId())) { + Player player = game.getPlayer(sourceControllerId); + new SquirrelToken().putOntoBattlefield(damageDone, game, source, player.getId()); + } + dealtDamageByThisTurn.add(new MageObjectReference(attacker, game)); + } + if (attacker == null) { + game.informPlayers(getLogName() + " gets " + damageDone + " damage"); + } else { + game.informPlayers(attacker.getLogName() + " deals " + damageDone + " damage to " + getLogName()); + } return damageDone; } + private static boolean checkWither(DamageEvent event, MageObject attacker, Game game) { + if (event.isAsThoughWither() || event.isAsThoughInfect()) { + return true; + } + if (attacker == null) { + return false; + } + Abilities abilities; + if (attacker instanceof Card) { + abilities = ((Card) attacker).getAbilities(game); + } else { + abilities = attacker.getAbilities(); + } + return abilities.containsKey(InfectAbility.getInstance().getId()) + || abilities.containsKey(WitherAbility.getInstance().getId()); + } + @Override public void markLifelink(int damage) { markedLifelink += damage; @@ -960,81 +1018,43 @@ public abstract class PermanentImpl extends CardImpl implements Permanent { } else if (mdi.sourceObject instanceof Permanent) { source = ((Permanent) mdi.sourceObject).getSpellAbility(); } - addCounters(mdi.counter, game.getControllerId(mdi.sourceObject.getId()), source, game); + if (mdi.addCounters) { + addCounters(mdi.counter, game.getControllerId(mdi.sourceObject.getId()), source, game); + } else { + removeCounters(mdi.counter, source, game); + } } markedDamage.clear(); return 0; } + @Override + public int getLethalDamage(UUID attackerId, Game game) { + int lethal = Integer.MAX_VALUE; + if (this.isCreature()) { + if (game.getState().getActivePowerInsteadOfToughnessForDamageLethalityFilters().stream().anyMatch(f -> f.match(this, game))) { + lethal = Math.min(lethal, power.getValue()); + } else { + lethal = Math.min(lethal, toughness.getValue()); + } + lethal = Math.max(lethal - this.damage, 0); + Card attacker = game.getCard(attackerId); + if (attacker != null && attacker.getAbilities(game).containsKey(DeathtouchAbility.getInstance().getId())) { + lethal = Math.min(1, lethal); + } + } + if (this.isPlaneswalker()) { + lethal = Math.min(lethal, this.getCounters(game).getCount(CounterType.LOYALTY)); + } + return lethal; + } + @Override public void removeAllDamage(Game game) { damage = 0; deathtouched = false; } - protected int damagePlaneswalker(int damage, UUID attackerId, Ability source, Game game, boolean preventable, boolean combat, boolean markDamage, List appliedEffects) { - GameEvent event = new DamagePlaneswalkerEvent(objectId, attackerId, controllerId, damage, preventable, combat); - event.setAppliedEffects(appliedEffects); - if (game.replaceEvent(event)) { - return 0; - } - int actualDamage = checkProtectionAbilities(event, attackerId, source, game); - if (actualDamage <= 0) { - return 0; - } - int countersToRemove = Math.min(actualDamage, getCounters(game).getCount(CounterType.LOYALTY)); - removeCounters(CounterType.LOYALTY.getName(), countersToRemove, source, game); - DamagedEvent damagedEvent = new DamagedPlaneswalkerEvent(objectId, attackerId, controllerId, actualDamage, combat); - damagedEvent.setExcess(actualDamage - countersToRemove); - game.fireEvent(damagedEvent); - game.getState().addSimultaneousDamage(damagedEvent, game); - return actualDamage; - } - - protected int damageCreature(int damage, UUID attackerId, Ability source, Game game, boolean preventable, boolean combat, boolean markDamage, List appliedEffects) { - GameEvent event = new DamageCreatureEvent(this.getId(), attackerId, this.getControllerId(), damage, preventable, combat); - event.setAppliedEffects(appliedEffects); - if (game.replaceEvent(event)) { - return 0; - } - int actualDamage = checkProtectionAbilities(event, attackerId, source, game); - if (actualDamage <= 0) { - return 0; - } - MageObject attacker = game.getObject(attackerId); - int lethal = 0; - if (game.getState().getActivePowerInsteadOfToughnessForDamageLethalityFilters().stream().anyMatch(f -> f.match(this, game))) { - lethal = power.getValue(); - } else { - lethal = toughness.getValue(); - } - lethal = Math.max(lethal - this.damage, 0); - if (attacker.getAbilities().containsKey(DeathtouchAbility.getInstance().getId())) { - lethal = Math.min(1, lethal); - } - if (attacker != null && (attacker.getAbilities().containsKey(InfectAbility.getInstance().getId()) - || attacker.getAbilities().containsKey(WitherAbility.getInstance().getId()))) { - if (markDamage) { - // mark damage only - markDamage(CounterType.M1M1.createInstance(actualDamage), attacker); - } else { - Ability damageSourceAbility = null; - if (attacker instanceof Permanent) { - damageSourceAbility = ((Permanent) attacker).getSpellAbility(); - } - // deal damage immediately - addCounters(CounterType.M1M1.createInstance(actualDamage), game.getControllerId(attackerId), damageSourceAbility, game); - } - } else { - this.damage = CardUtil.overflowInc(this.damage, actualDamage); - } - DamagedEvent damagedEvent = new DamagedCreatureEvent(this.getId(), attackerId, this.getControllerId(), actualDamage, combat); - damagedEvent.setExcess(actualDamage - lethal); - game.fireEvent(damagedEvent); - game.getState().addSimultaneousDamage(damagedEvent, game); - return actualDamage; - } - private int checkProtectionAbilities(GameEvent event, UUID attackerId, Ability source, Game game) { MageObject attacker = game.getObject(attackerId); if (attacker != null && hasProtectionFrom(attacker, game)) { @@ -1049,11 +1069,11 @@ public abstract class PermanentImpl extends CardImpl implements Permanent { return event.getAmount(); } - private void markDamage(Counter counter, MageObject source) { + private void markDamage(Counter counter, MageObject source, boolean addCounters) { if (markedDamage == null) { markedDamage = new ArrayList<>(); } - markedDamage.add(new MarkedDamageInfo(counter, source)); + markedDamage.add(new MarkedDamageInfo(counter, source, addCounters)); } @Override diff --git a/Mage/src/main/java/mage/players/PlayerImpl.java b/Mage/src/main/java/mage/players/PlayerImpl.java index 272264e0c6..98f4ade265 100644 --- a/Mage/src/main/java/mage/players/PlayerImpl.java +++ b/Mage/src/main/java/mage/players/PlayerImpl.java @@ -2075,75 +2075,76 @@ public abstract class PlayerImpl implements Player, Serializable { return 0; } - if (damage > 0) { - if (canDamage(game.getObject(attackerId), game)) { - GameEvent event = new DamagePlayerEvent(playerId, - attackerId, playerId, damage, preventable, combatDamage); - event.setAppliedEffects(appliedEffects); - if (!game.replaceEvent(event)) { - int actualDamage = event.getAmount(); - if (actualDamage > 0) { - UUID sourceControllerId = null; - Abilities sourceAbilities = null; - MageObject attacker = game.getPermanentOrLKIBattlefield(attackerId); - if (attacker == null) { - StackObject stackObject = game.getStack().getStackObject(attackerId); - if (stackObject != null) { - attacker = stackObject.getStackAbility().getSourceObject(game); - } else { - attacker = game.getObject(attackerId); - } - if (attacker instanceof Spell) { - sourceAbilities = ((Spell) attacker).getAbilities(game); - sourceControllerId = ((Spell) attacker).getControllerId(); - } else if (attacker instanceof Card) { - sourceAbilities = ((Card) attacker).getAbilities(game); - sourceControllerId = ((Card) attacker).getOwnerId(); - } else if (attacker instanceof CommandObject) { - sourceControllerId = ((CommandObject) attacker).getControllerId(); - sourceAbilities = attacker.getAbilities(); - } - } else { - sourceAbilities = ((Permanent) attacker).getAbilities(game); - sourceControllerId = ((Permanent) attacker).getControllerId(); - } - if (sourceAbilities != null && sourceAbilities.containsKey(InfectAbility.getInstance().getId())) { - addCounters(CounterType.POISON.createInstance(actualDamage), sourceControllerId, source, game); - } else { - GameEvent damageToLifeLossEvent = new GameEvent(GameEvent.EventType.DAMAGE_CAUSES_LIFE_LOSS, - playerId, source, playerId, actualDamage, combatDamage); - if (!game.replaceEvent(damageToLifeLossEvent)) { - this.loseLife(damageToLifeLossEvent.getAmount(), game, source, combatDamage, attackerId); - } - } - if (sourceAbilities != null && sourceAbilities.containsKey(LifelinkAbility.getInstance().getId())) { - if (combatDamage) { - game.getPermanent(attackerId).markLifelink(actualDamage); - } else { - Player player = game.getPlayer(sourceControllerId); - player.gainLife(actualDamage, game, source); - } - } - // Unstable ability - Earl of Squirrel - if (sourceAbilities != null && sourceAbilities.containsKey(SquirrellinkAbility.getInstance().getId())) { - Player player = game.getPlayer(sourceControllerId); - new SquirrelToken().putOntoBattlefield(actualDamage, game, source, player.getId()); - } - DamagedEvent damagedEvent = new DamagedPlayerEvent(playerId, attackerId, playerId, actualDamage, combatDamage); - game.fireEvent(damagedEvent); - game.getState().addSimultaneousDamage(damagedEvent, game); - return actualDamage; - } - } + if (damage < 1) { + return 0; + } + if (!canDamage(game.getObject(attackerId), game)) { + MageObject sourceObject = game.getObject(attackerId); + game.informPlayers(damage + " damage " + + (sourceObject == null ? "" : "from " + sourceObject.getLogName()) + + " to " + getLogName() + + (damage > 1 ? " were" : "was") + " prevented because of protection"); + return 0; + } + DamageEvent event = new DamagePlayerEvent(playerId, attackerId, playerId, damage, preventable, combatDamage); + event.setAppliedEffects(appliedEffects); + if (game.replaceEvent(event)) { + return 0; + } + int actualDamage = event.getAmount(); + if (actualDamage < 1) { + return 0; + } + UUID sourceControllerId = null; + Abilities sourceAbilities = null; + MageObject attacker = game.getPermanentOrLKIBattlefield(attackerId); + if (attacker == null) { + StackObject stackObject = game.getStack().getStackObject(attackerId); + if (stackObject != null) { + attacker = stackObject.getStackAbility().getSourceObject(game); } else { - MageObject sourceObject = game.getObject(attackerId); - game.informPlayers(damage + " damage " - + (sourceObject == null ? "" : "from " + sourceObject.getLogName()) - + " to " + getLogName() - + (damage > 1 ? " were" : "was") + " prevented because of protection"); + attacker = game.getObject(attackerId); + } + if (attacker instanceof Spell) { + sourceAbilities = ((Spell) attacker).getAbilities(game); + sourceControllerId = ((Spell) attacker).getControllerId(); + } else if (attacker instanceof Card) { + sourceAbilities = ((Card) attacker).getAbilities(game); + sourceControllerId = ((Card) attacker).getOwnerId(); + } else if (attacker instanceof CommandObject) { + sourceControllerId = ((CommandObject) attacker).getControllerId(); + sourceAbilities = attacker.getAbilities(); + } + } else { + sourceAbilities = ((Permanent) attacker).getAbilities(game); + sourceControllerId = ((Permanent) attacker).getControllerId(); + } + if (event.isAsThoughInfect() || (sourceAbilities != null && sourceAbilities.containsKey(InfectAbility.getInstance().getId()))) { + addCounters(CounterType.POISON.createInstance(actualDamage), sourceControllerId, source, game); + } else { + GameEvent damageToLifeLossEvent = new GameEvent(GameEvent.EventType.DAMAGE_CAUSES_LIFE_LOSS, + playerId, source, playerId, actualDamage, combatDamage); + if (!game.replaceEvent(damageToLifeLossEvent)) { + this.loseLife(damageToLifeLossEvent.getAmount(), game, source, combatDamage, attackerId); } } - return 0; + if (sourceAbilities != null && sourceAbilities.containsKey(LifelinkAbility.getInstance().getId())) { + if (combatDamage) { + game.getPermanent(attackerId).markLifelink(actualDamage); + } else { + Player player = game.getPlayer(sourceControllerId); + player.gainLife(actualDamage, game, source); + } + } + // Unstable ability - Earl of Squirrel + if (sourceAbilities != null && sourceAbilities.containsKey(SquirrellinkAbility.getInstance().getId())) { + Player player = game.getPlayer(sourceControllerId); + new SquirrelToken().putOntoBattlefield(actualDamage, game, source, player.getId()); + } + DamagedEvent damagedEvent = new DamagedPlayerEvent(playerId, attackerId, playerId, actualDamage, combatDamage); + game.fireEvent(damagedEvent); + game.getState().addSimultaneousDamage(damagedEvent, game); + return actualDamage; } @Override diff --git a/Mage/src/main/java/mage/watchers/common/DamageDoneWatcher.java b/Mage/src/main/java/mage/watchers/common/DamageDoneWatcher.java index 154f4414e0..348f88f290 100644 --- a/Mage/src/main/java/mage/watchers/common/DamageDoneWatcher.java +++ b/Mage/src/main/java/mage/watchers/common/DamageDoneWatcher.java @@ -38,8 +38,7 @@ public class DamageDoneWatcher extends Watcher { @Override public void watch(GameEvent event, Game game) { switch (event.getType()) { - case DAMAGED_CREATURE: - case DAMAGED_PLANESWALKER: + case DAMAGED_PERMANENT: case DAMAGED_PLAYER: { MageObjectReference damageSourceRef = new MageObjectReference(event.getSourceId(), game); damagingObjects.putIfAbsent(damageSourceRef, 0); diff --git a/Mage/src/main/java/mage/watchers/common/DamagedByWatcher.java b/Mage/src/main/java/mage/watchers/common/DamagedByWatcher.java index 1956b98e1d..5c5882e491 100644 --- a/Mage/src/main/java/mage/watchers/common/DamagedByWatcher.java +++ b/Mage/src/main/java/mage/watchers/common/DamagedByWatcher.java @@ -1,25 +1,24 @@ package mage.watchers.common; -import java.util.HashSet; -import java.util.Set; -import java.util.UUID; - import mage.MageObject; import mage.MageObjectReference; import mage.constants.WatcherScope; import mage.game.Game; import mage.game.events.GameEvent; -import mage.game.events.GameEvent.EventType; import mage.game.permanent.Permanent; import mage.watchers.Watcher; +import java.util.HashSet; +import java.util.Set; +import java.util.UUID; + /** * @author BetaSteward_at_googlemail.com */ public class DamagedByWatcher extends Watcher { - public final Set damagedBySource = new HashSet<>(); + private final Set damagedBySource = new HashSet<>(); private final boolean watchPlaneswalkers; @@ -30,12 +29,15 @@ public class DamagedByWatcher extends Watcher { @Override public void watch(GameEvent event, Game game) { - boolean eventHasAppropriateType = (event.getType() == GameEvent.EventType.DAMAGED_CREATURE) || - (watchPlaneswalkers && event.getType() == GameEvent.EventType.DAMAGED_PLANESWALKER); - if (eventHasAppropriateType && sourceId.equals(event.getSourceId())) { - MageObjectReference mor = new MageObjectReference(event.getTargetId(), game); - damagedBySource.add(mor); - + if (event.getType() != GameEvent.EventType.DAMAGED_PERMANENT) { + return; + } + Permanent permanent = game.getPermanent(event.getTargetId()); + if (permanent != null && !watchPlaneswalkers && !permanent.isCreature()) { + return; + } + if (sourceId.equals(event.getSourceId())) { + damagedBySource.add(new MageObjectReference(event.getTargetId(), game)); } } diff --git a/Mage/src/main/java/mage/watchers/common/SourceDidDamageWatcher.java b/Mage/src/main/java/mage/watchers/common/SourceDidDamageWatcher.java index 97112fd4b6..b76308bf59 100644 --- a/Mage/src/main/java/mage/watchers/common/SourceDidDamageWatcher.java +++ b/Mage/src/main/java/mage/watchers/common/SourceDidDamageWatcher.java @@ -24,11 +24,9 @@ public class SourceDidDamageWatcher extends Watcher { @Override public void watch(GameEvent event, Game game) { - if (event.getType() == GameEvent.EventType.DAMAGED_CREATURE - || event.getType() == GameEvent.EventType.DAMAGED_PLANESWALKER + if (event.getType() == GameEvent.EventType.DAMAGED_PERMANENT || event.getType() == GameEvent.EventType.DAMAGED_PLAYER) { damageSources.add(event.getSourceId()); - } }