* AlternativeCost - Fix to rule text generation.

This commit is contained in:
LevelX2 2014-02-27 08:59:35 +01:00
parent 664a506dba
commit 25994e8910
4 changed files with 19 additions and 11 deletions

View file

@ -30,18 +30,15 @@ package mage.sets.alarareborn;
import java.util.UUID;
import mage.abilities.Ability;
import mage.constants.CardType;
import mage.constants.Rarity;
import mage.abilities.common.EntersBattlefieldTappedAbility;
import mage.abilities.costs.AlternativeCostImpl;
import mage.abilities.costs.AlternativeCostSourceAbility;
import mage.abilities.costs.CompositeCost;
import mage.abilities.costs.Cost;
import mage.abilities.costs.common.ReturnToHandTargetCost;
import mage.abilities.costs.mana.GenericManaCost;
import mage.abilities.mana.GreenManaAbility;
import mage.abilities.mana.RedManaAbility;
import mage.cards.CardImpl;
import mage.constants.CardType;
import mage.constants.Rarity;
import mage.filter.common.FilterControlledLandPermanent;
import mage.filter.common.FilterControlledPermanent;
import mage.filter.predicate.mageobject.SupertypePredicate;

View file

@ -82,4 +82,6 @@ public interface AlternativeCost2 extends Cost {
*/
boolean isActivated();
Cost getCost();
}

View file

@ -147,4 +147,13 @@ public class AlternativeCost2Impl <T extends AlternativeCost2Impl<T>> extends Co
public AlternativeCost2Impl copy() {
return new AlternativeCost2Impl(this);
}
@Override
public Cost getCost() {
if (this.iterator().hasNext()) {
return this.iterator().next();
}
return null;
}
}

View file

@ -34,7 +34,7 @@ import mage.abilities.Ability;
import mage.abilities.SpellAbility;
import mage.abilities.StaticAbility;
import mage.abilities.condition.Condition;
import mage.abilities.costs.mana.ManaCostsImpl;
import mage.abilities.costs.mana.ManaCost;
import mage.constants.Outcome;
import mage.constants.Zone;
import mage.game.Game;
@ -110,8 +110,8 @@ public class AlternativeCostSourceAbility extends StaticAbility<AlternativeCostS
alternateCost.activate();
for (Iterator it = ((Costs) alternateCost).iterator(); it.hasNext();) {
Cost cost = (Cost) it.next();
if (cost instanceof ManaCostsImpl) {
ability.getManaCostsToPay().add((ManaCostsImpl) cost.copy());
if (cost instanceof ManaCost) {
ability.getManaCostsToPay().add((ManaCost) cost.copy());
} else {
ability.getCosts().add(cost.copy());
}
@ -157,16 +157,16 @@ public class AlternativeCostSourceAbility extends StaticAbility<AlternativeCostS
}
int numberCosts = 0;
String remarkText = "";
for (AlternativeCost2 alternativeCost : alternateCosts) {
for (AlternativeCost2 alternativeCost : alternateCosts) {
if (numberCosts == 0) {
if (alternativeCost instanceof ManaCostsImpl) {
if (alternativeCost.getCost() instanceof ManaCost) {
sb.append("pay ");
}
sb.append(alternativeCost.getText(false));
remarkText = alternativeCost.getReminderText();
} else {
sb.append(" and ");
if (alternativeCost instanceof ManaCostsImpl) {
if (alternativeCost.getCost() instanceof ManaCost) {
sb.append("pay ");
}
sb.append(alternativeCost.getText(true));