mirror of
https://github.com/magefree/mage.git
synced 2025-12-29 23:12:10 -08:00
Added some handling for X costs of flashback ability.
This commit is contained in:
parent
367dd0b228
commit
5d897ac321
2 changed files with 25 additions and 3 deletions
|
|
@ -37,7 +37,7 @@ import mage.game.Game;
|
|||
*/
|
||||
public interface VariableCost {
|
||||
/**
|
||||
* Returns the variable amount if alreaady set
|
||||
* Returns the variable amount if already set
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
|
|
@ -79,7 +79,7 @@ public interface VariableCost {
|
|||
*/
|
||||
int announceXValue(Ability source, Game game);
|
||||
/**
|
||||
* Returns a fixed cost with the announced variabke value
|
||||
* Returns a fixed cost with the announced variable value
|
||||
*
|
||||
* @param xValue
|
||||
* @return
|
||||
|
|
|
|||
|
|
@ -32,6 +32,8 @@ import mage.abilities.Ability;
|
|||
import mage.abilities.DelayedTriggeredAbility;
|
||||
import mage.abilities.SpellAbility;
|
||||
import mage.abilities.costs.Cost;
|
||||
import mage.abilities.costs.VariableCost;
|
||||
import mage.abilities.costs.mana.VariableManaCost;
|
||||
import mage.abilities.effects.OneShotEffect;
|
||||
import mage.abilities.effects.common.CreateDelayedTriggeredAbilityEffect;
|
||||
import mage.abilities.effects.common.ExileSourceEffect;
|
||||
|
|
@ -171,7 +173,27 @@ class FlashbackEffect extends OneShotEffect<FlashbackEffect> {
|
|||
spellAbility.clear();
|
||||
// used if flashbacked spell has a {X} cost
|
||||
int amount = source.getManaCostsToPay().getX();
|
||||
spellAbility.getManaCostsToPay().setX(amount);
|
||||
if (amount == 0) {
|
||||
// add variable cost like Discard X cards to get the X value to the spell
|
||||
// because there is currently no way to set the x value in anotehr way, it#s set for the
|
||||
// x mana value to be known by the spell
|
||||
for (Cost cost:source.getCosts()) {
|
||||
if (cost instanceof VariableCost && cost.isPaid()) {
|
||||
amount = ((VariableCost) cost).getAmount();
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (amount > 0) {
|
||||
// multiplier must be taken into account because if the base spell has {X}{X} the x value would be wrongly halfed
|
||||
for (VariableCost variableCost: spellAbility.getManaCostsToPay().getVariableCosts()) {
|
||||
if (variableCost instanceof VariableManaCost) {
|
||||
amount = amount * ((VariableManaCost)variableCost).getMultiplier();
|
||||
break;
|
||||
}
|
||||
}
|
||||
spellAbility.getManaCostsToPay().setX(amount);
|
||||
}
|
||||
for (Target target : spellAbility.getTargets()) {
|
||||
target.setRequired(true);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue