mirror of
https://github.com/correl/mage.git
synced 2025-01-12 19:25:44 +00:00
fixed Lightmine Field damaging creatures which weren't declared as attackers
(fixes #4111)
This commit is contained in:
parent
f6c76026e8
commit
1c258c6b9f
1 changed files with 21 additions and 4 deletions
|
@ -27,10 +27,15 @@
|
||||||
*/
|
*/
|
||||||
package mage.cards.l;
|
package mage.cards.l;
|
||||||
|
|
||||||
|
import java.util.HashSet;
|
||||||
|
import java.util.Iterator;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Set;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
import mage.MageObjectReference;
|
||||||
import mage.abilities.Ability;
|
import mage.abilities.Ability;
|
||||||
import mage.abilities.TriggeredAbilityImpl;
|
import mage.abilities.TriggeredAbilityImpl;
|
||||||
|
import mage.abilities.effects.Effect;
|
||||||
import mage.abilities.effects.OneShotEffect;
|
import mage.abilities.effects.OneShotEffect;
|
||||||
import mage.cards.CardImpl;
|
import mage.cards.CardImpl;
|
||||||
import mage.cards.CardSetInfo;
|
import mage.cards.CardSetInfo;
|
||||||
|
@ -49,7 +54,7 @@ import mage.game.permanent.Permanent;
|
||||||
public class LightmineField extends CardImpl {
|
public class LightmineField extends CardImpl {
|
||||||
|
|
||||||
public LightmineField(UUID ownerId, CardSetInfo setInfo) {
|
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.
|
// 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());
|
this.addAbility(new LightmineFieldTriggeredAbility());
|
||||||
|
@ -87,7 +92,17 @@ class LightmineFieldTriggeredAbility extends TriggeredAbilityImpl {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean checkTrigger(GameEvent event, Game game) {
|
public boolean checkTrigger(GameEvent event, Game game) {
|
||||||
return !game.getCombat().getAttackers().isEmpty();
|
Set<MageObjectReference> 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
|
@Override
|
||||||
|
@ -116,9 +131,11 @@ class LightmineFieldEffect extends OneShotEffect {
|
||||||
public boolean apply(Game game, Ability source) {
|
public boolean apply(Game game, Ability source) {
|
||||||
List<UUID> attackers = game.getCombat().getAttackers();
|
List<UUID> attackers = game.getCombat().getAttackers();
|
||||||
int damage = attackers.size();
|
int damage = attackers.size();
|
||||||
|
Set<MageObjectReference> attackSet = (Set<MageObjectReference>) getValue("Lightmine Field");
|
||||||
if (!attackers.isEmpty()) {
|
if (!attackers.isEmpty()) {
|
||||||
for (UUID attacker : attackers) {
|
for (Iterator<MageObjectReference> it = attackSet.iterator(); it.hasNext();) {
|
||||||
Permanent creature = game.getPermanent(attacker);
|
MageObjectReference attacker = it.next();
|
||||||
|
Permanent creature = attacker.getPermanent(game);
|
||||||
if (creature != null) {
|
if (creature != null) {
|
||||||
creature.damage(damage, source.getSourceId(), game, false, true);
|
creature.damage(damage, source.getSourceId(), game, false, true);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue