From 209f3bc8c8f9489a9f0d1431c3662c0518cfe27e Mon Sep 17 00:00:00 2001 From: LevelX2 Date: Fri, 24 Oct 2014 21:52:58 +0200 Subject: [PATCH] * Prossh, Skyraider of Kher - Fixed that the tokens were not created if the spell was countered (part 2). --- .../common/ManaSpentToCastCount.java | 16 +++++++++++----- Mage/src/mage/game/GameImpl.java | 8 ++++++++ 2 files changed, 19 insertions(+), 5 deletions(-) diff --git a/Mage/src/mage/abilities/dynamicvalue/common/ManaSpentToCastCount.java b/Mage/src/mage/abilities/dynamicvalue/common/ManaSpentToCastCount.java index 0cddf99a06..f9274b38ff 100644 --- a/Mage/src/mage/abilities/dynamicvalue/common/ManaSpentToCastCount.java +++ b/Mage/src/mage/abilities/dynamicvalue/common/ManaSpentToCastCount.java @@ -27,9 +27,11 @@ */ package mage.abilities.dynamicvalue.common; +import mage.MageObject; import mage.abilities.Ability; import mage.abilities.dynamicvalue.DynamicValue; import mage.abilities.effects.Effect; +import mage.constants.Zone; import mage.game.Game; import mage.game.stack.Spell; import mage.game.stack.StackObject; @@ -45,13 +47,17 @@ public class ManaSpentToCastCount implements DynamicValue{ @Override public int calculate(Game game, Ability source, Effect effect) { - if (!game.getStack().isEmpty()) { - for (StackObject stackObject : game.getStack()) { - if (stackObject instanceof Spell && ((Spell)stackObject).getSourceId().equals(source.getSourceId())) { - return ((Spell)stackObject).getConvertedManaCost(); - } + Spell spell = game.getStack().getSpell(source.getSourceId()); + if (spell == null) { + MageObject mageObject = game.getLastKnownInformation(source.getSourceId(), Zone.STACK); + if (mageObject instanceof Spell) { + spell = (Spell) mageObject; } } + if (spell != null) { + // NOT the cmc of the spell on the stack + return spell.getSpellAbility().getManaCostsToPay().convertedManaCost() + spell.getSpellAbility().getManaCostsToPay().getX(); + } return 0; } diff --git a/Mage/src/mage/game/GameImpl.java b/Mage/src/mage/game/GameImpl.java index c5f53b1af2..5a67f0c9ac 100644 --- a/Mage/src/mage/game/GameImpl.java +++ b/Mage/src/mage/game/GameImpl.java @@ -2099,6 +2099,14 @@ public abstract class GameImpl implements Game, Serializable { if (object != null) { return object.copy(); } + for (MageObject mageObject:lkiMap.values()) { + if (mageObject instanceof Spell) { + if (((Spell)mageObject).getCard().getId().equals(objectId)) { + return mageObject; + } + } + + } } return null; }