Fixed not giving counter option to non-opponent players that are not the spell's controller

This update brings to code to compliance with LevelX2's reccomendation by using getPlayersInRange(source.getControllerId(), game) and checking manually that the player is not the spell's controller.
This commit is contained in:
ThomasLerner 2017-04-10 04:39:10 -04:00 committed by GitHub
parent 57b50857cc
commit 7a48387635

View file

@ -30,10 +30,8 @@ package mage.cards.i;
import mage.abilities.Ability;
import mage.abilities.common.SpellCastAllTriggeredAbility;
import mage.abilities.effects.OneShotEffect;
import mage.cards.Card;
import mage.cards.CardImpl;
import mage.cards.CardSetInfo;
import mage.cards.CardsImpl;
import mage.constants.CardType;
import mage.constants.Outcome;
import mage.constants.SetTargetPointer;
@ -43,12 +41,11 @@ import mage.game.Game;
import mage.game.permanent.Permanent;
import mage.game.stack.Spell;
import mage.players.Player;
import mage.util.CardUtil;
import java.util.UUID;
import mage.abilities.costs.Cost;
import mage.abilities.costs.mana.ManaCostsImpl;
import java.util.UUID;
/**
*
* @author ThomasLerner
@ -97,14 +94,14 @@ class IceCaveEffect extends OneShotEffect {
if(sourcePermanent != null && spell != null && controller != null) {
Player spellController = game.getPlayer(spell.getControllerId());
Cost cost = new ManaCostsImpl(spell.getSpellAbility().getManaCosts().getText());
if (spellController != null) {
for (UUID playerId : game.getOpponents(spell.getControllerId())) {
if(spellController != null) {
for (UUID playerId : game.getState().getPlayersInRange(source.getControllerId(), game)) {
Player player = game.getPlayer(playerId);
if (player != null) {
if(player != null && player != spellController) {
cost.clearPaid();
if (cost.canPay(source, source.getSourceId(), player.getId(), game)
if(cost.canPay(source, source.getSourceId(), player.getId(), game)
&& player.chooseUse(outcome, "Pay " + cost.getText() + " to counter " + spell.getIdName() + '?', source, game)) {
if (cost.pay(source, game, source.getSourceId(), playerId, false, null)) {
if(cost.pay(source, game, source.getSourceId(), playerId, false, null)) {
game.informPlayers(player.getLogName() + " pays" + cost.getText() + " to counter " + spell.getIdName() + '.');
game.getStack().counter(spell.getId(), source.getSourceId(), game);
return true;
@ -117,4 +114,3 @@ class IceCaveEffect extends OneShotEffect {
return true;
}
}