convert cardcast white cards into pyx format
capitalize the first letter and add a period if there's no punctuation at the end of the card
This commit is contained in:
parent
1d98a78f8c
commit
5b43fd1dd0
|
@ -99,6 +99,16 @@ public class CardcastService {
|
|||
return soft.get();
|
||||
}
|
||||
|
||||
private static String sanitizeWhite(final String input) {
|
||||
final StringBuilder sb = new StringBuilder();
|
||||
sb.append(input.substring(0, 1).toUpperCase());
|
||||
sb.append(input.substring(1));
|
||||
if (Character.isLetterOrDigit(input.charAt(input.length() - 1))) {
|
||||
sb.append('.');
|
||||
}
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
public CardcastDeck loadSet(final String setId) {
|
||||
if (!validIdPattern.matcher(setId).matches()) {
|
||||
return null;
|
||||
|
@ -170,7 +180,20 @@ public class CardcastService {
|
|||
// The white cards should only ever have one element in text, but let's be safe.
|
||||
final List<String> strs = new ArrayList<String>(texts.size());
|
||||
for (final Object o : texts) {
|
||||
strs.add((String) o);
|
||||
final String cardCastString = (String) o;
|
||||
final StringBuilder pyxString = new StringBuilder();
|
||||
|
||||
// Cardcast's recommended format is to not capitalize the first letter
|
||||
pyxString.append(cardCastString.substring(0, 1).toUpperCase());
|
||||
pyxString.append(cardCastString.substring(1));
|
||||
|
||||
// Cardcast's recommended format is to not include a period
|
||||
if (Character.isLetterOrDigit(cardCastString.charAt(cardCastString.length() - 1))) {
|
||||
pyxString.append('.');
|
||||
}
|
||||
|
||||
// Cardcast's white cards are now formatted consistently with pyx cards
|
||||
strs.add(pyxString.toString());
|
||||
}
|
||||
final String text = StringUtils.join(strs, "");
|
||||
final CardcastWhiteCard card = new CardcastWhiteCard(cardIdProvider.get(), text, setId);
|
||||
|
|
Loading…
Reference in New Issue