CardFactoryUtil: make Modular into new format

add Modular Keyword class for better formating of Modular:Sunburst
This commit is contained in:
Hanmac
2016-11-04 09:14:37 +00:00
parent 9dfce775c2
commit 44b4d16ee3
4 changed files with 73 additions and 29 deletions

1
.gitattributes vendored
View File

@@ -591,6 +591,7 @@ forge-game/src/main/java/forge/game/keyword/KeywordWithCostAndType.java -text
forge-game/src/main/java/forge/game/keyword/KeywordWithType.java -text
forge-game/src/main/java/forge/game/keyword/KeywordsChange.java -text
forge-game/src/main/java/forge/game/keyword/Kicker.java -text svneol=unset#text/plain
forge-game/src/main/java/forge/game/keyword/Modular.java -text svneol=unset#text/plain
forge-game/src/main/java/forge/game/keyword/Protection.java -text
forge-game/src/main/java/forge/game/keyword/SimpleKeyword.java -text
forge-game/src/main/java/forge/game/keyword/UndefinedKeyword.java -text

View File

@@ -2058,6 +2058,10 @@ public class CardFactoryUtil {
else if (keyword.equals("Melee")) {
addTriggerAbility(keyword, card, null);
}
else if (keyword.startsWith("Modular")) {
addReplacementEffect(keyword, card, null);
addTriggerAbility(keyword, card, null);
}
else if (keyword.startsWith("Monstrosity")) {
addSpellAbility(keyword, card, null);
}
@@ -2877,6 +2881,27 @@ public class CardFactoryUtil {
card.setSVar("MeleePump", effect);
card.setSVar("MeleeX", "TriggeredPlayersDefenders$Amount");
final Trigger trigger = TriggerHandler.parseTrigger(trigStr.toString(), card, intrinsic);
final Trigger cardTrigger = card.addTrigger(trigger);
if (!intrinsic) {
kws.addTrigger(cardTrigger);
}
} else if (keyword.startsWith("Modular")) {
final String abStr = "AB$ PutCounter | Cost$ 0 | ValidTgts$ Artifact.Creature | " +
"TgtPrompt$ Select target artifact creature | CounterType$ P1P1 | CounterNum$ ModularX";
String trigStr = "Mode$ ChangesZone | ValidCard$ Card.Self | Origin$ Battlefield | Destination$ Graveyard" +
" | OptionalDecider$ TriggeredCardController | TriggerController$ TriggeredCardController" +
" | Secondary$ True | TriggerDescription$ When CARDNAME is put into a graveyard from the battlefield, " +
"you may put a +1/+1 counter on target artifact creature for each +1/+1 counter on CARDNAME";
final Trigger trigger = TriggerHandler.parseTrigger(trigStr, card, intrinsic);
SpellAbility ab = AbilityFactory.getAbility(abStr, card);
ab.setSVar("ModularX", "TriggeredCard$CardCounters.P1P1");
trigger.setOverridingAbility(ab);
final Trigger cardTrigger = card.addTrigger(trigger);
if (!intrinsic) {
kws.addTrigger(cardTrigger);
@@ -2896,7 +2921,7 @@ public class CardFactoryUtil {
final String dbString3 = "DB$ ChangeZone | Defined$ DelayTriggerRemembered | Origin$"
+ " Battlefield | Destination$ Exile";
final String dbString4 = "DB$ Cleanup | ClearImprinted$ True";
final Trigger parsedTrigger = TriggerHandler.parseTrigger(actualTrigger, card, true);
final Trigger parsedTrigger = TriggerHandler.parseTrigger(actualTrigger, card, intrinsic);
card.setSVar("MyriadAbility", abString);
card.setSVar("MyriadCopy", dbString1);
@@ -3173,6 +3198,28 @@ public class CardFactoryUtil {
if (!intrinsic) {
kws.addReplacement(cardre);
}
} else if (keyword.startsWith("Modular")) {
final String[] k = keyword.split(":");
final String m = k[1];
StringBuilder sb = new StringBuilder("etbCounter:P1P1:");
sb.append(m).append(":no Condition:");
sb.append("Modular ");
if (!StringUtils.isNumeric(m)) {
sb.append("- ");
}
sb.append(m);
sb.append(" (").append(Keyword.getInstance(keyword).getReminderText()).append(")");
if ("Sunburst".equals(m)) {
card.setSVar(m, "Count$Converge");
}
if (intrinsic) {
card.addIntrinsicKeyword(sb.toString());
} else {
kws.addReplacement(makeEtbCounter(sb.toString(), card, intrinsic));
}
} else if (keyword.equals("Unleash")) {
String effect = "DB$ PutCounter | Defined$ Self | CounterType$ P1P1 | CounterNum$ 1 | SpellDescription$ Unleash (" + Keyword.getInstance(keyword).getReminderText() + ")";
@@ -3966,33 +4013,6 @@ public class CardFactoryUtil {
addReplacementEffect(card.getKeywords().get(n), card, null);
} // Devour
if (hasKeyword(card, "Modular") != -1) {
final int n = hasKeyword(card, "Modular");
if (n != -1) {
final String parse = card.getKeywords().get(n).toString();
card.getKeywords().remove(parse);
final int m = Integer.parseInt(parse.substring(8));
card.addIntrinsicKeyword("etbCounter:P1P1:" + m + ":no Condition: " +
"Modular " + m + " (This enters the battlefield with " + m + " +1/+1 counters on it. When it's put into a graveyard, " +
"you may put its +1/+1 counters on target artifact creature.)");
final String abStr = "AB$ PutCounter | Cost$ 0 | References$ ModularX | ValidTgts$ Artifact.Creature | " +
"TgtPrompt$ Select target artifact creature | CounterType$ P1P1 | CounterNum$ ModularX";
card.setSVar("ModularTrig", abStr);
card.setSVar("ModularX", "TriggeredCard$CardCounters.P1P1");
String trigStr = "Mode$ ChangesZone | ValidCard$ Card.Self | Origin$ Battlefield | Destination$ Graveyard" +
" | OptionalDecider$ TriggeredCardController | TriggerController$ TriggeredCardController | Execute$ ModularTrig | " +
"Secondary$ True | TriggerDescription$ When CARDNAME is put into a graveyard from the battlefield, " +
"you may put a +1/+1 counter on target artifact creature for each +1/+1 counter on CARDNAME";
final Trigger myTrigger = TriggerHandler.parseTrigger(trigStr, card, true);
card.addTrigger(myTrigger);
}
} // Modular
/*
* WARNING: must keep this keyword processing before etbCounter keyword
* processing.

View File

@@ -81,7 +81,7 @@ public enum Keyword {
MENACE(SimpleKeyword.class, true, "This creature can't be blocked except by two or more creatures."),
MEGAMORPH(KeywordWithCost.class, true, "You may cast this card face down as a 2/2 creature for {3}. Turn it face up any time for its megamorph cost and put a +1/+1 counter on it."),
MONSTROSITY(KeywordWithCostAndAmount.class, false, "If this creature isn't monstrous, put {%2$d:+1/+1 counter} on it and it becomes monstrous."),
MODULAR(KeywordWithAmount.class, false, "This creature enters the battlefield with %d +1/+1 counters on it. When it dies, you may put its +1/+1 counters on target artifact creature."),
MODULAR(Modular.class, false, "This creature enters the battlefield with {%d:+1/+1 counter} on it. When it dies, you may put its +1/+1 counters on target artifact creature."),
MORPH(KeywordWithCost.class, true, "You may cast this card face down as a 2/2 creature for {3}. Turn it face up any time for its morph cost."),
MULTIKICKER(KeywordWithCost.class, false, "You may pay an additional %s any number of times as you cast this spell."),
MYRIAD(SimpleKeyword.class, false, "Whenever this creature attacks, for each opponent other than defending player, you may create a token that's a copy of this creature that's tapped and attacking that player or a planeswalker he or she controls. If one or more tokens are created this way, exile the tokens at end of combat."),

View File

@@ -0,0 +1,23 @@
package forge.game.keyword;
public class Modular extends KeywordWithAmount {
private boolean sunburst = false;
@Override
protected void parse(String details) {
if ("Sunburst".equals(details)) {
sunburst = true;
} else {
super.parse(details);
}
}
@Override
protected String formatReminderText(String reminderText) {
if (sunburst) {
return "This enters the battlefield with a +1/+1 counter on it for each color of mana spent to cast it. When it dies, you may put its +1/+1 counters on target artifact creature.";
} else {
return super.formatReminderText(reminderText);
}
}
}