fixed effects counting opponents no longer in the game

This commit is contained in:
Evan Kranzler 2021-04-28 08:18:07 -04:00
parent a69f6b38d9
commit 7778e867f8
3 changed files with 20 additions and 21 deletions

View file

@ -5,6 +5,8 @@ import mage.abilities.dynamicvalue.DynamicValue;
import mage.abilities.effects.Effect;
import mage.game.Game;
import java.util.Objects;
/**
* @author JayDi85
*/
@ -13,7 +15,12 @@ public enum OpponentsCount implements DynamicValue {
@Override
public int calculate(Game game, Ability sourceAbility, Effect effect) {
return game.getOpponents(sourceAbility.getControllerId()).size();
return game.getOpponents(sourceAbility.getControllerId())
.stream()
.map(game::getPlayer)
.map(Objects::nonNull)
.mapToInt(x -> x ? 1 : 0)
.sum();
}
@Override
@ -30,4 +37,4 @@ public enum OpponentsCount implements DynamicValue {
public String toString() {
return "1";
}
}
}