mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-18 03:38:01 +00:00
Card & CharmEffect: have the Effect generate the description with the bullets from the choices.
This commit is contained in:
@@ -81,6 +81,34 @@ public class CharmEffect extends SpellAbilityEffect {
|
|||||||
return sb.toString();
|
return sb.toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static String makeFormatedDescription(SpellAbility sa) {
|
||||||
|
int num = Integer.parseInt(sa.getParamOrDefault("CharmNum", "1"));
|
||||||
|
int min = Integer.parseInt(sa.getParamOrDefault("MinCharmNum", String.valueOf(num)));
|
||||||
|
boolean repeat = sa.hasParam("CanRepeatModes");
|
||||||
|
|
||||||
|
List<AbilitySub> list = CharmEffect.makePossibleOptions(sa);
|
||||||
|
|
||||||
|
StringBuilder sb = new StringBuilder("Choose ");
|
||||||
|
if (num == min) {
|
||||||
|
sb.append(Lang.getNumeral(num));
|
||||||
|
} else {
|
||||||
|
sb.append(Lang.getNumeral(min)).append(" or ").append(list.size() == 2 ? "both" : "more");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (repeat) {
|
||||||
|
sb.append(". You may choose the same mode more than once.");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!list.isEmpty()) {
|
||||||
|
sb.append(" \u2014\r\n");
|
||||||
|
for (AbilitySub sub : list) {
|
||||||
|
sb.append("\u2022 ").append(sub.getParam("SpellDescription"));
|
||||||
|
sb.append("\r\n");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return sb.toString();
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void resolve(SpellAbility sa) {
|
public void resolve(SpellAbility sa) {
|
||||||
// all chosen modes have been chained as subabilities to this sa.
|
// all chosen modes have been chained as subabilities to this sa.
|
||||||
|
|||||||
@@ -32,6 +32,7 @@ import forge.game.*;
|
|||||||
import forge.game.ability.AbilityFactory;
|
import forge.game.ability.AbilityFactory;
|
||||||
import forge.game.ability.AbilityUtils;
|
import forge.game.ability.AbilityUtils;
|
||||||
import forge.game.ability.ApiType;
|
import forge.game.ability.ApiType;
|
||||||
|
import forge.game.ability.effects.CharmEffect;
|
||||||
import forge.game.card.CardPredicates.Presets;
|
import forge.game.card.CardPredicates.Presets;
|
||||||
import forge.game.combat.AttackingBand;
|
import forge.game.combat.AttackingBand;
|
||||||
import forge.game.combat.Combat;
|
import forge.game.combat.Combat;
|
||||||
@@ -1901,30 +1902,7 @@ public class Card extends GameEntity implements Comparable<Card> {
|
|||||||
|
|
||||||
//Determine if a card has multiple choices, then format it in an easier to read list.
|
//Determine if a card has multiple choices, then format it in an easier to read list.
|
||||||
if (ApiType.Charm.equals(sa.getApi())) {
|
if (ApiType.Charm.equals(sa.getApi())) {
|
||||||
// Only split once! Otherwise some Charm spells looks broken
|
sb.append(CharmEffect.makeFormatedDescription(sa));
|
||||||
final String[] splitElemText = elementText.split("-", 2);
|
|
||||||
final String chooseText = splitElemText[0].trim();
|
|
||||||
final String[] choices = splitElemText.length > 1 ? splitElemText[1].split(";") : null;
|
|
||||||
|
|
||||||
sb.append(chooseText);
|
|
||||||
|
|
||||||
if (choices != null) {
|
|
||||||
sb.append(" \u2014\r\n");
|
|
||||||
for (int i = 0; i < choices.length; i++) {
|
|
||||||
String choice = choices[i].trim();
|
|
||||||
|
|
||||||
if (choice.startsWith("Or ") || choice.startsWith("or ")) {
|
|
||||||
choice = choice.substring(3);
|
|
||||||
}
|
|
||||||
|
|
||||||
sb.append("\u2022 ").append(Character.toUpperCase(choice.charAt(0)))
|
|
||||||
.append(choice.substring(1));
|
|
||||||
if (i < choices.length - 1) {
|
|
||||||
sb.append(".");
|
|
||||||
}
|
|
||||||
sb.append("\r\n");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
sb.append(elementText).append("\r\n");
|
sb.append(elementText).append("\r\n");
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user