Merge branch 'equipExtras' into 'master'

CardFactoryUtil: add way to add Extra Parameters and Extra Description

See merge request core-developers/forge!4980
This commit is contained in:
Michael Kamensky
2021-07-11 04:01:28 +00:00
7 changed files with 48 additions and 12 deletions

View File

@@ -2627,8 +2627,10 @@ public class CardFactoryUtil {
String[] k = keyword.split(":");
// Get cost string
String equipCost = k[1];
String valid = k.length > 2 ? k[2] : "Creature.YouCtrl";
String vstr = k.length > 3 ? k[3] : "creature";
String valid = k.length > 2 && !k[2].isEmpty() ? k[2] : "Creature.YouCtrl";
String vstr = k.length > 3 && !k[3].isEmpty() ? k[3] : "creature";
String extra = k.length > 4 ? k[4] : "";
String extraDesc = k.length > 5 ? k[5] : "";
// Create attach ability string
final StringBuilder abilityStr = new StringBuilder();
abilityStr.append("AB$ Attach | Cost$ ");
@@ -2641,7 +2643,7 @@ public class CardFactoryUtil {
abilityStr.append("| ").append(card.getSVar("AttachAi"));
}
abilityStr.append("| PrecostDesc$ Equip");
if (k.length > 3) {
if (k.length > 3 && !k[3].isEmpty()) {
abilityStr.append(" ").append(vstr);
}
Cost cost = new Cost(equipCost, true);
@@ -2651,7 +2653,14 @@ public class CardFactoryUtil {
abilityStr.append(" ");
}
abilityStr.append("| CostDesc$ ").append(cost.toSimpleString()).append(" ");
abilityStr.append("| SpellDescription$ (").append(inst.getReminderText()).append(")");
abilityStr.append("| SpellDescription$ ");
if (!extraDesc.isEmpty()) {
abilityStr.append(". ").append(extraDesc).append(". ");
}
abilityStr.append("(").append(inst.getReminderText()).append(")");
if (!extra.isEmpty()) {
abilityStr.append("| ").append(extra);
}
// instantiate attach ability
final SpellAbility newSA = AbilityFactory.getAbility(abilityStr.toString(), card);
newSA.setIntrinsic(intrinsic);

View File

@@ -309,8 +309,9 @@ public class Cost implements Serializable {
// Changes Cost by adding a Life Payment
if (parse.startsWith("PayLife<")) {
// PayLife<LifeCost>
final String[] splitStr = abCostParse(parse, 1);
return new CostPayLife(splitStr[0]);
final String[] splitStr = abCostParse(parse, 2);
final String description = splitStr.length > 1 ? splitStr[1] : null;
return new CostPayLife(splitStr[0], description);
}
if (parse.startsWith("PayEnergy<")) {
@@ -908,7 +909,7 @@ public class Cost implements Serializable {
} else if (part instanceof CostAddMana) {
costParts.add(new CostAddMana(amount, part.getType(), part.getTypeDescription()));
} else if (part instanceof CostPayLife) {
costParts.add(new CostPayLife(amount));
costParts.add(new CostPayLife(amount, part.getTypeDescription()));
}
toRemove.add(other);
alreadyAdded = true;

View File

@@ -37,8 +37,8 @@ public class CostPayLife extends CostPart {
* @param amount
* the amount
*/
public CostPayLife(final String amount) {
this.setAmount(amount);
public CostPayLife(final String amount, final String description) {
super(amount, "card", description);
}
@Override
@@ -52,7 +52,13 @@ public class CostPayLife extends CostPart {
@Override
public final String toString() {
final StringBuilder sb = new StringBuilder();
sb.append("Pay ").append(this.getAmount()).append(" Life");
sb.append("Pay ");
String desc = this.getTypeDescription();
if (desc != null) {
sb.append(desc);
} else {
sb.append(this.getAmount()).append(" Life");
}
return sb.toString();
}