* Flashback - Fixed handling of combined flashback costs (e.g. Deep Analysis).

This commit is contained in:
LevelX2 2016-09-15 17:34:25 +02:00
parent 0042dc1ad9
commit 0a5a073637
3 changed files with 98 additions and 48 deletions

View file

@ -27,11 +27,14 @@
*/
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;
import mage.abilities.effects.ReplacementEffectImpl;
@ -200,9 +203,30 @@ class FlashbackEffect extends OneShotEffect {
spellAbility.getManaCosts().clear();
spellAbility.getManaCosts().addAll(source.getManaCosts());
// needed to get e.g. paid costs from Conflagrate
for (Cost cost : source.getCosts()) {
if (!(cost instanceof VariableCost)) {
spellAbility.getCosts().add(cost);
if (cost instanceof Costs) {
Costs listOfcosts = (Costs) cost;
for (Iterator itListOfcosts = listOfcosts.iterator(); itListOfcosts.hasNext();) {
Object singleCost = itListOfcosts.next();
if (singleCost instanceof ManaCost) {
((ManaCost) singleCost).clearPaid();
spellAbility.getManaCosts().add((ManaCost) singleCost);
spellAbility.getManaCostsToPay().add((ManaCost) singleCost);
} else {
spellAbility.getCosts().add((Cost) singleCost);
}
}
}
if (!(cost instanceof VariableCost) && !(cost instanceof Costs)) {
if (cost instanceof ManaCost) {
spellAbility.getManaCosts().add((ManaCost) cost);
spellAbility.getManaCostsToPay().add((ManaCost) cost);
} else {
spellAbility.getCosts().add(cost);
}
}
}
if (!game.isSimulation()) {
@ -217,8 +241,10 @@ class FlashbackEffect extends OneShotEffect {
return false;
}
}
return false;
}
}
class FlashbackReplacementEffect extends ReplacementEffectImpl {

View file

@ -141,16 +141,20 @@ public class Spell extends StackObjImpl implements Card {
if (!spellAbilities.get(0).activate(game, noMana)) {
return false;
}
// if there are more abilities (fused split spell) or first ability added new abilities (splice), activate the additional abilities
boolean ignoreAbility = true;
boolean payNoMana = noMana;
for (SpellAbility spellAbility : spellAbilities) {
// costs for spliced abilities were added to main spellAbility, so pay no mana for spliced abilities
payNoMana |= spellAbility.getSpellAbilityType().equals(SpellAbilityType.SPLICE);
if (ignoreAbility) {
ignoreAbility = false;
} else if (!spellAbility.activate(game, payNoMana)) {
return false;
if (spellAbilities.size() > 1) {
// if there are more abilities (fused split spell) or first ability added new abilities (splice), activate the additional abilities
boolean ignoreAbility = true;
boolean payNoMana = noMana;
for (SpellAbility spellAbility : spellAbilities) {
if (ignoreAbility) {
ignoreAbility = false;
} else {
// costs for spliced abilities were added to main spellAbility, so pay no mana for spliced abilities
payNoMana |= spellAbility.getSpellAbilityType().equals(SpellAbilityType.SPLICE);
if (!spellAbility.activate(game, payNoMana)) {
return false;
}
}
}
}
return true;
@ -490,7 +494,7 @@ public class Spell extends StackObjImpl implements Card {
public ObjectColor getColor(Game game) {
return color;
}
@Override
public ObjectColor getFrameColor(Game game) {
return frameColor;
@ -536,7 +540,7 @@ public class Spell extends StackObjImpl implements Card {
public MageInt getToughness() {
return card.getToughness();
}
@Override
public int getStartingLoyalty() {
return card.getStartingLoyalty();
@ -595,7 +599,7 @@ public class Spell extends StackObjImpl implements Card {
public String getTokenSetCode() {
return card.getTokenSetCode();
}
@Override
public String getTokenDescriptor() {
return card.getTokenDescriptor();