mirror of
https://github.com/magefree/mage.git
synced 2026-01-24 04:09:54 -08:00
fix #11921 (Norn's Decree) and similar
fix Iron Mastiff fix Tahngarth, First Mate
This commit is contained in:
parent
73e9b8da49
commit
8969e1a5de
3 changed files with 33 additions and 10 deletions
|
|
@ -1,11 +1,12 @@
|
|||
|
||||
package mage.abilities.condition.common;
|
||||
|
||||
import mage.abilities.Ability;
|
||||
import mage.abilities.condition.Condition;
|
||||
import mage.counters.CounterType;
|
||||
import mage.game.Game;
|
||||
import mage.watchers.common.PlayerAttackedStepWatcher;
|
||||
import mage.game.combat.CombatGroup;
|
||||
|
||||
import java.util.Objects;
|
||||
|
||||
/**
|
||||
* A condition which checks whether any players being attacked are poisoned
|
||||
|
|
@ -14,17 +15,23 @@ import mage.watchers.common.PlayerAttackedStepWatcher;
|
|||
* @author alexander-novo
|
||||
*/
|
||||
public enum AttackedPlayersPoisonedCondition implements Condition {
|
||||
|
||||
instance;
|
||||
|
||||
@Override
|
||||
public boolean apply(Game game, Ability source) {
|
||||
return game.getCombat().getDefenders().stream().map(defender -> game.getPlayer(defender))
|
||||
.anyMatch(player -> player != null && player.getCounters().containsKey(CounterType.POISON));
|
||||
return game.getCombat()
|
||||
.getGroups()
|
||||
.stream()
|
||||
.map(CombatGroup::getDefenderId)
|
||||
.filter(Objects::nonNull)
|
||||
.distinct()
|
||||
.map(game::getPlayer)
|
||||
.filter(Objects::nonNull)
|
||||
.anyMatch(player -> player.getCounters().containsKey(CounterType.POISON));
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "one or more players being attacked are poisoned";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue