mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-15 18:28:00 +00:00
Failsafe in case Android decides to explode due to complicated regex syntax again.
This commit is contained in:
@@ -6,6 +6,7 @@ import org.apache.commons.lang3.StringUtils;
|
|||||||
|
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
import java.util.Map.Entry;
|
import java.util.Map.Entry;
|
||||||
|
import java.util.regex.PatternSyntaxException;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
//
|
//
|
||||||
@@ -188,11 +189,18 @@ final class CardFace implements ICardFace, Cloneable {
|
|||||||
void assignMissingFieldsToVariant(CardFace variant) {
|
void assignMissingFieldsToVariant(CardFace variant) {
|
||||||
if(variant.oracleText == null) {
|
if(variant.oracleText == null) {
|
||||||
if(variant.flavorName != null && this.oracleText != null) {
|
if(variant.flavorName != null && this.oracleText != null) {
|
||||||
Lang lang = Lang.getInstance();
|
try {
|
||||||
//Rudimentary name replacement. Can't do pronouns, ability words, or flavored keywords. Need to define variant text manually for that.
|
Lang lang = Lang.getInstance();
|
||||||
String flavoredText = this.oracleText.replaceAll("(?<=\\b|\\\\n)" + this.name + "\\b", variant.flavorName);
|
//Rudimentary name replacement. Can't do pronouns, ability words, or flavored keywords. Need to define variant text manually for that.
|
||||||
flavoredText = flavoredText.replaceAll("(?<=\\b|\\\\n)" + lang.getNickName(this.name) + "\\b", lang.getNickName(variant.flavorName));
|
//Regex here checks for the name following either a word boundary or a literal "\n" string, since those haven't yet been converted to line breaks.
|
||||||
variant.oracleText = flavoredText;
|
String flavoredText = this.oracleText.replaceAll("(?<=\\b|\\\\n)" + this.name + "\\b", variant.flavorName);
|
||||||
|
flavoredText = flavoredText.replaceAll("(?<=\\b|\\\\n)" + lang.getNickName(this.name) + "\\b", lang.getNickName(variant.flavorName));
|
||||||
|
variant.oracleText = flavoredText;
|
||||||
|
}
|
||||||
|
catch (PatternSyntaxException ignored) {
|
||||||
|
// Old versions of Android are weird about patterns sometimes. I don't *think* this is such a case but
|
||||||
|
// the documentation is unreliable. May be worth removing this once we're sure it's not a problem.
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
variant.oracleText = this.oracleText;
|
variant.oracleText = this.oracleText;
|
||||||
|
|||||||
Reference in New Issue
Block a user