mirror of
https://github.com/magefree/mage.git
synced 2025-12-20 10:40:06 -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.ArrayList;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
|
import java.util.Optional;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author BetaSteward_at_googlemail.com
|
* @author BetaSteward_at_googlemail.com
|
||||||
|
|
@ -29,11 +30,21 @@ public class Effects extends ArrayList<Effect> {
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getTextStartingUpperCase(Mode mode) {
|
public String getTextStartingUpperCase(Mode mode) {
|
||||||
String text = getText(mode);
|
StringBuilder text = Optional
|
||||||
if (text.length() > 3) {
|
.of(getText(mode))
|
||||||
return CardUtil.getTextWithFirstCharUpperCase(text);
|
.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) {
|
public String getText(Mode mode) {
|
||||||
|
|
@ -115,20 +126,6 @@ public class Effects extends ArrayList<Effect> {
|
||||||
sbText.append('.');
|
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();
|
return sbText.toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue