From 3510ac0957eb7e0734d05a13252de01df0243864 Mon Sep 17 00:00:00 2001 From: jeffwadsworth Date: Fri, 24 Jan 2020 11:09:26 -0600 Subject: [PATCH] - Fixed #6220 --- Mage.Sets/src/mage/cards/c/CatalystStone.java | 43 ++++++++++++------- 1 file changed, 27 insertions(+), 16 deletions(-) diff --git a/Mage.Sets/src/mage/cards/c/CatalystStone.java b/Mage.Sets/src/mage/cards/c/CatalystStone.java index 0837d00997..261606150f 100644 --- a/Mage.Sets/src/mage/cards/c/CatalystStone.java +++ b/Mage.Sets/src/mage/cards/c/CatalystStone.java @@ -4,7 +4,7 @@ package mage.cards.c; import java.util.LinkedHashSet; import java.util.Set; import java.util.UUID; -import mage.MageObject; +import mage.Mana; import mage.abilities.Ability; import mage.abilities.SpellAbility; import mage.abilities.common.SimpleStaticAbility; @@ -18,7 +18,6 @@ import mage.constants.Duration; import mage.constants.Outcome; import mage.constants.SpellAbilityCastMode; import mage.constants.Zone; -import static mage.filter.predicate.permanent.ControllerControlsIslandPredicate.filter; import mage.game.Game; import mage.players.Player; import mage.util.CardUtil; @@ -63,22 +62,34 @@ class CatalystStoneCostReductionEffect extends CostModificationEffectImpl { @Override public boolean apply(Game game, Ability source, Ability abilityToModify) { - Player controller = game.getPlayer(source.getControllerId()); + Player controller = game.getPlayer(abilityToModify.getControllerId()); if (controller != null) { - int generic = abilityToModify.getManaCostsToPay().getMana().getGeneric(); - if (generic > 0) { - ChoiceImpl choice = new ChoiceImpl(false); - Set set = new LinkedHashSet<>(); - for (int i = 0; i <= Math.min(2, generic); i++) { - set.add(String.valueOf(i)); + Mana mana = abilityToModify.getManaCostsToPay().getMana(); + int reduceMax = mana.getGeneric(); + if (reduceMax > 2) { + reduceMax = 2; + } + if (reduceMax > 0) { + int reduce; + if (game.inCheckPlayableState()) { + reduce = reduceMax; + } else { + ChoiceImpl choice = new ChoiceImpl(true); + Set set = new LinkedHashSet<>(); + + for (int i = 0; i <= reduceMax; i++) { + set.add(String.valueOf(i)); + } + choice.setChoices(set); + choice.setMessage("Reduce flashback cost"); + + if (controller.choose(Outcome.Benefit, choice, game)) { + reduce = Integer.parseInt(choice.getChoice()); + } else { + return false; + } } - choice.setChoices(set); - MageObject mageObject = game.getObject(abilityToModify.getSourceId()); - choice.setMessage("Reduce cost of " + (mageObject != null ? mageObject.getIdName() : filter.getMessage())); - if (controller.choose(Outcome.Benefit, choice, game)) { - generic = Integer.parseInt(choice.getChoice()); - } - CardUtil.reduceCost(abilityToModify, generic); + CardUtil.reduceCost(abilityToModify, reduce); } return true; }