From 1c258c6b9f776e59efef7e3eaa7138fa9b4693ef Mon Sep 17 00:00:00 2001 From: Evan Kranzler Date: Sun, 15 Oct 2017 20:48:26 -0400 Subject: [PATCH] fixed Lightmine Field damaging creatures which weren't declared as attackers (fixes #4111) --- .../src/mage/cards/l/LightmineField.java | 25 ++++++++++++++++--- 1 file changed, 21 insertions(+), 4 deletions(-) diff --git a/Mage.Sets/src/mage/cards/l/LightmineField.java b/Mage.Sets/src/mage/cards/l/LightmineField.java index 2b4b8aaf72..7f9e081f62 100644 --- a/Mage.Sets/src/mage/cards/l/LightmineField.java +++ b/Mage.Sets/src/mage/cards/l/LightmineField.java @@ -27,10 +27,15 @@ */ package mage.cards.l; +import java.util.HashSet; +import java.util.Iterator; import java.util.List; +import java.util.Set; import java.util.UUID; +import mage.MageObjectReference; 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; @@ -49,7 +54,7 @@ import mage.game.permanent.Permanent; public class LightmineField extends CardImpl { public LightmineField(UUID ownerId, CardSetInfo setInfo) { - super(ownerId,setInfo,new CardType[]{CardType.ENCHANTMENT},"{2}{W}{W}"); + super(ownerId, setInfo, new CardType[]{CardType.ENCHANTMENT}, "{2}{W}{W}"); // Whenever one or more creatures attack, Lightmine Field deals damage to each of those creatures equal to the number of attacking creatures. this.addAbility(new LightmineFieldTriggeredAbility()); @@ -87,7 +92,17 @@ class LightmineFieldTriggeredAbility extends TriggeredAbilityImpl { @Override public boolean checkTrigger(GameEvent event, Game game) { - return !game.getCombat().getAttackers().isEmpty(); + Set attackSet = new HashSet<>(); + for (UUID attackerId : game.getCombat().getAttackers()) { + Permanent attacker = game.getPermanent(attackerId); + if (attacker != null) { + attackSet.add(new MageObjectReference(attacker, game)); + } + } + for (Effect effect : getEffects()) { + effect.setValue("Lightmine Field", attackSet); + } + return !attackSet.isEmpty(); } @Override @@ -116,9 +131,11 @@ class LightmineFieldEffect extends OneShotEffect { public boolean apply(Game game, Ability source) { List attackers = game.getCombat().getAttackers(); int damage = attackers.size(); + Set attackSet = (Set) getValue("Lightmine Field"); if (!attackers.isEmpty()) { - for (UUID attacker : attackers) { - Permanent creature = game.getPermanent(attacker); + for (Iterator it = attackSet.iterator(); it.hasNext();) { + MageObjectReference attacker = it.next(); + Permanent creature = attacker.getPermanent(game); if (creature != null) { creature.damage(damage, source.getSourceId(), game, false, true); }