1
0
Fork 0
mirror of https://github.com/correl/mage.git synced 2025-03-13 01:09:53 -09:00

* Flashback - Fixed that cost midification effects was applied twice for flashbacked spells.

This commit is contained in:
LevelX2 2014-05-29 16:42:27 +02:00
parent 37a1c9a6f9
commit 83be13a68b
3 changed files with 37 additions and 15 deletions

View file

@ -28,9 +28,9 @@
package mage.abilities;
import mage.constants.AbilityType;
import mage.constants.EffectType;
import mage.constants.Zone;
import java.io.Serializable;
import java.util.List;
import java.util.UUID;
import mage.MageObject;
import mage.abilities.costs.AlternativeCost;
import mage.abilities.costs.Cost;
@ -41,16 +41,15 @@ import mage.abilities.effects.Effect;
import mage.abilities.effects.Effects;
import mage.choices.Choice;
import mage.choices.Choices;
import mage.constants.AbilityType;
import mage.constants.AbilityWord;
import mage.constants.EffectType;
import mage.constants.Zone;
import mage.game.Controllable;
import mage.game.Game;
import mage.target.Target;
import mage.target.Targets;
import java.io.Serializable;
import java.util.List;
import java.util.UUID;
import mage.constants.AbilityWord;
/**
* Practically everything in the game is started from an Ability. This
* interface describes what an Ability is composed of at the highest level.
@ -447,4 +446,11 @@ public interface Ability extends Controllable, Serializable {
*/
String getGameLogMessage(Game game);
/**
* Used to deactivate cost modification logic of ability activation for some special handling
* (e.g. FlashbackAbility gets cost modifiaction twice because of how it#s ahndled now)
*
* @param active execute no cost modification
*/
void setCostModificationActive(boolean active);
}

View file

@ -97,6 +97,7 @@ public abstract class AbilityImpl<T extends AbilityImpl<T>> implements Ability {
protected boolean ruleAtTheTop = false;
protected boolean ruleVisible = true;
protected boolean ruleAdditionalCostsVisible = true;
protected boolean costModificationActive = true;
@Override
public abstract T copy();
@ -133,6 +134,7 @@ public abstract class AbilityImpl<T extends AbilityImpl<T>> implements Ability {
this.ruleAtTheTop = ability.ruleAtTheTop;
this.ruleVisible = ability.ruleVisible;
this.ruleAdditionalCostsVisible = ability.ruleAdditionalCostsVisible;
this.costModificationActive = ability.costModificationActive;
}
@Override
@ -221,11 +223,15 @@ public abstract class AbilityImpl<T extends AbilityImpl<T>> implements Ability {
// if ability can be cast for no mana, clear the mana costs now, because additional mana costs must be paid.
// For Flashback ability can be set X before, so the X costs have to be restored for the flashbacked ability
if (noMana) {
if (this.getManaCostsToPay().getVariableCosts().size() > 0) {
int xValue = this.getManaCostsToPay().getX();
this.getManaCostsToPay().clear();
VariableManaCost xCosts = new VariableManaCost();
xCosts.setAmount(xValue);
this.getManaCostsToPay().add(xCosts);
} else {
this.getManaCostsToPay().clear();
}
}
// 20130201 - 601.2b
// If the spell has alternative or additional costs that will be paid as it's being cast such
@ -329,7 +335,11 @@ public abstract class AbilityImpl<T extends AbilityImpl<T>> implements Ability {
}
//20101001 - 601.2e
if (costModificationActive) {
game.getContinuousEffects().costModification(this, game);
} else {
costModificationActive = true;
}
UUID activatorId = controllerId;
if ((this instanceof ActivatedAbilityImpl) && ((ActivatedAbilityImpl)this).getActivatorId()!= null) {
@ -927,5 +937,10 @@ public abstract class AbilityImpl<T extends AbilityImpl<T>> implements Ability {
return sb.toString();
}
@Override
public void setCostModificationActive(boolean active) {
this.costModificationActive = active;
}
}

View file

@ -198,6 +198,7 @@ class FlashbackEffect extends OneShotEffect<FlashbackEffect> {
target.setRequired(true);
}
game.informPlayers(new StringBuilder(controller.getName()).append(" flashbacks ").append(card.getName()).toString());
spellAbility.setCostModificationActive(false); // prevents to apply cost modification twice for flashbacked spells
return controller.cast(spellAbility, game, true);
}
}