mirror of
https://github.com/magefree/mage.git
synced 2025-12-20 02:30:08 -08:00
rework text generation for modes with costs and/or flavor words
This commit is contained in:
parent
cb7620860b
commit
ca1145c967
1 changed files with 15 additions and 18 deletions
|
|
@ -8,6 +8,7 @@ import mage.util.CardUtil;
|
|||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Optional;
|
||||
|
||||
/**
|
||||
* @author BetaSteward_at_googlemail.com
|
||||
|
|
@ -29,11 +30,21 @@ public class Effects extends ArrayList<Effect> {
|
|||
}
|
||||
|
||||
public String getTextStartingUpperCase(Mode mode) {
|
||||
String text = getText(mode);
|
||||
if (text.length() > 3) {
|
||||
return CardUtil.getTextWithFirstCharUpperCase(text);
|
||||
StringBuilder text = Optional
|
||||
.of(getText(mode))
|
||||
.map(s -> s.length() > 3 ? CardUtil.getTextWithFirstCharUpperCase(s) : s)
|
||||
.map(StringBuilder::new)
|
||||
.get();
|
||||
// cost
|
||||
if (mode.getCost() != null) {
|
||||
text.insert(0, " — ");
|
||||
text.insert(0, mode.getCost().getText());
|
||||
}
|
||||
return text;
|
||||
// flavor word
|
||||
if (mode.getFlavorWord() != null) {
|
||||
text.insert(0, CardUtil.italicizeWithEmDash(mode.getFlavorWord()));
|
||||
}
|
||||
return text.toString();
|
||||
}
|
||||
|
||||
public String getText(Mode mode) {
|
||||
|
|
@ -115,20 +126,6 @@ public class Effects extends ArrayList<Effect> {
|
|||
sbText.append('.');
|
||||
}
|
||||
|
||||
|
||||
if (mode.getCost() != null || mode.getFlavorWord() != null) {
|
||||
sbText.replace(0, 1, sbText.substring(0, 1).toUpperCase());
|
||||
}
|
||||
// cost
|
||||
if (mode.getCost() != null) {
|
||||
sbText.insert(0, " — ");
|
||||
sbText.insert(0, mode.getCost().getText());
|
||||
}
|
||||
// flavor word
|
||||
if (mode.getFlavorWord() != null) {
|
||||
sbText.insert(0, CardUtil.italicizeWithEmDash(mode.getFlavorWord()));
|
||||
}
|
||||
|
||||
return sbText.toString();
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue