* Prossh, Skyraider of Kher - Fixed that the tokens were not created if the spell was countered (part 2).

This commit is contained in:
LevelX2 2014-10-24 21:52:58 +02:00
parent befc3d73ef
commit 209f3bc8c8
2 changed files with 19 additions and 5 deletions

View file

@ -27,9 +27,11 @@
*/ */
package mage.abilities.dynamicvalue.common; package mage.abilities.dynamicvalue.common;
import mage.MageObject;
import mage.abilities.Ability; import mage.abilities.Ability;
import mage.abilities.dynamicvalue.DynamicValue; import mage.abilities.dynamicvalue.DynamicValue;
import mage.abilities.effects.Effect; import mage.abilities.effects.Effect;
import mage.constants.Zone;
import mage.game.Game; import mage.game.Game;
import mage.game.stack.Spell; import mage.game.stack.Spell;
import mage.game.stack.StackObject; import mage.game.stack.StackObject;
@ -45,13 +47,17 @@ public class ManaSpentToCastCount implements DynamicValue{
@Override @Override
public int calculate(Game game, Ability source, Effect effect) { public int calculate(Game game, Ability source, Effect effect) {
if (!game.getStack().isEmpty()) { Spell spell = game.getStack().getSpell(source.getSourceId());
for (StackObject stackObject : game.getStack()) { if (spell == null) {
if (stackObject instanceof Spell && ((Spell)stackObject).getSourceId().equals(source.getSourceId())) { MageObject mageObject = game.getLastKnownInformation(source.getSourceId(), Zone.STACK);
return ((Spell)stackObject).getConvertedManaCost(); 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; return 0;
} }

View file

@ -2099,6 +2099,14 @@ public abstract class GameImpl implements Game, Serializable {
if (object != null) { if (object != null) {
return object.copy(); return object.copy();
} }
for (MageObject mageObject:lkiMap.values()) {
if (mageObject instanceof Spell) {
if (((Spell)mageObject).getCard().getId().equals(objectId)) {
return mageObject;
}
}
}
} }
return null; return null;
} }