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;
|
package mage.abilities;
|
||||||
|
|
||||||
import mage.MageObject;
|
import mage.MageObject;
|
||||||
|
import mage.abilities.costs.Cost;
|
||||||
|
import mage.abilities.costs.VariableCost;
|
||||||
import mage.abilities.costs.mana.ManaCost;
|
import mage.abilities.costs.mana.ManaCost;
|
||||||
|
import mage.abilities.costs.mana.VariableManaCost;
|
||||||
import mage.abilities.keyword.FlashAbility;
|
import mage.abilities.keyword.FlashAbility;
|
||||||
|
import mage.cards.Card;
|
||||||
import mage.cards.SplitCard;
|
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.Game;
|
||||||
import mage.game.events.GameEvent;
|
import mage.game.events.GameEvent;
|
||||||
import mage.players.Player;
|
import mage.players.Player;
|
||||||
|
|
@ -172,17 +180,32 @@ public class SpellAbility extends ActivatedAbilityImpl {
|
||||||
return cardName;
|
return cardName;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getConvertedXManaCost() {
|
public int getConvertedXManaCost(Card card) {
|
||||||
int xMultiplier = 0;
|
int xMultiplier = 0;
|
||||||
for (String symbolString : getManaCosts().getSymbols()) {
|
int amount = 0;
|
||||||
int index = symbolString.indexOf("{X}");
|
if(card == null) {
|
||||||
while (index != -1) {
|
return 0;
|
||||||
xMultiplier++;
|
|
||||||
symbolString = symbolString.substring(index + 3);
|
|
||||||
index = symbolString.indexOf("{X}");
|
|
||||||
}
|
}
|
||||||
}
|
|
||||||
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;
|
package mage.abilities.keyword;
|
||||||
|
|
||||||
import java.util.Iterator;
|
|
||||||
import java.util.UUID;
|
|
||||||
import mage.abilities.Ability;
|
import mage.abilities.Ability;
|
||||||
import mage.abilities.SpellAbility;
|
import mage.abilities.SpellAbility;
|
||||||
import mage.abilities.costs.Cost;
|
import mage.abilities.costs.Cost;
|
||||||
import mage.abilities.costs.Costs;
|
import mage.abilities.costs.Costs;
|
||||||
import mage.abilities.costs.VariableCost;
|
|
||||||
import mage.abilities.costs.mana.ManaCost;
|
import mage.abilities.costs.mana.ManaCost;
|
||||||
import mage.abilities.effects.ContinuousEffect;
|
import mage.abilities.effects.ContinuousEffect;
|
||||||
import mage.abilities.effects.OneShotEffect;
|
import mage.abilities.effects.OneShotEffect;
|
||||||
|
|
@ -51,6 +48,8 @@ import mage.game.events.ZoneChangeEvent;
|
||||||
import mage.players.Player;
|
import mage.players.Player;
|
||||||
import mage.target.targetpointer.FixedTarget;
|
import mage.target.targetpointer.FixedTarget;
|
||||||
|
|
||||||
|
import java.util.UUID;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 702.32. Flashback
|
* 702.32. Flashback
|
||||||
*
|
*
|
||||||
|
|
@ -206,21 +205,18 @@ class FlashbackEffect extends OneShotEffect {
|
||||||
|
|
||||||
for (Cost cost : source.getCosts()) {
|
for (Cost cost : source.getCosts()) {
|
||||||
if (cost instanceof Costs) {
|
if (cost instanceof Costs) {
|
||||||
Costs listOfcosts = (Costs) cost;
|
Costs<Cost> listOfCosts = (Costs<Cost>) cost;
|
||||||
for (Iterator itListOfcosts = listOfcosts.iterator(); itListOfcosts.hasNext();) {
|
for (Cost singleCost : listOfCosts) {
|
||||||
Object singleCost = itListOfcosts.next();
|
|
||||||
if (singleCost instanceof ManaCost) {
|
if (singleCost instanceof ManaCost) {
|
||||||
((ManaCost) singleCost).clearPaid();
|
singleCost.clearPaid();
|
||||||
spellAbility.getManaCosts().add((ManaCost) singleCost);
|
spellAbility.getManaCosts().add((ManaCost) singleCost);
|
||||||
spellAbility.getManaCostsToPay().add((ManaCost) singleCost);
|
spellAbility.getManaCostsToPay().add((ManaCost) singleCost);
|
||||||
} else {
|
} else {
|
||||||
spellAbility.getCosts().add((Cost) singleCost);
|
spellAbility.getCosts().add(singleCost);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
} else {
|
||||||
|
|
||||||
if (!(cost instanceof VariableCost) && !(cost instanceof Costs)) {
|
|
||||||
if (cost instanceof ManaCost) {
|
if (cost instanceof ManaCost) {
|
||||||
spellAbility.getManaCosts().add((ManaCost) cost);
|
spellAbility.getManaCosts().add((ManaCost) cost);
|
||||||
spellAbility.getManaCostsToPay().add((ManaCost) cost);
|
spellAbility.getManaCostsToPay().add((ManaCost) cost);
|
||||||
|
|
|
||||||
|
|
@ -27,8 +27,6 @@
|
||||||
*/
|
*/
|
||||||
package mage.game.stack;
|
package mage.game.stack;
|
||||||
|
|
||||||
import java.util.*;
|
|
||||||
|
|
||||||
import mage.MageInt;
|
import mage.MageInt;
|
||||||
import mage.MageObject;
|
import mage.MageObject;
|
||||||
import mage.Mana;
|
import mage.Mana;
|
||||||
|
|
@ -65,6 +63,11 @@ import mage.game.permanent.PermanentCard;
|
||||||
import mage.players.Player;
|
import mage.players.Player;
|
||||||
import mage.util.GameLog;
|
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
|
* @author BetaSteward_at_googlemail.com
|
||||||
|
|
@ -554,7 +557,7 @@ public class Spell extends StackObjImpl implements Card {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
for (SpellAbility spellAbility : spellAbilities) {
|
for (SpellAbility spellAbility : spellAbilities) {
|
||||||
cmc += spellAbility.getConvertedXManaCost();
|
cmc += spellAbility.getConvertedXManaCost(getCard());
|
||||||
}
|
}
|
||||||
cmc += getCard().getManaCost().convertedManaCost();
|
cmc += getCard().getManaCost().convertedManaCost();
|
||||||
return cmc;
|
return cmc;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue