* Flashback ability - Fixed that flashback abilities with non mana costs (e.g. Cabal Therapy) added the costs wrongly again as additional costs to the tooltip text of the card.

This commit is contained in:
LevelX2 2014-03-27 13:33:12 +01:00
parent ad6898ca54
commit a229d4d260
9 changed files with 52 additions and 9 deletions

View file

@ -32,7 +32,6 @@ import mage.constants.CardType;
import mage.constants.Outcome;
import mage.constants.Rarity;
import mage.constants.TimingRule;
import mage.constants.Zone;
import mage.abilities.Ability;
import mage.abilities.costs.common.SacrificeTargetCost;
import mage.abilities.effects.OneShotEffect;
@ -64,7 +63,9 @@ public class CabalTherapy extends CardImpl<CabalTherapy> {
this.getSpellAbility().addTarget(new TargetPlayer(true));
this.getSpellAbility().addEffect(new CabalTherapyEffect());
// Flashback-Sacrifice a creature.
this.addAbility(new FlashbackAbility(new SacrificeTargetCost(new TargetControlledCreaturePermanent(1,1,new FilterControlledCreaturePermanent("a creature"), true)), TimingRule.SORCERY));
this.addAbility(new FlashbackAbility(
new SacrificeTargetCost(new TargetControlledCreaturePermanent(1,1,new FilterControlledCreaturePermanent("a creature"), true)),
TimingRule.SORCERY));
}
public CabalTherapy(final CabalTherapy card) {

View file

@ -40,6 +40,7 @@ import mage.constants.TimingRule;
import mage.target.TargetPlayer;
import java.util.UUID;
import mage.abilities.costs.Cost;
/**
*
@ -58,7 +59,7 @@ public class DeepAnalysis extends CardImpl<DeepAnalysis> {
this.getSpellAbility().addTarget(new TargetPlayer());
// Flashback-{1}{U}, Pay 3 life.
Costs costs = new CostsImpl();
CostsImpl costs = new CostsImpl();
costs.add(new ManaCostsImpl("{1}{U}"));
costs.add(new PayLifeCost(3));
this.addAbility(new FlashbackAbility(costs, TimingRule.SORCERY));

View file

@ -95,7 +95,7 @@ public class AbilitiesImpl<T extends Ability> extends ArrayList<T> implements Ab
}
rules.add(sbRule.toString());
}
if (ability.getCosts().size() > 0) {
if (ability.getAdditionalCostsRuleVisible() && ability.getCosts().size() > 0) {
StringBuilder sbRule = new StringBuilder();
for (Cost cost: ability.getCosts()) {
if (cost.getText() != null && !cost.getText().isEmpty()) {

View file

@ -391,6 +391,7 @@ public interface Ability extends Controllable, Serializable {
*/
boolean getRuleVisible();
/**
* Sets the value for the ruleVisible attribute
*
@ -401,7 +402,24 @@ public interface Ability extends Controllable, Serializable {
*/
void setRuleVisible(boolean ruleVisible);
/**
* Returns true if the additional costs of the abilitiy should be visible on the tooltip text
*
* @return
*/
boolean getAdditionalCostsRuleVisible();
/**
* Sets the value for the additional costs rule attribute
*
* true = rule will be shown for the card / permanent
* false = rule won't be shown
*
* @param ruleAdditionalCostsVisible
*/
void setAdditionalCostsRuleVisible(boolean ruleAdditionalCostsVisible);
/**
* Get the originalId of the ability
*

View file

@ -95,6 +95,7 @@ public abstract class AbilityImpl<T extends AbilityImpl<T>> implements Ability {
protected boolean usesStack = true;
protected boolean ruleAtTheTop = false;
protected boolean ruleVisible = true;
protected boolean ruleAdditionalCostsVisible = true;
@Override
public abstract T copy();
@ -130,6 +131,7 @@ public abstract class AbilityImpl<T extends AbilityImpl<T>> implements Ability {
this.modes = ability.modes.copy();
this.ruleAtTheTop = ability.ruleAtTheTop;
this.ruleVisible = ability.ruleVisible;
this.ruleAdditionalCostsVisible = ability.ruleAdditionalCostsVisible;
}
@Override
@ -760,7 +762,16 @@ public abstract class AbilityImpl<T extends AbilityImpl<T>> implements Ability {
this.ruleVisible = ruleVisible;
}
@Override
public boolean getAdditionalCostsRuleVisible() {
return ruleAdditionalCostsVisible;
}
@Override
public void setAdditionalCostsRuleVisible(boolean ruleAdditionalCostsVisible) {
this.ruleAdditionalCostsVisible = ruleAdditionalCostsVisible;
}
@Override
public UUID getOriginalId() {
return this.originalId;

View file

@ -40,6 +40,7 @@ import mage.target.Targets;
/**
*
* @author BetaSteward_at_googlemail.com
* @param <T>
*/
public class CostsImpl<T extends Cost> extends ArrayList<T> implements Costs<T> {
@ -97,7 +98,7 @@ public class CostsImpl<T extends Cost> extends ArrayList<T> implements Costs<T>
@Override
public boolean isPaid() {
for (T cost: this) {
if (!((T)cost instanceof VariableManaCost) && !cost.isPaid()) {
if (!(cost instanceof VariableManaCost) && !cost.isPaid()) {
return false;
}
}
@ -120,7 +121,7 @@ public class CostsImpl<T extends Cost> extends ArrayList<T> implements Costs<T>
@Override
public Costs<T> getUnpaid() {
Costs<T> unpaid = new CostsImpl<T>();
Costs<T> unpaid = new CostsImpl<>();
for (T cost: this) {
if (!cost.isPaid()) {
unpaid.add(cost);
@ -139,7 +140,7 @@ public class CostsImpl<T extends Cost> extends ArrayList<T> implements Costs<T>
@Override
public List<VariableCost> getVariableCosts() {
List<VariableCost> variableCosts = new ArrayList<VariableCost>();
List<VariableCost> variableCosts = new ArrayList<>();
for (T cost: this) {
if (cost instanceof VariableCost) {
variableCosts.add((VariableCost) cost);

View file

@ -40,7 +40,7 @@ import java.util.UUID;
*/
public class PayLifeCost extends CostImpl<PayLifeCost> {
private int amount;
private final int amount;
public PayLifeCost(int amount) {
this.amount = amount;

View file

@ -57,6 +57,7 @@ public class FlashbackAbility extends SpellAbility {
public FlashbackAbility(Cost cost, TimingRule timingRule) {
super(null, "", Zone.GRAVEYARD);
this.setAdditionalCostsRuleVisible(false);
this.name = new StringBuilder("Flashback ").append(cost.getText()).toString();
this.addEffect(new FlashbackEffect());
this.addCost(cost);
@ -76,7 +77,7 @@ public class FlashbackAbility extends SpellAbility {
public FlashbackAbility copy() {
return new FlashbackAbility(this);
}
@Override
public String getRule(boolean all) {
return this.getRule();

View file

@ -390,6 +390,16 @@ public class StackAbility implements StackObject, Ability {
this.ability.setRuleVisible(ruleVisible);
}
@Override
public boolean getAdditionalCostsRuleVisible() {
return this.ability.getAdditionalCostsRuleVisible();
}
@Override
public void setAdditionalCostsRuleVisible(boolean ruleAdditionalCostsVisible) {
this.ability.setAdditionalCostsRuleVisible(ruleAdditionalCostsVisible);
}
@Override
public UUID getOriginalId() {
return this.ability.getOriginalId();