From c3983dac6397f4b000493634658df494cdfb5e58 Mon Sep 17 00:00:00 2001 From: Evan Kranzler Date: Sun, 25 Apr 2021 14:58:58 -0400 Subject: [PATCH] [ONS] fixed Thrashing Mudspawn null pointer exception (fixes #7775) --- .../src/mage/cards/t/ThrashingMudspawn.java | 27 +++++++++---------- .../DealtDamageToSourceTriggeredAbility.java | 4 +-- 2 files changed, 14 insertions(+), 17 deletions(-) diff --git a/Mage.Sets/src/mage/cards/t/ThrashingMudspawn.java b/Mage.Sets/src/mage/cards/t/ThrashingMudspawn.java index 17a8133b0b..7e1becc18e 100644 --- a/Mage.Sets/src/mage/cards/t/ThrashingMudspawn.java +++ b/Mage.Sets/src/mage/cards/t/ThrashingMudspawn.java @@ -1,11 +1,8 @@ - package mage.cards.t; -import java.util.UUID; import mage.MageInt; import mage.abilities.Ability; import mage.abilities.common.DealtDamageToSourceTriggeredAbility; -import mage.constants.SubType; import mage.abilities.costs.mana.ManaCostsImpl; import mage.abilities.effects.OneShotEffect; import mage.abilities.keyword.MorphAbility; @@ -13,11 +10,13 @@ import mage.cards.CardImpl; import mage.cards.CardSetInfo; import mage.constants.CardType; import mage.constants.Outcome; +import mage.constants.SubType; import mage.game.Game; import mage.players.Player; +import java.util.UUID; + /** - * * @author TheElk801 */ public final class ThrashingMudspawn extends CardImpl { @@ -30,11 +29,13 @@ public final class ThrashingMudspawn extends CardImpl { this.toughness = new MageInt(4); // Whenever Thrashing Mudspawn is dealt damage, you lose that much life. - Ability ability = new DealtDamageToSourceTriggeredAbility(new ThrashingMudspawnEffect(), false); + Ability ability = new DealtDamageToSourceTriggeredAbility( + new ThrashingMudspawnEffect(), false, false, true + ); this.addAbility(ability); // Morph {1}{B}{B} - this.addAbility(new MorphAbility(this, new ManaCostsImpl("{1}{B}{B}"))); + this.addAbility(new MorphAbility(this, new ManaCostsImpl<>("{1}{B}{B}"))); } @@ -66,14 +67,12 @@ class ThrashingMudspawnEffect extends OneShotEffect { @Override public boolean apply(Game game, Ability source) { - int amount = (Integer) getValue("damage"); - if (amount > 0) { - Player player = game.getPlayer(source.getControllerId()); - if (player != null) { - player.loseLife(amount, game, source, false); - return true; - } + Integer amount = (Integer) getValue("damage"); + Player player = game.getPlayer(source.getControllerId()); + if (amount == null || amount < 1 || player == null) { + return false; } - return false; + player.loseLife(amount, game, source, false); + return true; } } diff --git a/Mage/src/main/java/mage/abilities/common/DealtDamageToSourceTriggeredAbility.java b/Mage/src/main/java/mage/abilities/common/DealtDamageToSourceTriggeredAbility.java index 9f99078951..3fe62d4bb6 100644 --- a/Mage/src/main/java/mage/abilities/common/DealtDamageToSourceTriggeredAbility.java +++ b/Mage/src/main/java/mage/abilities/common/DealtDamageToSourceTriggeredAbility.java @@ -55,9 +55,7 @@ public class DealtDamageToSourceTriggeredAbility extends TriggeredAbilityImpl { 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 - for (Effect effect : this.getEffects()) { - effect.setValue("damage", event.getAmount()); - } + getEffects().setValue("damage", event.getAmount()); return true; } else { if (((DamagedEvent) event).isCombatDamage()) {