From b6a3f7edc1592861b8fd095289788736114e71f4 Mon Sep 17 00:00:00 2001 From: LevelX2 Date: Tue, 3 Aug 2021 16:35:47 +0200 Subject: [PATCH] * 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. --- .../main/java/mage/players/PlayerImpl.java | 20 ++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/Mage/src/main/java/mage/players/PlayerImpl.java b/Mage/src/main/java/mage/players/PlayerImpl.java index a6cd7eed8b..7903d304fc 100644 --- a/Mage/src/main/java/mage/players/PlayerImpl.java +++ b/Mage/src/main/java/mage/players/PlayerImpl.java @@ -1,6 +1,10 @@ package mage.players; 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.abilities.*; import mage.abilities.ActivatedAbility.ActivationStatus; @@ -8,6 +12,7 @@ import mage.abilities.common.PassAbility; import mage.abilities.common.PlayLandAsCommanderAbility; import mage.abilities.common.WhileSearchingPlayFromLibraryAbility; import mage.abilities.common.delayed.AtTheEndOfTurnStepPostDelayedTriggeredAbility; +import mage.abilities.costs.AlternativeCost2; import mage.abilities.costs.AlternativeSourceCosts; import mage.abilities.costs.Cost; import mage.abilities.costs.Costs; @@ -65,11 +70,6 @@ import mage.util.GameLog; import mage.util.RandomUtil; 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 { private static final Logger logger = Logger.getLogger(PlayerImpl.class); @@ -3290,8 +3290,14 @@ public abstract class PlayerImpl implements Player, Serializable { if (alternateSourceCostsAbility.getCosts().canPay(ability, ability, playerId, game)) { ManaCostsImpl manaCosts = new ManaCostsImpl(); for (Cost cost : alternateSourceCostsAbility.getCosts()) { - if (cost instanceof ManaCost) { - manaCosts.add((ManaCost) cost); + if (cost instanceof AlternativeCost2) { + if(((AlternativeCost2) cost).getCost() instanceof ManaCost) { + manaCosts.add((ManaCost) ((AlternativeCost2) cost).getCost()); + } + } else { + if (cost instanceof ManaCost) { + manaCosts.add((ManaCost) cost); + } } }