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

View File

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

View File

@@ -37,8 +37,8 @@ public class CostPayLife extends CostPart {
* @param amount * @param amount
* the amount * the amount
*/ */
public CostPayLife(final String amount) { public CostPayLife(final String amount, final String description) {
this.setAmount(amount); super(amount, "card", description);
} }
@Override @Override
@@ -52,7 +52,13 @@ public class CostPayLife extends CostPart {
@Override @Override
public final String toString() { public final String toString() {
final StringBuilder sb = new StringBuilder(); 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(); return sb.toString();
} }

View File

@@ -0,0 +1,7 @@
Name:Belt of Giant Strength
ManaCost:1 G
Types:Artifact Equipment
S:Mode$ Continuous | Affected$ Creature.EquippedBy | SetPower$ 10 | SetToughness$ 10 | Description$ Equipped creature has base power and toughness 10/10.
K:Equip:10:::ReduceCost$ X:This ability costs {X} less to activate where X is the power of the creature it targets.
SVar:X:Targeted$CardPower
Oracle:Equipped creature has base power and toughness 10/10.\nEquip {10}. This ability costs {X} less to activate where X is the power of the creature it targets.

View File

@@ -3,9 +3,9 @@ ManaCost:3
Types:Legendary Artifact Equipment Types:Legendary Artifact Equipment
T:Mode$Phase | Phase$ BeginCombat | ValidPlayer$ You | Execute$ TrigChoose | TriggerZones$ Battlefield | TriggerDescription$ At the beginning of combat on your turn, equipped creature or a creature you control named Vecna gets +X/+X until end of turn, where X is the number of cards in your hand. T:Mode$Phase | Phase$ BeginCombat | ValidPlayer$ You | Execute$ TrigChoose | TriggerZones$ Battlefield | TriggerDescription$ At the beginning of combat on your turn, equipped creature or a creature you control named Vecna gets +X/+X until end of turn, where X is the number of cards in your hand.
SVar:TrigChoose:DB$ ChooseCard | Choices$ Creature.EquippedBy,Creature.YouCtrl+namedVecna | SubAbility$ DBPump SVar:TrigChoose:DB$ ChooseCard | Choices$ Creature.EquippedBy,Creature.YouCtrl+namedVecna | SubAbility$ DBPump
SVar:DBPump:DB$ Pump | Defined$ ChosenCard | NumAtt$ +X | NumDef$ +X | SubAbility$ DBCleanup SVar:DBPump:DB$ Pump | Defined$ ChosenCard | NumAtt$ +X | NumDef$ +X | Mandatory$ True | SubAbility$ DBCleanup
SVar:DBCleanup:DB$ Cleanup | ClearChosenCard$ True SVar:DBCleanup:DB$ Cleanup | ClearChosenCard$ True
K:Equip:PayLife<X> K:Equip:PayLife<X/1 life for each card in your hand>
K:Equip:2 K:Equip:2
SVar:X:Count$CardsInYourHand SVar:X:Count$CardsInYourHand
DeckHints:Name$Eye of Vecna|The Book of Vile Darkness DeckHints:Name$Eye of Vecna|The Book of Vile Darkness

View File

@@ -0,0 +1,6 @@
Name:Leather Armor
ManaCost:1
Types:Artifact Equipment
S:Mode$ Continuous | Affected$ Creature.EquippedBy | AddToughness$ 1 | AddKeyword$ Ward:1 | Description$ Equipped creature gets +0/+1 and has ward {1}. (Whenever equipped creature becomes the target of a spell or ability an opponent controls, counter it unless that player pays {1}.)
K:Equip:0:::ActivationLimit$ 1:Activate only once each turn
Oracle:Equipped creature gets +0/+1 and has ward {1}. (Whenever equipped creature becomes the target of a spell or ability an opponent controls, counter it unless that player pays {1}.)\nEquip {0}. Activate only once each turn.

View File

@@ -0,0 +1,7 @@
Name:Plate Armor
ManaCost:2 W
Types:Artifact Equipment
S:Mode$ Continuous | Affected$ Creature.EquippedBy | AddPower$ 3 | AddToughness$ 3 | AddKeyword$ Ward:1 | Description$ Equipped creature gets +3/+3 and has ward {1}. (Whenever equipped creature becomes the target of a spell or ability an opponent controls, counter it unless that player pays {1}.)
K:Equip:3:::ReduceCost$ Y:This ability costs {1} less to activate for each other Equipment you control
SVar:Y:Count$Valid Equipment.YouCtrl+Other
Oracle:Equipped creature gets +3/+3 and has ward {1}. (Whenever equipped creature becomes the target of a spell or ability an opponent controls, counter it unless that player pays {1}.)\nEquip {3}. This ability costs {1} less to activate for each other Equipment you control.