mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-17 11:18:01 +00:00
AbilityFactory & CharmEffect: do create the SpellDescription from its Choices
This commit is contained in:
@@ -18,6 +18,7 @@
|
||||
package forge.game.ability;
|
||||
|
||||
import forge.card.CardStateName;
|
||||
import forge.game.ability.effects.CharmEffect;
|
||||
import forge.game.card.Card;
|
||||
import forge.game.cost.Cost;
|
||||
import forge.game.spellability.*;
|
||||
@@ -202,6 +203,8 @@ public final class AbilityFactory {
|
||||
sb.append(mapParams.get("SpellDescription"));
|
||||
|
||||
spellAbility.setDescription(sb.toString());
|
||||
} else if (api == ApiType.Charm) {
|
||||
spellAbility.setDescription(CharmEffect.makeSpellDescription(spellAbility));
|
||||
} else {
|
||||
spellAbility.setDescription("");
|
||||
}
|
||||
|
||||
@@ -7,6 +7,7 @@ import forge.game.card.Card;
|
||||
import forge.game.player.Player;
|
||||
import forge.game.spellability.AbilitySub;
|
||||
import forge.game.spellability.SpellAbility;
|
||||
import forge.util.Lang;
|
||||
import forge.util.collect.FCollection;
|
||||
|
||||
import java.util.ArrayList;
|
||||
@@ -50,6 +51,36 @@ public class CharmEffect extends SpellAbilityEffect {
|
||||
return choices;
|
||||
}
|
||||
|
||||
public static String makeSpellDescription(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.");
|
||||
}
|
||||
sb.append(" - ");
|
||||
int i = 0;
|
||||
for (AbilitySub sub : list) {
|
||||
if (i > 0) {
|
||||
sb.append("; ");
|
||||
}
|
||||
sb.append(sub.getParam("SpellDescription"));
|
||||
++i;
|
||||
}
|
||||
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void resolve(SpellAbility sa) {
|
||||
// all chosen modes have been chained as subabilities to this sa.
|
||||
|
||||
Reference in New Issue
Block a user