forked from External/mage
Failing test and fix for alternative costs not displayed on cards
This commit is contained in:
parent
cb63af7559
commit
2fe2da8eaf
2 changed files with 42 additions and 0 deletions
|
|
@ -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 AlternativeCostRuleTest extends CardTestPlayerBase {
|
||||
|
||||
@Test
|
||||
public void testAlternativeCostDisplayed() {
|
||||
addCard(Constants.Zone.GRAVEYARD, playerA, "Firewild Borderpost");
|
||||
|
||||
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("You may pay")) {
|
||||
found = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
Assert.assertTrue("Couldn't find rule text for alternative cost on a card: " + firewildBorderpost.getName(), found);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
@ -30,6 +30,7 @@ package mage.abilities;
|
|||
|
||||
import mage.Constants.Zone;
|
||||
import mage.abilities.common.ZoneChangeTriggeredAbility;
|
||||
import mage.abilities.costs.AlternativeCost;
|
||||
import mage.abilities.keyword.KickerAbility;
|
||||
import mage.abilities.keyword.ProtectionAbility;
|
||||
import mage.abilities.mana.ManaAbility;
|
||||
|
|
@ -72,6 +73,13 @@ public class AbilitiesImpl<T extends Ability> extends ArrayList<T> 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");
|
||||
}
|
||||
rules.add(sbRule.toString());
|
||||
}
|
||||
}
|
||||
|
||||
return rules;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue