From a229d4d260b760a852ae0013cc374c62d1646225 Mon Sep 17 00:00:00 2001 From: LevelX2 Date: Thu, 27 Mar 2014 13:33:12 +0100 Subject: [PATCH] * 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. --- .../src/mage/sets/judgment/CabalTherapy.java | 5 +++-- .../src/mage/sets/torment/DeepAnalysis.java | 3 ++- Mage/src/mage/abilities/AbilitiesImpl.java | 2 +- Mage/src/mage/abilities/Ability.java | 18 ++++++++++++++++++ Mage/src/mage/abilities/AbilityImpl.java | 11 +++++++++++ Mage/src/mage/abilities/costs/CostsImpl.java | 7 ++++--- .../abilities/costs/common/PayLifeCost.java | 2 +- .../abilities/keyword/FlashbackAbility.java | 3 ++- Mage/src/mage/game/stack/StackAbility.java | 10 ++++++++++ 9 files changed, 52 insertions(+), 9 deletions(-) diff --git a/Mage.Sets/src/mage/sets/judgment/CabalTherapy.java b/Mage.Sets/src/mage/sets/judgment/CabalTherapy.java index 8e40b95435..eb204dc16e 100644 --- a/Mage.Sets/src/mage/sets/judgment/CabalTherapy.java +++ b/Mage.Sets/src/mage/sets/judgment/CabalTherapy.java @@ -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 { 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) { diff --git a/Mage.Sets/src/mage/sets/torment/DeepAnalysis.java b/Mage.Sets/src/mage/sets/torment/DeepAnalysis.java index 4be9bc4ecc..ba38d1c5d3 100644 --- a/Mage.Sets/src/mage/sets/torment/DeepAnalysis.java +++ b/Mage.Sets/src/mage/sets/torment/DeepAnalysis.java @@ -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 { 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)); diff --git a/Mage/src/mage/abilities/AbilitiesImpl.java b/Mage/src/mage/abilities/AbilitiesImpl.java index d23614a53a..bac6a3e417 100644 --- a/Mage/src/mage/abilities/AbilitiesImpl.java +++ b/Mage/src/mage/abilities/AbilitiesImpl.java @@ -95,7 +95,7 @@ public class AbilitiesImpl extends ArrayList 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()) { diff --git a/Mage/src/mage/abilities/Ability.java b/Mage/src/mage/abilities/Ability.java index e17880624c..502e39c6e3 100644 --- a/Mage/src/mage/abilities/Ability.java +++ b/Mage/src/mage/abilities/Ability.java @@ -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 * diff --git a/Mage/src/mage/abilities/AbilityImpl.java b/Mage/src/mage/abilities/AbilityImpl.java index 0dcb267c3b..1adeb17d9b 100644 --- a/Mage/src/mage/abilities/AbilityImpl.java +++ b/Mage/src/mage/abilities/AbilityImpl.java @@ -95,6 +95,7 @@ public abstract class AbilityImpl> 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> 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> 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; diff --git a/Mage/src/mage/abilities/costs/CostsImpl.java b/Mage/src/mage/abilities/costs/CostsImpl.java index f98317e3eb..7cbe7b517a 100644 --- a/Mage/src/mage/abilities/costs/CostsImpl.java +++ b/Mage/src/mage/abilities/costs/CostsImpl.java @@ -40,6 +40,7 @@ import mage.target.Targets; /** * * @author BetaSteward_at_googlemail.com + * @param */ public class CostsImpl extends ArrayList implements Costs { @@ -97,7 +98,7 @@ public class CostsImpl extends ArrayList implements Costs @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 extends ArrayList implements Costs @Override public Costs getUnpaid() { - Costs unpaid = new CostsImpl(); + Costs unpaid = new CostsImpl<>(); for (T cost: this) { if (!cost.isPaid()) { unpaid.add(cost); @@ -139,7 +140,7 @@ public class CostsImpl extends ArrayList implements Costs @Override public List getVariableCosts() { - List variableCosts = new ArrayList(); + List variableCosts = new ArrayList<>(); for (T cost: this) { if (cost instanceof VariableCost) { variableCosts.add((VariableCost) cost); diff --git a/Mage/src/mage/abilities/costs/common/PayLifeCost.java b/Mage/src/mage/abilities/costs/common/PayLifeCost.java index c495a2473f..279b6d5ed3 100644 --- a/Mage/src/mage/abilities/costs/common/PayLifeCost.java +++ b/Mage/src/mage/abilities/costs/common/PayLifeCost.java @@ -40,7 +40,7 @@ import java.util.UUID; */ public class PayLifeCost extends CostImpl { - private int amount; + private final int amount; public PayLifeCost(int amount) { this.amount = amount; diff --git a/Mage/src/mage/abilities/keyword/FlashbackAbility.java b/Mage/src/mage/abilities/keyword/FlashbackAbility.java index 1ae0433b55..349da62513 100644 --- a/Mage/src/mage/abilities/keyword/FlashbackAbility.java +++ b/Mage/src/mage/abilities/keyword/FlashbackAbility.java @@ -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(); diff --git a/Mage/src/mage/game/stack/StackAbility.java b/Mage/src/mage/game/stack/StackAbility.java index 774802ca19..17a73f75de 100644 --- a/Mage/src/mage/game/stack/StackAbility.java +++ b/Mage/src/mage/game/stack/StackAbility.java @@ -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();