* UI: choose spell to cast dialog - added card name for spell abilities (split, adventure, additional spell, etc, see #6549);

This commit is contained in:
Oleg Agafonov 2020-05-18 06:46:39 +04:00
parent dcd6cf34f3
commit 0c2e08f54e
2 changed files with 106 additions and 3 deletions

View file

@ -1,6 +1,7 @@
package mage.view;
import mage.abilities.Ability;
import mage.abilities.SpellAbility;
import java.io.Serializable;
import java.util.LinkedHashMap;
@ -28,15 +29,30 @@ public class AbilityPickerView implements Serializable {
if (objectName == null) {
rule = ability.getRule(true);
} else {
rule = ability.getRule(objectName);
if (rule.isEmpty()) {
rule = ability.toString();
// spell abilities must start with "Cast name" (split cards have different names for each spell part)
if (ability instanceof SpellAbility) {
SpellAbility spell = (SpellAbility) ability;
rule = getAbilityRules(spell, spell.getCardName());
if (!rule.startsWith("Cast ")) {
rule = spell.toString() + ": " + rule; // spell.toString() must return this.name (example: Cast Armed)
}
} else {
rule = getAbilityRules(ability, objectName);
}
}
choices.put(ability.getId(), num + ". " + rule);
}
}
private String getAbilityRules(Ability ability, String objectName) {
String rule = ability.getRule(objectName);
if (rule.isEmpty()) {
rule = ability.toString();
}
rule = Character.toUpperCase(rule.charAt(0)) + rule.substring(1);
return rule;
}
public AbilityPickerView(Map<UUID, String> modes, String message) {
this.choices = modes;
this.message = message;