mirror of
https://github.com/correl/mage.git
synced 2024-12-24 03:00:14 +00:00
* Conflagrate - Fixed that the damage amount could be calulated if cast by flashback.
This commit is contained in:
parent
1335d58e77
commit
50b5602459
3 changed files with 80 additions and 9 deletions
|
@ -29,10 +29,12 @@ package mage.sets.timespiral;
|
|||
|
||||
import java.util.UUID;
|
||||
import mage.abilities.Ability;
|
||||
import mage.abilities.costs.Cost;
|
||||
import mage.abilities.costs.common.DiscardTargetCost;
|
||||
import mage.abilities.costs.common.DiscardXTargetCost;
|
||||
import mage.abilities.costs.mana.ManaCostsImpl;
|
||||
import mage.abilities.dynamicvalue.DynamicValue;
|
||||
import mage.abilities.dynamicvalue.common.ManacostVariableValue;
|
||||
import mage.abilities.effects.Effect;
|
||||
import mage.abilities.effects.common.DamageMultiEffect;
|
||||
import mage.abilities.keyword.FlashbackAbility;
|
||||
import mage.cards.CardImpl;
|
||||
|
@ -40,6 +42,7 @@ import mage.constants.CardType;
|
|||
import mage.constants.Rarity;
|
||||
import mage.constants.TimingRule;
|
||||
import mage.filter.FilterCard;
|
||||
import mage.game.Game;
|
||||
import mage.target.common.TargetCreatureOrPlayerAmount;
|
||||
|
||||
/**
|
||||
|
@ -52,17 +55,16 @@ public class Conflagrate extends CardImpl {
|
|||
super(ownerId, 151, "Conflagrate", Rarity.UNCOMMON, new CardType[]{CardType.SORCERY}, "{X}{X}{R}");
|
||||
this.expansionSetCode = "TSP";
|
||||
|
||||
|
||||
// Conflagrate deals X damage divided as you choose among any number of target creatures and/or players.
|
||||
DynamicValue xValue = new ManacostVariableValue();
|
||||
DynamicValue xValue = new ConflagrateVariableValue();
|
||||
this.getSpellAbility().addEffect(new DamageMultiEffect(xValue));
|
||||
this.getSpellAbility().addTarget(new TargetCreatureOrPlayerAmount(xValue));
|
||||
|
||||
this.getSpellAbility().addTarget(new TargetCreatureOrPlayerAmount(xValue));
|
||||
|
||||
// Flashback-{R}{R}, Discard X cards.
|
||||
Ability ability = new FlashbackAbility(new ManaCostsImpl("{R}{R}"), TimingRule.SORCERY);
|
||||
ability.addCost(new DiscardXTargetCost(new FilterCard("cards")));
|
||||
this.addAbility(ability);
|
||||
|
||||
|
||||
}
|
||||
|
||||
public Conflagrate(final Conflagrate card) {
|
||||
|
@ -74,3 +76,31 @@ public class Conflagrate extends CardImpl {
|
|||
return new Conflagrate(this);
|
||||
}
|
||||
}
|
||||
|
||||
class ConflagrateVariableValue implements DynamicValue {
|
||||
|
||||
@Override
|
||||
public int calculate(Game game, Ability sourceAbility, Effect effect) {
|
||||
for (Cost cost : sourceAbility.getCosts()) {
|
||||
if (cost instanceof DiscardTargetCost) {
|
||||
return ((DiscardTargetCost) cost).getCards().size();
|
||||
}
|
||||
}
|
||||
return sourceAbility.getManaCostsToPay().getX();
|
||||
}
|
||||
|
||||
@Override
|
||||
public ConflagrateVariableValue copy() {
|
||||
return new ConflagrateVariableValue();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "X";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getMessage() {
|
||||
return "";
|
||||
}
|
||||
}
|
||||
|
|
|
@ -148,4 +148,34 @@ public class FlashbackTest extends CardTestPlayerBase {
|
|||
assertExileCount("Unified Front", 1);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Conflagrate flashback no longer works. Requires mana payment but never
|
||||
* allows target selection before resolving.
|
||||
*/
|
||||
@Test
|
||||
public void testConflagrate() {
|
||||
addCard(Zone.BATTLEFIELD, playerA, "Mountain", 7);
|
||||
|
||||
// Conflagrate deals X damage divided as you choose among any number of target creatures and/or players.
|
||||
// Flashback-{R}{R}, Discard X cards.
|
||||
addCard(Zone.HAND, playerA, "Conflagrate", 1);
|
||||
|
||||
addCard(Zone.HAND, playerA, "Forest", 4);
|
||||
|
||||
castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerA, "Conflagrate");
|
||||
setChoice(playerA, "X=2");
|
||||
|
||||
activateAbility(1, PhaseStep.POSTCOMBAT_MAIN, playerA, "Flashback");
|
||||
setChoice(playerA, "X=4");
|
||||
|
||||
setStopAt(1, PhaseStep.END_TURN);
|
||||
execute();
|
||||
|
||||
assertLife(playerA, 20);
|
||||
assertLife(playerB, 14);
|
||||
|
||||
assertExileCount("Conflagrate", 1);
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
@ -31,6 +31,7 @@ import java.util.UUID;
|
|||
import mage.abilities.Ability;
|
||||
import mage.abilities.SpellAbility;
|
||||
import mage.abilities.costs.Cost;
|
||||
import mage.abilities.costs.VariableCost;
|
||||
import mage.abilities.effects.OneShotEffect;
|
||||
import mage.abilities.effects.ReplacementEffectImpl;
|
||||
import mage.cards.Card;
|
||||
|
@ -121,6 +122,9 @@ public class FlashbackAbility extends SpellAbility {
|
|||
sbRule.append(manaCosts.getText());
|
||||
}
|
||||
if (costs.size() > 0) {
|
||||
if (manaCosts.size() > 0) {
|
||||
sbRule.append(", ");
|
||||
}
|
||||
sbRule.append(costs.getText());
|
||||
sbRule.append(".");
|
||||
}
|
||||
|
@ -173,19 +177,26 @@ class FlashbackEffect extends OneShotEffect {
|
|||
SpellAbility spellAbility;
|
||||
switch (((FlashbackAbility) source).getSpellAbilityType()) {
|
||||
case SPLIT_LEFT:
|
||||
spellAbility = ((SplitCard) card).getLeftHalfCard().getSpellAbility();
|
||||
spellAbility = ((SplitCard) card).getLeftHalfCard().getSpellAbility().copy();
|
||||
break;
|
||||
case SPLIT_RIGHT:
|
||||
spellAbility = ((SplitCard) card).getRightHalfCard().getSpellAbility();
|
||||
spellAbility = ((SplitCard) card).getRightHalfCard().getSpellAbility().copy();
|
||||
break;
|
||||
default:
|
||||
spellAbility = card.getSpellAbility();
|
||||
spellAbility = card.getSpellAbility().copy();
|
||||
}
|
||||
|
||||
spellAbility.clear();
|
||||
// set the payed flashback costs to the spell ability so abilities like Converge or calculation of {X} values work
|
||||
spellAbility.getManaCostsToPay().clear();
|
||||
spellAbility.getManaCostsToPay().addAll(source.getManaCostsToPay());
|
||||
// needed to get e.g. paid costs from Conflagrate
|
||||
spellAbility.getCosts().clear();
|
||||
for (Cost cost : source.getCosts()) {
|
||||
if (!(cost instanceof VariableCost)) {
|
||||
spellAbility.getCosts().add(cost);
|
||||
}
|
||||
}
|
||||
if (!game.isSimulation()) {
|
||||
game.informPlayers(controller.getLogName() + " flashbacks " + card.getLogName());
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue