* Fixed a problem that the playable check for some alternate costs (e.g. Devastating Master) was not done with the correct mana cost and wrongly shown as playable without enough avalable mana.

This commit is contained in:
LevelX2 2021-08-03 16:35:47 +02:00
parent 2134d004af
commit b6a3f7edc1

View file

@ -1,6 +1,10 @@
package mage.players; package mage.players;
import com.google.common.collect.ImmutableMap; import com.google.common.collect.ImmutableMap;
import java.io.Serializable;
import java.util.*;
import java.util.Map.Entry;
import java.util.stream.Collectors;
import mage.*; import mage.*;
import mage.abilities.*; import mage.abilities.*;
import mage.abilities.ActivatedAbility.ActivationStatus; import mage.abilities.ActivatedAbility.ActivationStatus;
@ -8,6 +12,7 @@ import mage.abilities.common.PassAbility;
import mage.abilities.common.PlayLandAsCommanderAbility; import mage.abilities.common.PlayLandAsCommanderAbility;
import mage.abilities.common.WhileSearchingPlayFromLibraryAbility; import mage.abilities.common.WhileSearchingPlayFromLibraryAbility;
import mage.abilities.common.delayed.AtTheEndOfTurnStepPostDelayedTriggeredAbility; import mage.abilities.common.delayed.AtTheEndOfTurnStepPostDelayedTriggeredAbility;
import mage.abilities.costs.AlternativeCost2;
import mage.abilities.costs.AlternativeSourceCosts; import mage.abilities.costs.AlternativeSourceCosts;
import mage.abilities.costs.Cost; import mage.abilities.costs.Cost;
import mage.abilities.costs.Costs; import mage.abilities.costs.Costs;
@ -65,11 +70,6 @@ import mage.util.GameLog;
import mage.util.RandomUtil; import mage.util.RandomUtil;
import org.apache.log4j.Logger; import org.apache.log4j.Logger;
import java.io.Serializable;
import java.util.*;
import java.util.Map.Entry;
import java.util.stream.Collectors;
public abstract class PlayerImpl implements Player, Serializable { public abstract class PlayerImpl implements Player, Serializable {
private static final Logger logger = Logger.getLogger(PlayerImpl.class); private static final Logger logger = Logger.getLogger(PlayerImpl.class);
@ -3290,10 +3290,16 @@ public abstract class PlayerImpl implements Player, Serializable {
if (alternateSourceCostsAbility.getCosts().canPay(ability, ability, playerId, game)) { if (alternateSourceCostsAbility.getCosts().canPay(ability, ability, playerId, game)) {
ManaCostsImpl manaCosts = new ManaCostsImpl(); ManaCostsImpl manaCosts = new ManaCostsImpl();
for (Cost cost : alternateSourceCostsAbility.getCosts()) { for (Cost cost : alternateSourceCostsAbility.getCosts()) {
if (cost instanceof AlternativeCost2) {
if(((AlternativeCost2) cost).getCost() instanceof ManaCost) {
manaCosts.add((ManaCost) ((AlternativeCost2) cost).getCost());
}
} else {
if (cost instanceof ManaCost) { if (cost instanceof ManaCost) {
manaCosts.add((ManaCost) cost); manaCosts.add((ManaCost) cost);
} }
} }
}
if (manaCosts.isEmpty()) { if (manaCosts.isEmpty()) {
return true; return true;