From 3d1bb8e1abe646f6509756a6c3444759600af948 Mon Sep 17 00:00:00 2001 From: magenoxx Date: Thu, 23 Aug 2012 13:41:40 +0400 Subject: [PATCH] Failing test and fix for additional costs not displayed in tooltips --- .../cards/rules/AdditionalCostRuleTest.java | 34 +++++++++++++++++++ Mage/src/mage/abilities/AbilitiesImpl.java | 20 ++++++++--- 2 files changed, 49 insertions(+), 5 deletions(-) create mode 100644 Mage.Tests/src/test/java/org/mage/test/cards/rules/AdditionalCostRuleTest.java diff --git a/Mage.Tests/src/test/java/org/mage/test/cards/rules/AdditionalCostRuleTest.java b/Mage.Tests/src/test/java/org/mage/test/cards/rules/AdditionalCostRuleTest.java new file mode 100644 index 0000000000..e20eeae46e --- /dev/null +++ b/Mage.Tests/src/test/java/org/mage/test/cards/rules/AdditionalCostRuleTest.java @@ -0,0 +1,34 @@ +package org.mage.test.cards.rules; + +import mage.Constants; +import mage.cards.Card; +import org.junit.Assert; +import org.junit.Test; +import org.mage.test.serverside.base.CardTestPlayerBase; + +/** + * + * @author magenoxx_at_googlemail.com + */ +public class AdditionalCostRuleTest extends CardTestPlayerBase { + + @Test + public void testAdditionalCostDisplayed() { + addCard(Constants.Zone.GRAVEYARD, playerA, "Silvergill Adept"); + + setStopAt(1, Constants.PhaseStep.BEGIN_COMBAT); + execute(); + + Card firewildBorderpost = playerA.getGraveyard().getCards(currentGame).iterator().next(); + boolean found = false; + for (String rule : firewildBorderpost.getRules()) { + if (rule.startsWith("As an additional cost to cast")) { + found = true; + break; + } + } + Assert.assertTrue("Couldn't find rule text for additional cost on a card: " + firewildBorderpost.getName(), found); + } + + +} diff --git a/Mage/src/mage/abilities/AbilitiesImpl.java b/Mage/src/mage/abilities/AbilitiesImpl.java index 327873275b..299f230f0d 100644 --- a/Mage/src/mage/abilities/AbilitiesImpl.java +++ b/Mage/src/mage/abilities/AbilitiesImpl.java @@ -31,6 +31,7 @@ package mage.abilities; import mage.Constants.Zone; import mage.abilities.common.ZoneChangeTriggeredAbility; import mage.abilities.costs.AlternativeCost; +import mage.abilities.costs.Cost; import mage.abilities.keyword.KickerAbility; import mage.abilities.keyword.ProtectionAbility; import mage.abilities.mana.ManaAbility; @@ -73,12 +74,21 @@ public class AbilitiesImpl extends ArrayList implements Ab for (T ability:this) { if (!(ability instanceof SpellAbility || ability instanceof PlayLandAbility)) rules.add(ability.getRule()); - if (ability instanceof SpellAbility && ability.getAlternativeCosts().size() > 0) { - StringBuilder sbRule = new StringBuilder(); - for (AlternativeCost cost: ability.getAlternativeCosts()) { - sbRule.append(cost.getName()).append(".\n"); + if (ability instanceof SpellAbility) { + if (ability.getAlternativeCosts().size() > 0) { + StringBuilder sbRule = new StringBuilder(); + for (AlternativeCost cost: ability.getAlternativeCosts()) { + sbRule.append(cost.getName()).append(".\n"); + } + rules.add(sbRule.toString()); + } + if (ability.getCosts().size() > 0) { + StringBuilder sbRule = new StringBuilder(); + for (Cost cost: ability.getCosts()) { + sbRule.append(cost.getText()).append(".\n"); + } + rules.add(sbRule.toString()); } - rules.add(sbRule.toString()); } }