From 0dd96df9e39e8b08c9ae7f4c8ff752706795ef0c Mon Sep 17 00:00:00 2001 From: LevelX2 Date: Thu, 3 Jul 2014 15:16:59 +0200 Subject: [PATCH] * Fixed that in some cases the converted mana costs of spells were calculated without the value of X costs (e.g. Chalice of the Void). --- .../sets/betrayersofkamigawa/DisruptingShoal.java | 2 +- .../championsofkamigawa/HisokaMinamoSensei.java | 2 +- .../commander2013/EndrekSahrMasterBreeder.java | 2 +- .../src/mage/sets/dragonsmaze/PlasmCapture.java | 2 +- .../journeyintonyx/EidolonOfTheGreatRevel.java | 2 +- .../src/mage/sets/mirrodin/ChaliceOfTheVoid.java | 3 +-- .../src/mage/sets/planarchaos/ImpsMischief.java | 2 +- .../sets/saviorsofkamigawa/BounteousKirin.java | 2 +- .../sets/saviorsofkamigawa/CelestialKirin.java | 2 +- .../sets/saviorsofkamigawa/CloudhoofKirin.java | 2 +- .../mage/sets/saviorsofkamigawa/InfernalKirin.java | 2 +- .../mage/sets/saviorsofkamigawa/SkyfireKirin.java | 2 +- .../src/mage/sets/shardsofalara/Manaplasm.java | 5 +++-- Mage/src/mage/game/stack/Spell.java | 14 +++++++++++++- 14 files changed, 28 insertions(+), 16 deletions(-) diff --git a/Mage.Sets/src/mage/sets/betrayersofkamigawa/DisruptingShoal.java b/Mage.Sets/src/mage/sets/betrayersofkamigawa/DisruptingShoal.java index e1ae266270..3aeb7ff558 100644 --- a/Mage.Sets/src/mage/sets/betrayersofkamigawa/DisruptingShoal.java +++ b/Mage.Sets/src/mage/sets/betrayersofkamigawa/DisruptingShoal.java @@ -102,7 +102,7 @@ class DisruptingShoalCounterTargetEffect extends OneShotEffect { public boolean apply(Game game, Ability source) { DynamicValue amount = new ExileFromHandCostCardConvertedMana(); Spell spell = game.getStack().getSpell(targetPointer.getFirst(game, source)); - if (spell != null && spell.getManaCost().convertedManaCost() == amount.calculate(game, source)) { + if (spell != null && spell.getConvertedManaCost() == amount.calculate(game, source)) { return game.getStack().counter(source.getFirstTarget(), source.getSourceId(), game); } return false; diff --git a/Mage.Sets/src/mage/sets/championsofkamigawa/HisokaMinamoSensei.java b/Mage.Sets/src/mage/sets/championsofkamigawa/HisokaMinamoSensei.java index 561195f351..0b289a2022 100644 --- a/Mage.Sets/src/mage/sets/championsofkamigawa/HisokaMinamoSensei.java +++ b/Mage.Sets/src/mage/sets/championsofkamigawa/HisokaMinamoSensei.java @@ -144,7 +144,7 @@ class HisokaMinamoSenseiCounterEffect extends OneShotEffect { Spell spell = game.getStack().getSpell(targetPointer.getFirst(game, source)); if (spell != null) { HisokaMinamoSenseiDiscardTargetCost cost = (HisokaMinamoSenseiDiscardTargetCost) source.getCosts().get(0); - if (cost != null && cost.getConvertedCosts() == spell.getManaCost().convertedManaCost()) { + if (cost != null && cost.getConvertedCosts() == spell.getConvertedManaCost()) { return game.getStack().counter(targetPointer.getFirst(game, source), source.getSourceId(), game); } } diff --git a/Mage.Sets/src/mage/sets/commander2013/EndrekSahrMasterBreeder.java b/Mage.Sets/src/mage/sets/commander2013/EndrekSahrMasterBreeder.java index 36e76a3f16..97de0364e9 100644 --- a/Mage.Sets/src/mage/sets/commander2013/EndrekSahrMasterBreeder.java +++ b/Mage.Sets/src/mage/sets/commander2013/EndrekSahrMasterBreeder.java @@ -138,7 +138,7 @@ class EndrekSahrMasterBreederEffect extends OneShotEffect { public boolean apply(Game game, Ability source) { Spell spell = game.getStack().getSpell(targetPointer.getFirst(game, source)); if (spell != null) { - int cmc = spell.getManaCost().convertedManaCost(); + int cmc = spell.getConvertedManaCost(); if (cmc > 0) { return new CreateTokenEffect(new EndrekSahrMasterBreederThrullToken(), cmc).apply(game, source); } diff --git a/Mage.Sets/src/mage/sets/dragonsmaze/PlasmCapture.java b/Mage.Sets/src/mage/sets/dragonsmaze/PlasmCapture.java index 657abf4866..1cee1a7515 100644 --- a/Mage.Sets/src/mage/sets/dragonsmaze/PlasmCapture.java +++ b/Mage.Sets/src/mage/sets/dragonsmaze/PlasmCapture.java @@ -95,7 +95,7 @@ class PlasmCaptureCounterEffect extends OneShotEffect { Spell spell = game.getStack().getSpell(getTargetPointer().getFirst(game, source)); if (spell != null) { result = game.getStack().counter(getTargetPointer().getFirst(game, source), source.getSourceId(), game); - int mana = spell.getManaCost().convertedManaCost(); + int mana = spell.getConvertedManaCost(); AtTheBeginOfPreCombatMainDelayedTriggeredAbility delayedAbility = new AtTheBeginOfPreCombatMainDelayedTriggeredAbility(new PlasmCaptureManaEffect(mana), TargetController.YOU); delayedAbility.setSourceId(source.getSourceId()); diff --git a/Mage.Sets/src/mage/sets/journeyintonyx/EidolonOfTheGreatRevel.java b/Mage.Sets/src/mage/sets/journeyintonyx/EidolonOfTheGreatRevel.java index 83c65db410..c054d7847c 100644 --- a/Mage.Sets/src/mage/sets/journeyintonyx/EidolonOfTheGreatRevel.java +++ b/Mage.Sets/src/mage/sets/journeyintonyx/EidolonOfTheGreatRevel.java @@ -93,7 +93,7 @@ class EidolonOfTheGreatRevelTriggeredAbility extends TriggeredAbilityImpl { public boolean checkTrigger(GameEvent event, Game game) { if(event.getType() == GameEvent.EventType.SPELL_CAST){ Spell spell = game.getStack().getSpell(event.getTargetId()); - if(spell != null && spell.getManaCost().convertedManaCost() <= 3){ + if(spell != null && spell.getConvertedManaCost() <= 3){ for (Effect effect : this.getEffects()) { effect.setTargetPointer(new FixedTarget(event.getPlayerId())); } diff --git a/Mage.Sets/src/mage/sets/mirrodin/ChaliceOfTheVoid.java b/Mage.Sets/src/mage/sets/mirrodin/ChaliceOfTheVoid.java index 290bf68543..0a71caca92 100644 --- a/Mage.Sets/src/mage/sets/mirrodin/ChaliceOfTheVoid.java +++ b/Mage.Sets/src/mage/sets/mirrodin/ChaliceOfTheVoid.java @@ -28,7 +28,6 @@ package mage.sets.mirrodin; import java.util.UUID; -import static javax.xml.bind.JAXBIntrospector.getValue; import mage.abilities.Ability; import mage.abilities.SpellAbility; import mage.abilities.TriggeredAbilityImpl; @@ -128,7 +127,7 @@ class ChaliceOfTheVoidTriggeredAbility extends TriggeredAbilityImpl { if(event.getType() == GameEvent.EventType.SPELL_CAST){ Permanent chalice = game.getPermanent(this.sourceId); Spell spell = game.getStack().getSpell(event.getTargetId()); - if(spell != null && chalice != null && spell.getManaCost().convertedManaCost() == chalice.getCounters().getCount(CounterType.CHARGE)){ + if(spell != null && chalice != null && spell.getConvertedManaCost() == chalice.getCounters().getCount(CounterType.CHARGE)){ for (Effect effect : this.getEffects()) { effect.setTargetPointer(new FixedTarget(event.getTargetId())); } diff --git a/Mage.Sets/src/mage/sets/planarchaos/ImpsMischief.java b/Mage.Sets/src/mage/sets/planarchaos/ImpsMischief.java index bc204c5952..725f2e7dac 100644 --- a/Mage.Sets/src/mage/sets/planarchaos/ImpsMischief.java +++ b/Mage.Sets/src/mage/sets/planarchaos/ImpsMischief.java @@ -100,7 +100,7 @@ class ImpsMischiefLoseLifeEffect extends OneShotEffect { if (spell != null) { Player player = game.getPlayer(source.getControllerId()); if (player != null) { - player.loseLife(spell.getManaCost().convertedManaCost(), game); + player.loseLife(spell.getConvertedManaCost(), game); return true; } } diff --git a/Mage.Sets/src/mage/sets/saviorsofkamigawa/BounteousKirin.java b/Mage.Sets/src/mage/sets/saviorsofkamigawa/BounteousKirin.java index ffd3b1c0c2..1d0b5a575f 100644 --- a/Mage.Sets/src/mage/sets/saviorsofkamigawa/BounteousKirin.java +++ b/Mage.Sets/src/mage/sets/saviorsofkamigawa/BounteousKirin.java @@ -100,7 +100,7 @@ class BounteousKirinEffect extends OneShotEffect { if (spell != null) { Player controller = game.getPlayer(source.getControllerId()); if (controller != null) { - int life = spell.getManaCost().convertedManaCost(); + int life = spell.getConvertedManaCost(); controller.gainLife(life, game); return true; } diff --git a/Mage.Sets/src/mage/sets/saviorsofkamigawa/CelestialKirin.java b/Mage.Sets/src/mage/sets/saviorsofkamigawa/CelestialKirin.java index 7fb9736b3f..676e6f3a04 100644 --- a/Mage.Sets/src/mage/sets/saviorsofkamigawa/CelestialKirin.java +++ b/Mage.Sets/src/mage/sets/saviorsofkamigawa/CelestialKirin.java @@ -99,7 +99,7 @@ class CelestialKirinEffect extends OneShotEffect { public boolean apply(Game game, Ability source) { Spell spell = game.getState().getStack().getSpell(getTargetPointer().getFirst(game, source)); if (spell != null) { - int cmc = spell.getManaCost().convertedManaCost(); + int cmc = spell.getConvertedManaCost(); FilterPermanent filter = new FilterPermanent(); filter.add(new ConvertedManaCostPredicate(Filter.ComparisonType.Equal, cmc)); return new DestroyAllEffect(filter).apply(game, source); diff --git a/Mage.Sets/src/mage/sets/saviorsofkamigawa/CloudhoofKirin.java b/Mage.Sets/src/mage/sets/saviorsofkamigawa/CloudhoofKirin.java index d793bf561b..2d2ffba18a 100644 --- a/Mage.Sets/src/mage/sets/saviorsofkamigawa/CloudhoofKirin.java +++ b/Mage.Sets/src/mage/sets/saviorsofkamigawa/CloudhoofKirin.java @@ -108,7 +108,7 @@ class CloudhoofKirinEffect extends OneShotEffect { } } if (targetPlayer != null) { - int cardsCount = Math.min(spell.getManaCost().convertedManaCost(), targetPlayer.getLibrary().size()); + int cardsCount = Math.min(spell.getConvertedManaCost(), targetPlayer.getLibrary().size()); for (int i = 0; i < cardsCount; i++) { Card card = targetPlayer.getLibrary().removeFromTop(game); if (card != null) { diff --git a/Mage.Sets/src/mage/sets/saviorsofkamigawa/InfernalKirin.java b/Mage.Sets/src/mage/sets/saviorsofkamigawa/InfernalKirin.java index d5092050e4..e7410d23d6 100644 --- a/Mage.Sets/src/mage/sets/saviorsofkamigawa/InfernalKirin.java +++ b/Mage.Sets/src/mage/sets/saviorsofkamigawa/InfernalKirin.java @@ -103,7 +103,7 @@ class InfernalKirinEffect extends OneShotEffect { public boolean apply(Game game, Ability source) { Spell spell = game.getStack().getSpell(targetPointer.getFirst(game, source)); if (spell != null) { - int cmc = spell.getManaCost().convertedManaCost(); + int cmc = spell.getConvertedManaCost(); Player targetPlayer = null; for(Target target: source.getTargets()) { if (target instanceof TargetPlayer) { diff --git a/Mage.Sets/src/mage/sets/saviorsofkamigawa/SkyfireKirin.java b/Mage.Sets/src/mage/sets/saviorsofkamigawa/SkyfireKirin.java index 9d296aec8c..4f8ad52348 100644 --- a/Mage.Sets/src/mage/sets/saviorsofkamigawa/SkyfireKirin.java +++ b/Mage.Sets/src/mage/sets/saviorsofkamigawa/SkyfireKirin.java @@ -84,7 +84,7 @@ public class SkyfireKirin extends CardImpl { if (ability.getAbilityType().equals(AbilityType.TRIGGERED)) { Spell spell = game.getStack().getSpell(ability.getEffects().get(0).getTargetPointer().getFirst(game, ability)); if (spell != null) { - int cmc = spell.getManaCost().convertedManaCost(); + int cmc = spell.getConvertedManaCost(); ability.getTargets().clear(); FilterPermanent filter = new FilterCreaturePermanent(new StringBuilder("creature with converted mana costs of ").append(cmc).toString()); Target target = new TargetPermanent(filter); diff --git a/Mage.Sets/src/mage/sets/shardsofalara/Manaplasm.java b/Mage.Sets/src/mage/sets/shardsofalara/Manaplasm.java index 5493d2447d..2a31817cb2 100644 --- a/Mage.Sets/src/mage/sets/shardsofalara/Manaplasm.java +++ b/Mage.Sets/src/mage/sets/shardsofalara/Manaplasm.java @@ -92,7 +92,8 @@ class ManaplasmAbility extends TriggeredAbilityImpl { Spell spell = game.getStack().getSpell(event.getTargetId()); if (spell != null && spell.getControllerId().equals(controllerId)) { this.getEffects().remove(0); - this.addEffect(new BoostSourceEffect(spell.getManaCost().convertedManaCost(), spell.getManaCost().convertedManaCost(), Duration.EndOfTurn)); + int x = spell.getConvertedManaCost(); + this.addEffect(new BoostSourceEffect(x,x, Duration.EndOfTurn)); this.getEffects().get(0).setTargetPointer(new FixedTarget(event.getPlayerId())); return true; } @@ -109,4 +110,4 @@ class ManaplasmAbility extends TriggeredAbilityImpl { public ManaplasmAbility copy() { return new ManaplasmAbility(this); } -} \ No newline at end of file +} diff --git a/Mage/src/mage/game/stack/Spell.java b/Mage/src/mage/game/stack/Spell.java index a1f999766d..cb4a34753a 100644 --- a/Mage/src/mage/game/stack/Spell.java +++ b/Mage/src/mage/game/stack/Spell.java @@ -58,7 +58,6 @@ import mage.constants.Zone; import mage.counters.Counter; import mage.counters.Counters; import mage.game.Game; -import mage.game.events.GameEvent; import mage.game.events.ZoneChangeEvent; import mage.game.permanent.Permanent; import mage.game.permanent.PermanentCard; @@ -596,6 +595,19 @@ public class Spell implements StackObject, Card { return card.getManaCost(); } + /** + * 202.3b When calculating the converted mana cost of an object with an {X} in its + * mana cost, X is treated as 0 while the object is not on the stack, and X is + * treated as the number chosen for it while the object is on the stack. + */ + public int getConvertedManaCost() { + int cmc = 0; + for (Ability spellAbility: spellAbilities) { + cmc += spellAbility.getManaCostsToPay().convertedManaCost(); + } + return cmc; + } + @Override public MageInt getPower() { return card.getPower();