mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-19 04:08:01 +00:00
added 2 overloads to splitWithParethesis assuming parentheses by default.
updated many callers, since they no longer need to specify round brackets explicitly
This commit is contained in:
@@ -76,7 +76,7 @@ public class BoosterGenerator {
|
|||||||
String slotType = slot.getLeft(); // add expansion symbol here?
|
String slotType = slot.getLeft(); // add expansion symbol here?
|
||||||
int numCards = slot.getRight().intValue();
|
int numCards = slot.getRight().intValue();
|
||||||
|
|
||||||
String[] sType = TextUtil.splitWithParenthesis(slotType, ' ', '(', ')');
|
String[] sType = TextUtil.splitWithParenthesis(slotType, ' ');
|
||||||
String setCode = sType.length == 1 && booster.getEdition() != null ? booster.getEdition() : null;
|
String setCode = sType.length == 1 && booster.getEdition() != null ? booster.getEdition() : null;
|
||||||
String sheetKey = Singletons.getModel().getEditions().contains(setCode) ? slotType.trim() + " " + setCode: slotType.trim();
|
String sheetKey = Singletons.getModel().getEditions().contains(setCode) ? slotType.trim() + " " + setCode: slotType.trim();
|
||||||
|
|
||||||
@@ -89,10 +89,10 @@ public class BoosterGenerator {
|
|||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
public static final PrintSheet makeSheet(String sheetKey, Iterable<CardPrinted> src) {
|
public static final PrintSheet makeSheet(String sheetKey, Iterable<CardPrinted> src) {
|
||||||
PrintSheet ps = new PrintSheet(sheetKey);
|
PrintSheet ps = new PrintSheet(sheetKey);
|
||||||
String[] sKey = TextUtil.splitWithParenthesis(sheetKey, ' ', '(', ')', 2);
|
String[] sKey = TextUtil.splitWithParenthesis(sheetKey, ' ', 2);
|
||||||
Predicate<CardPrinted> setPred = (Predicate<CardPrinted>) (sKey.length > 1 ? IPaperCard.Predicates.printedInSets(sKey[1].split(" ")) : Predicates.alwaysTrue());
|
Predicate<CardPrinted> setPred = (Predicate<CardPrinted>) (sKey.length > 1 ? IPaperCard.Predicates.printedInSets(sKey[1].split(" ")) : Predicates.alwaysTrue());
|
||||||
|
|
||||||
List<String> operators = new LinkedList<String>(Arrays.asList(TextUtil.splitWithParenthesis(sKey[0], ':', '(', ')')));
|
List<String> operators = new LinkedList<String>(Arrays.asList(TextUtil.splitWithParenthesis(sKey[0], ':')));
|
||||||
Predicate<CardPrinted> extraPred = buildExtraPredicate(operators);
|
Predicate<CardPrinted> extraPred = buildExtraPredicate(operators);
|
||||||
|
|
||||||
// source replacement operators - if one is applied setPredicate will be ignored
|
// source replacement operators - if one is applied setPredicate will be ignored
|
||||||
|
|||||||
@@ -67,12 +67,12 @@ public class BoosterTemplate extends SealedProductTemplate {
|
|||||||
protected BoosterTemplate read(String line, int i) {
|
protected BoosterTemplate read(String line, int i) {
|
||||||
String[] headAndData = TextUtil.split(line, ':', 2);
|
String[] headAndData = TextUtil.split(line, ':', 2);
|
||||||
final String edition = headAndData[0];
|
final String edition = headAndData[0];
|
||||||
final String[] data = TextUtil.splitWithParenthesis(headAndData[1], ',', '(', ')');
|
final String[] data = TextUtil.splitWithParenthesis(headAndData[1], ',');
|
||||||
int nCovers = 1;
|
int nCovers = 1;
|
||||||
|
|
||||||
List<Pair<String, Integer>> slots = new ArrayList<Pair<String,Integer>>();
|
List<Pair<String, Integer>> slots = new ArrayList<Pair<String,Integer>>();
|
||||||
for(String slotDesc : data) {
|
for(String slotDesc : data) {
|
||||||
String[] kv = TextUtil.splitWithParenthesis(slotDesc, ' ', '(', ')', 2);
|
String[] kv = TextUtil.splitWithParenthesis(slotDesc, ' ', 2);
|
||||||
if (kv[1].startsWith("cover"))
|
if (kv[1].startsWith("cover"))
|
||||||
nCovers = Integer.parseInt(kv[0]);
|
nCovers = Integer.parseInt(kv[0]);
|
||||||
else
|
else
|
||||||
|
|||||||
@@ -238,7 +238,7 @@ public final class CardBlock implements Comparable<CardBlock> {
|
|||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
protected CardBlock read(String line, int i) {
|
protected CardBlock read(String line, int i) {
|
||||||
final String[] sParts = TextUtil.splitWithParenthesis(line.trim(), ',', '(', ')', 3);
|
final String[] sParts = TextUtil.splitWithParenthesis(line.trim(), ',', 3);
|
||||||
String name = sParts[0];
|
String name = sParts[0];
|
||||||
|
|
||||||
String[] numbers = sParts[1].trim().split("/");
|
String[] numbers = sParts[1].trim().split("/");
|
||||||
@@ -249,7 +249,7 @@ public final class CardBlock implements Comparable<CardBlock> {
|
|||||||
List<CardEdition> sets = new ArrayList<CardEdition>();
|
List<CardEdition> sets = new ArrayList<CardEdition>();
|
||||||
List<MetaSet> metas = new ArrayList<MetaSet>();
|
List<MetaSet> metas = new ArrayList<MetaSet>();
|
||||||
|
|
||||||
String[] setNames = TextUtil.splitWithParenthesis(sParts[2], ' ', '(', ')' );
|
String[] setNames = TextUtil.splitWithParenthesis(sParts[2], ' ' );
|
||||||
for(final String set : setNames ) {
|
for(final String set : setNames ) {
|
||||||
if(set.startsWith("Meta-")) {
|
if(set.startsWith("Meta-")) {
|
||||||
String metaSpec = set.substring(5);
|
String metaSpec = set.substring(5);
|
||||||
|
|||||||
@@ -34,7 +34,7 @@ public class FatPackTemplate extends SealedProductTemplate {
|
|||||||
protected FatPackTemplate read(String line, int i) {
|
protected FatPackTemplate read(String line, int i) {
|
||||||
String[] headAndData = TextUtil.split(line, ':', 2);
|
String[] headAndData = TextUtil.split(line, ':', 2);
|
||||||
final String edition = headAndData[0];
|
final String edition = headAndData[0];
|
||||||
final String[] data = TextUtil.splitWithParenthesis(headAndData[1], ',', '(', ')');
|
final String[] data = TextUtil.splitWithParenthesis(headAndData[1], ',');
|
||||||
int nBoosters = 6;
|
int nBoosters = 6;
|
||||||
|
|
||||||
List<Pair<String, Integer>> slots = new ArrayList<Pair<String,Integer>>();
|
List<Pair<String, Integer>> slots = new ArrayList<Pair<String,Integer>>();
|
||||||
|
|||||||
@@ -78,11 +78,11 @@ public class SealedProductTemplate {
|
|||||||
protected SealedProductTemplate read(String line, int i) {
|
protected SealedProductTemplate read(String line, int i) {
|
||||||
String[] headAndData = TextUtil.split(line, ':', 2);
|
String[] headAndData = TextUtil.split(line, ':', 2);
|
||||||
final String edition = headAndData[0];
|
final String edition = headAndData[0];
|
||||||
final String[] data = TextUtil.splitWithParenthesis(headAndData[1], ',', '(', ')');
|
final String[] data = TextUtil.splitWithParenthesis(headAndData[1], ',');
|
||||||
|
|
||||||
List<Pair<String, Integer>> slots = new ArrayList<Pair<String,Integer>>();
|
List<Pair<String, Integer>> slots = new ArrayList<Pair<String,Integer>>();
|
||||||
for(String slotDesc : data) {
|
for(String slotDesc : data) {
|
||||||
String[] kv = TextUtil.splitWithParenthesis(slotDesc, ' ', '(', ')', 2);
|
String[] kv = TextUtil.splitWithParenthesis(slotDesc, ' ', 2);
|
||||||
slots.add(ImmutablePair.of(kv[1], Integer.parseInt(kv[0])));
|
slots.add(ImmutablePair.of(kv[1], Integer.parseInt(kv[0])));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -55,7 +55,7 @@ public class UnOpenedMeta implements IUnOpenedProduct {
|
|||||||
metaSets = new ArrayList<MetaSet>();
|
metaSets = new ArrayList<MetaSet>();
|
||||||
operation = op;
|
operation = op;
|
||||||
|
|
||||||
for(String m : TextUtil.splitWithParenthesis(creationString, ';', '(', ')')) {
|
for(String m : TextUtil.splitWithParenthesis(creationString, ';')) {
|
||||||
metaSets.add(new MetaSet(m, true));
|
metaSets.add(new MetaSet(m, true));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -95,9 +95,9 @@ public class CustomLimited extends DeckBase {
|
|||||||
List<Pair<String, Integer>> slots = new ArrayList<Pair<String,Integer>>();
|
List<Pair<String, Integer>> slots = new ArrayList<Pair<String,Integer>>();
|
||||||
String boosterData = data.get("Booster");
|
String boosterData = data.get("Booster");
|
||||||
if(StringUtils.isNotEmpty(boosterData)){
|
if(StringUtils.isNotEmpty(boosterData)){
|
||||||
final String[] booster = TextUtil.splitWithParenthesis(boosterData, ',', '(', ')');
|
final String[] booster = TextUtil.splitWithParenthesis(boosterData, ',');
|
||||||
for(String slotDesc : booster) {
|
for(String slotDesc : booster) {
|
||||||
String[] kv = TextUtil.splitWithParenthesis(slotDesc, ' ', '(', ')', 2);
|
String[] kv = TextUtil.splitWithParenthesis(slotDesc, ' ', 2);
|
||||||
slots.add(ImmutablePair.of(kv[1], Integer.parseInt(kv[0])));
|
slots.add(ImmutablePair.of(kv[1], Integer.parseInt(kv[0])));
|
||||||
}
|
}
|
||||||
} else
|
} else
|
||||||
|
|||||||
@@ -108,7 +108,7 @@ public class SealedCardPoolGenerator {
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
for (String pz : TextUtil.split(p, ',')) {
|
for (String pz : TextUtil.split(p, ',')) {
|
||||||
String[] pps = TextUtil.splitWithParenthesis(pz.trim(), ' ' , '(', ')');
|
String[] pps = TextUtil.splitWithParenthesis(pz.trim(), ' ');
|
||||||
String setCode = pps[pps.length - 1];
|
String setCode = pps[pps.length - 1];
|
||||||
int nBoosters = pps.length > 1 ? Integer.parseInt(pps[0]) : 1;
|
int nBoosters = pps.length > 1 ? Integer.parseInt(pps[0]) : 1;
|
||||||
while(nBoosters-- > 0)
|
while(nBoosters-- > 0)
|
||||||
|
|||||||
@@ -48,11 +48,18 @@ public class TextUtil {
|
|||||||
public static String[] split(CharSequence input, char delimiter, int limit) {
|
public static String[] split(CharSequence input, char delimiter, int limit) {
|
||||||
return splitWithParenthesis(input, delimiter, limit, '\0', '\0', true);
|
return splitWithParenthesis(input, delimiter, limit, '\0', '\0', true);
|
||||||
}
|
}
|
||||||
|
public static String[] splitWithParenthesis(CharSequence input, char delimiter) {
|
||||||
|
return splitWithParenthesis(input, delimiter, Integer.MAX_VALUE, '(', ')', true);
|
||||||
|
}
|
||||||
|
|
||||||
public static String[] splitWithParenthesis(CharSequence input, char delimiter, char openPar, char closePar) {
|
public static String[] splitWithParenthesis(CharSequence input, char delimiter, char openPar, char closePar) {
|
||||||
return splitWithParenthesis(input, delimiter, Integer.MAX_VALUE, openPar, closePar, true);
|
return splitWithParenthesis(input, delimiter, Integer.MAX_VALUE, openPar, closePar, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static String[] splitWithParenthesis(CharSequence input, char delimiter, int limit) {
|
||||||
|
return splitWithParenthesis(input, delimiter, limit, '(', ')', true);
|
||||||
|
}
|
||||||
|
|
||||||
public static String[] splitWithParenthesis(CharSequence input, char delimiter, char openPar, char closePar, int limit) {
|
public static String[] splitWithParenthesis(CharSequence input, char delimiter, char openPar, char closePar, int limit) {
|
||||||
return splitWithParenthesis(input, delimiter, limit, openPar, closePar, true);
|
return splitWithParenthesis(input, delimiter, limit, openPar, closePar, true);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user