[ONS] fixed Thrashing Mudspawn null pointer exception (fixes #7775)

This commit is contained in:
Evan Kranzler 2021-04-25 14:58:58 -04:00
parent 05d5eeb941
commit c3983dac63
2 changed files with 14 additions and 17 deletions

View file

@ -1,11 +1,8 @@
package mage.cards.t; package mage.cards.t;
import java.util.UUID;
import mage.MageInt; import mage.MageInt;
import mage.abilities.Ability; import mage.abilities.Ability;
import mage.abilities.common.DealtDamageToSourceTriggeredAbility; import mage.abilities.common.DealtDamageToSourceTriggeredAbility;
import mage.constants.SubType;
import mage.abilities.costs.mana.ManaCostsImpl; import mage.abilities.costs.mana.ManaCostsImpl;
import mage.abilities.effects.OneShotEffect; import mage.abilities.effects.OneShotEffect;
import mage.abilities.keyword.MorphAbility; import mage.abilities.keyword.MorphAbility;
@ -13,11 +10,13 @@ import mage.cards.CardImpl;
import mage.cards.CardSetInfo; import mage.cards.CardSetInfo;
import mage.constants.CardType; import mage.constants.CardType;
import mage.constants.Outcome; import mage.constants.Outcome;
import mage.constants.SubType;
import mage.game.Game; import mage.game.Game;
import mage.players.Player; import mage.players.Player;
import java.util.UUID;
/** /**
*
* @author TheElk801 * @author TheElk801
*/ */
public final class ThrashingMudspawn extends CardImpl { public final class ThrashingMudspawn extends CardImpl {
@ -30,11 +29,13 @@ public final class ThrashingMudspawn extends CardImpl {
this.toughness = new MageInt(4); this.toughness = new MageInt(4);
// Whenever Thrashing Mudspawn is dealt damage, you lose that much life. // 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); this.addAbility(ability);
// Morph {1}{B}{B} // 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 @Override
public boolean apply(Game game, Ability source) { public boolean apply(Game game, Ability source) {
int amount = (Integer) getValue("damage"); Integer amount = (Integer) getValue("damage");
if (amount > 0) {
Player player = game.getPlayer(source.getControllerId()); Player player = game.getPlayer(source.getControllerId());
if (player != null) { if (amount == null || amount < 1 || player == null) {
return false;
}
player.loseLife(amount, game, source, false); player.loseLife(amount, game, source, false);
return true; return true;
} }
}
return false;
}
} }

View file

@ -55,9 +55,7 @@ public class DealtDamageToSourceTriggeredAbility extends TriggeredAbilityImpl {
if (useValue) { if (useValue) {
// TODO: this ability should only trigger once for multiple creatures dealing combat damage. // 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 // 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()) { getEffects().setValue("damage", event.getAmount());
effect.setValue("damage", event.getAmount());
}
return true; return true;
} else { } else {
if (((DamagedEvent) event).isCombatDamage()) { if (((DamagedEvent) event).isCombatDamage()) {