Merge pull request #158 from Northmoc/sncDuskMangler

SNC: Dusk Mangler and support
This commit is contained in:
Anthony Calosa
2022-04-28 23:57:58 +08:00
committed by GitHub
4 changed files with 44 additions and 37 deletions

View File

@@ -487,27 +487,17 @@ public final class GameActionUtil {
final String keyword = inst.getOriginal(); final String keyword = inst.getOriginal();
if (keyword.startsWith("AlternateAdditionalCost")) { if (keyword.startsWith("AlternateAdditionalCost")) {
final List<SpellAbility> newAbilities = Lists.newArrayList(); final List<SpellAbility> newAbilities = Lists.newArrayList();
String[] costs = TextUtil.split(keyword, ':');
for (String s : keyword.split(":", 2)[1].split(":")) {
final SpellAbility newSA = sa.copy(); final SpellAbility newSA = sa.copy();
newSA.setBasicSpell(false); newSA.setBasicSpell(false);
final Cost cost1 = new Cost(costs[1], false); final Cost cost = new Cost(s, false);
newSA.setDescription(sa.getDescription() + " (Additional cost " + cost1.toSimpleString() + ")"); newSA.setDescription(sa.getDescription() + " (Additional cost: " + cost.toSimpleString() + ")");
newSA.setPayCosts(cost1.add(sa.getPayCosts())); newSA.setPayCosts(cost.add(sa.getPayCosts()));
if (newSA.canPlay()) { if (newSA.canPlay()) {
newAbilities.add(newSA); newAbilities.add(newSA);
} }
//second option
final SpellAbility newSA2 = sa.copy();
newSA2.setBasicSpell(false);
final Cost cost2 = new Cost(costs[2], false);
newSA2.setDescription(sa.getDescription() + " (Additional cost " + cost2.toSimpleString() + ")");
newSA2.setPayCosts(cost2.add(sa.getPayCosts()));
if (newSA2.canPlay()) {
newAbilities.add(newSA2);
} }
abilities.clear(); abilities.clear();

View File

@@ -2011,15 +2011,17 @@ public class Card extends GameEntity implements Comparable<Card>, IHasSVars {
} else if (keyword.startsWith("Alternative Cost")) { } else if (keyword.startsWith("Alternative Cost")) {
sbLong.append("Has alternative cost."); sbLong.append("Has alternative cost.");
} else if (keyword.startsWith("AlternateAdditionalCost")) { } else if (keyword.startsWith("AlternateAdditionalCost")) {
final String costString1 = keyword.split(":")[1]; final String[] costs = keyword.split(":", 2)[1].split(":");
final String costString2 = keyword.split(":")[2]; sbLong.append("As an additional cost to cast this spell, ");
final Cost cost1 = new Cost(costString1, false); for (int n = 0; n < costs.length; n++) {
final Cost cost2 = new Cost(costString2, false); final Cost cost = new Cost(costs[n], false);
sbLong.append("As an additional cost to cast this spell, ") if (cost.isOnlyManaCost()) {
.append(StringUtils.uncapitalize(cost1.toSimpleString())) sbLong.append(" pay ");
.append(" or pay ") }
.append(StringUtils.uncapitalize(cost2.toSimpleString())) sbLong.append(StringUtils.uncapitalize(cost.toSimpleString()));
.append(".\r\n\r\n"); sbLong.append(n + 1 == costs.length ? ".\r\n\r\n" : n + 2 == costs.length && costs.length > 2
? ", or " : n + 2 == costs.length ? " or " : ", ");
}
} else if (keyword.startsWith("Multikicker")) { } else if (keyword.startsWith("Multikicker")) {
if (!keyword.endsWith("Generic")) { if (!keyword.endsWith("Generic")) {
final String[] n = keyword.split(":"); final String[] n = keyword.split(":");
@@ -2632,14 +2634,17 @@ public class Card extends GameEntity implements Comparable<Card>, IHasSVars {
} }
sbBefore.append(sbx).append("\r\n"); sbBefore.append(sbx).append("\r\n");
} else if (keyword.startsWith("AlternateAdditionalCost")) { } else if (keyword.startsWith("AlternateAdditionalCost")) {
final String[] k = keyword.split(":"); final String[] costs = keyword.split(":", 2)[1].split(":");
final Cost cost1 = new Cost(k[1], false); sbBefore.append("As an additional cost to cast this spell, ");
final Cost cost2 = new Cost(k[2], false); for (int n = 0; n < costs.length; n++) {
sbBefore.append("As an additional cost to cast this spell, ") final Cost cost = new Cost(costs[n], false);
.append(StringUtils.uncapitalize(cost1.toSimpleString())) if (cost.isOnlyManaCost()) {
.append(" or pay ") sbBefore.append(" pay ");
.append(StringUtils.uncapitalize(cost2.toSimpleString())) }
.append(".\r\n\r\n"); sbBefore.append(StringUtils.uncapitalize(cost.toSimpleString()));
sbBefore.append(n + 1 == costs.length ? ".\r\n\r\n" : n + 2 == costs.length && costs.length > 2
? ", or " : n + 2 == costs.length ? " or " : ", ");
}
} else if (keyword.startsWith("Presence") || keyword.startsWith("MayFlash")) { } else if (keyword.startsWith("Presence") || keyword.startsWith("MayFlash")) {
// Pseudo keywords, only print Reminder // Pseudo keywords, only print Reminder
sbBefore.append(inst.getReminderText()); sbBefore.append(inst.getReminderText());

View File

@@ -155,7 +155,7 @@ public class Cost implements Serializable {
* @return a boolean. * @return a boolean.
*/ */
public final boolean isOnlyManaCost() { public final boolean isOnlyManaCost() {
// Only used by Morph and Equip... why do we need this? // used by Morph, Equip and some string builders
for (final CostPart part : this.costParts) { for (final CostPart part : this.costParts) {
if (!(part instanceof CostPartMana)) { if (!(part instanceof CostPartMana)) {
return false; return false;

View File

@@ -0,0 +1,12 @@
Name:Dusk Mangler
ManaCost:5 B B
Types:Creature Horror
PT:5/4
K:AlternateAdditionalCost:Sac<1/Creature>:Discard<1/Card>:PayLife<4>
T:Mode$ ChangesZone | Origin$ Any | Destination$ Battlefield | ValidCard$ Card.Self | Execute$ TrigSac | TriggerDescription$ When CARDNAME enters the battlefield, each opponent sacrifices a creature, discards a card, and loses 4 life.
SVar:TrigSac:DB$ Sacrifice | Defined$ Opponent | SacValid$ Creature | SubAbility$ DBDiscard
SVar:DBDiscard:DB$ Discard | Mode$ TgtChoose | Defined$ Opponent | SubAbility$ DBLoseLife
SVar:DBLoseLife:DB$ LoseLife | Defined$ Opponent | LifeAmount$ 4
DeckHas:Ability$Sacrifice|Discard
SVar:AIPreference:SacCost$Creature.token,Creature.cmcLE3
Oracle:As an additional cost to cast this spell, sacrifice a creature, discard a card, or pay 4 life.\nWhen Dusk Mangler enters the battlefield, each opponent sacrifices a creature, discards a card, and loses 4 life.