CardFactoryUtil & GameActionUtil: make "Alternative Cost" a better keyword to create SpellAbilities

that does make it work better with MayPlay
This commit is contained in:
Hanmac
2016-08-03 09:16:24 +00:00
parent ab37dd35c0
commit cd41977b42
3 changed files with 22 additions and 15 deletions

View File

@@ -231,19 +231,6 @@ public final class GameActionUtil {
}
alternatives.add(flashback);
}
if (sa.isSpell() && keyword.startsWith("Alternative Cost")) {
final SpellAbility newSA = sa.copy();
newSA.setBasicSpell(false);
String kw = keyword;
if (keyword.contains("ConvertedManaCost")) {
final String cmc = Integer.toString(sa.getHostCard().getCMC());
kw = keyword.replace("ConvertedManaCost", cmc);
}
final Cost cost = new Cost(kw.substring(17), false).add(newSA.getPayCosts().copyWithNoMana());
newSA.setPayCosts(cost);
newSA.setDescription(sa.getDescription() + " (by paying " + cost.toSimpleString() + " instead of its mana cost)");
alternatives.add(newSA);
}
if (sa.isSpell() && keyword.equals("You may cast CARDNAME as though it had flash if you pay 2 more to cast it.")) {
final SpellAbility newSA = sa.copy();
newSA.setBasicSpell(false);

View File

@@ -1667,7 +1667,7 @@ public class Card extends GameEntity implements Comparable<Card> {
for (final SpellAbility sa : state.getSpellAbilities()) {
// only add abilities not Spell portions of cards
if (sa == null || !state.getType().isPermanent()) {
if (sa == null || sa.isSecondary() || !state.getType().isPermanent()) {
continue;
}

View File

@@ -3173,7 +3173,27 @@ public class CardFactoryUtil {
public static void addSpellAbility(final String keyword, final Card card, final KeywordsChange kws) {
final boolean intrinsic = kws == null;
if (keyword.startsWith("Bestow")) {
if (keyword.startsWith("Alternative Cost")) {
final String[] kw = keyword.split(":");
String costStr = kw[1];
final SpellAbility sa = card.getFirstSpellAbility();
final SpellAbility newSA = sa.copy();
newSA.setBasicSpell(false);
if (costStr.equals("ConvertedManaCost")) {
costStr = Integer.toString(card.getCMC());
}
final Cost cost = new Cost(costStr, false).add(sa.getPayCosts().copyWithNoMana());
newSA.getMapParams().put("Secondary", "True");
newSA.setPayCosts(cost);
newSA.setDescription(sa.getDescription() + " (by paying " + cost.toSimpleString() + " instead of its mana cost)");
if (!intrinsic) {
newSA.setTemporary(true);
newSA.setIntrinsic(false);
kws.addSpellAbility(newSA);
}
card.addSpellAbility(newSA);
} else if (keyword.startsWith("Bestow")) {
final String[] params = keyword.split(":");
final String cost = params[1];