mirror of
https://github.com/magefree/mage.git
synced 2025-12-23 03:51:58 -08:00
Fix CMC for flashbacked cards.
This should fix Conflagate/Chalice of the Void interaction.
This commit is contained in:
parent
368dd9a5be
commit
900d68f77d
4 changed files with 77 additions and 23 deletions
|
|
@ -86,4 +86,36 @@ public class ChaliceOfTheVoidTest extends CardTestPlayerBase {
|
|||
|
||||
}
|
||||
|
||||
/*
|
||||
Conflagurate flashed back for X >= 0 should not be countered by chalice.
|
||||
*/
|
||||
@Test
|
||||
public void testConflagrateFlashback() {
|
||||
addCard(Zone.BATTLEFIELD, playerA, "Swamp", 2);
|
||||
addCard(Zone.HAND, playerA, "Chalice of the Void", 1);
|
||||
|
||||
addCard(Zone.GRAVEYARD, playerB, "Conflagrate", 1);
|
||||
addCard(Zone.BATTLEFIELD, playerB, "Mountain", 2);
|
||||
addCard(Zone.HAND, playerB, "Mountain", 1);
|
||||
|
||||
castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerA, "Chalice of the Void");
|
||||
setChoice(playerA, "X=1");
|
||||
|
||||
|
||||
activateAbility(2, PhaseStep.PRECOMBAT_MAIN, playerB, "Flashback {R}{R}");
|
||||
setChoice(playerB, "X=1");
|
||||
addTarget(playerB, playerA);
|
||||
|
||||
setStopAt(2, PhaseStep.BEGIN_COMBAT);
|
||||
execute();
|
||||
|
||||
assertLife(playerA, 19);
|
||||
assertLife(playerB, 20);
|
||||
|
||||
assertExileCount(playerB, "Conflagrate", 1);
|
||||
//TODO: Apparently there are two mountains in the graveyard at the end of the test now.
|
||||
//assertGraveyardCount(playerB, "Mountain", 1);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -28,10 +28,18 @@
|
|||
package mage.abilities;
|
||||
|
||||
import mage.MageObject;
|
||||
import mage.abilities.costs.Cost;
|
||||
import mage.abilities.costs.VariableCost;
|
||||
import mage.abilities.costs.mana.ManaCost;
|
||||
import mage.abilities.costs.mana.VariableManaCost;
|
||||
import mage.abilities.keyword.FlashAbility;
|
||||
import mage.cards.Card;
|
||||
import mage.cards.SplitCard;
|
||||
import mage.constants.*;
|
||||
import mage.constants.AbilityType;
|
||||
import mage.constants.AsThoughEffectType;
|
||||
import mage.constants.SpellAbilityType;
|
||||
import mage.constants.TimingRule;
|
||||
import mage.constants.Zone;
|
||||
import mage.game.Game;
|
||||
import mage.game.events.GameEvent;
|
||||
import mage.players.Player;
|
||||
|
|
@ -172,17 +180,32 @@ public class SpellAbility extends ActivatedAbilityImpl {
|
|||
return cardName;
|
||||
}
|
||||
|
||||
public int getConvertedXManaCost() {
|
||||
public int getConvertedXManaCost(Card card) {
|
||||
int xMultiplier = 0;
|
||||
for (String symbolString : getManaCosts().getSymbols()) {
|
||||
int index = symbolString.indexOf("{X}");
|
||||
while (index != -1) {
|
||||
xMultiplier++;
|
||||
symbolString = symbolString.substring(index + 3);
|
||||
index = symbolString.indexOf("{X}");
|
||||
int amount = 0;
|
||||
if(card == null) {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
return getManaCostsToPay().getX() * xMultiplier;
|
||||
|
||||
for(ManaCost manaCost : card.getManaCost()) {
|
||||
if(manaCost instanceof VariableManaCost) {
|
||||
xMultiplier = ((VariableManaCost)manaCost).getMultiplier();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
boolean hasNonManaXCost = false;
|
||||
for(Cost cost : getCosts()) {
|
||||
if(cost instanceof VariableCost) {
|
||||
hasNonManaXCost = true;
|
||||
amount = ((VariableCost) cost).getAmount();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if(!hasNonManaXCost) {
|
||||
amount = getManaCostsToPay().getX();
|
||||
}
|
||||
return amount * xMultiplier;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -27,13 +27,10 @@
|
|||
*/
|
||||
package mage.abilities.keyword;
|
||||
|
||||
import java.util.Iterator;
|
||||
import java.util.UUID;
|
||||
import mage.abilities.Ability;
|
||||
import mage.abilities.SpellAbility;
|
||||
import mage.abilities.costs.Cost;
|
||||
import mage.abilities.costs.Costs;
|
||||
import mage.abilities.costs.VariableCost;
|
||||
import mage.abilities.costs.mana.ManaCost;
|
||||
import mage.abilities.effects.ContinuousEffect;
|
||||
import mage.abilities.effects.OneShotEffect;
|
||||
|
|
@ -51,6 +48,8 @@ import mage.game.events.ZoneChangeEvent;
|
|||
import mage.players.Player;
|
||||
import mage.target.targetpointer.FixedTarget;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
/**
|
||||
* 702.32. Flashback
|
||||
*
|
||||
|
|
@ -206,21 +205,18 @@ class FlashbackEffect extends OneShotEffect {
|
|||
|
||||
for (Cost cost : source.getCosts()) {
|
||||
if (cost instanceof Costs) {
|
||||
Costs listOfcosts = (Costs) cost;
|
||||
for (Iterator itListOfcosts = listOfcosts.iterator(); itListOfcosts.hasNext();) {
|
||||
Object singleCost = itListOfcosts.next();
|
||||
Costs<Cost> listOfCosts = (Costs<Cost>) cost;
|
||||
for (Cost singleCost : listOfCosts) {
|
||||
if (singleCost instanceof ManaCost) {
|
||||
((ManaCost) singleCost).clearPaid();
|
||||
singleCost.clearPaid();
|
||||
spellAbility.getManaCosts().add((ManaCost) singleCost);
|
||||
spellAbility.getManaCostsToPay().add((ManaCost) singleCost);
|
||||
} else {
|
||||
spellAbility.getCosts().add((Cost) singleCost);
|
||||
spellAbility.getCosts().add(singleCost);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if (!(cost instanceof VariableCost) && !(cost instanceof Costs)) {
|
||||
} else {
|
||||
if (cost instanceof ManaCost) {
|
||||
spellAbility.getManaCosts().add((ManaCost) cost);
|
||||
spellAbility.getManaCostsToPay().add((ManaCost) cost);
|
||||
|
|
|
|||
|
|
@ -27,8 +27,6 @@
|
|||
*/
|
||||
package mage.game.stack;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
import mage.MageInt;
|
||||
import mage.MageObject;
|
||||
import mage.Mana;
|
||||
|
|
@ -65,6 +63,11 @@ import mage.game.permanent.PermanentCard;
|
|||
import mage.players.Player;
|
||||
import mage.util.GameLog;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.EnumSet;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author BetaSteward_at_googlemail.com
|
||||
|
|
@ -554,7 +557,7 @@ public class Spell extends StackObjImpl implements Card {
|
|||
return 0;
|
||||
}
|
||||
for (SpellAbility spellAbility : spellAbilities) {
|
||||
cmc += spellAbility.getConvertedXManaCost();
|
||||
cmc += spellAbility.getConvertedXManaCost(getCard());
|
||||
}
|
||||
cmc += getCard().getManaCost().convertedManaCost();
|
||||
return cmc;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue