mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-20 20:58:03 +00:00
Support outputting results from parse utility
This commit is contained in:
@@ -378,7 +378,11 @@ public class CardStorageReader {
|
|||||||
public static void parseAllCards(String[] args) {
|
public static void parseAllCards(String[] args) {
|
||||||
if (args.length < 2) { return; }
|
if (args.length < 2) { return; }
|
||||||
|
|
||||||
final int[] counts = new int[args.length];
|
int totalParsedCount = 0;
|
||||||
|
final List<List<String>> output = new ArrayList<List<String>>();
|
||||||
|
for (int i = 1; i < args.length; i++) {
|
||||||
|
output.add(new ArrayList<String>());
|
||||||
|
}
|
||||||
final List<File> allFiles = new ArrayList<File>();
|
final List<File> allFiles = new ArrayList<File>();
|
||||||
final CardRulesReader rulesReader = new CardRulesReader();
|
final CardRulesReader rulesReader = new CardRulesReader();
|
||||||
final CardStorageReader reader = new CardStorageReader(NewConstants.CARD_DATA_DIR, false, null);
|
final CardStorageReader reader = new CardStorageReader(NewConstants.CARD_DATA_DIR, false, null);
|
||||||
@@ -393,15 +397,13 @@ public class CardStorageReader {
|
|||||||
CardRules rules = rulesReader.readCard(lines);
|
CardRules rules = rulesReader.readCard(lines);
|
||||||
|
|
||||||
System.out.println();
|
System.out.println();
|
||||||
System.out.print(rules.getName());
|
System.out.print(rules.getName()); //print each card here in case it gets stuck in utility
|
||||||
|
|
||||||
counts[0]++;
|
totalParsedCount++;
|
||||||
for (int i = 1; i < args.length; i++) {
|
for (int i = 1; i < args.length; i++) {
|
||||||
switch (args[i]) {
|
switch (args[i]) {
|
||||||
case "updateAbilityManaSymbols":
|
case "updateAbilityManaSymbols":
|
||||||
if (updateAbilityManaSymbols(rules, lines, file)) {
|
updateAbilityManaSymbols(rules, lines, file, output.get(i - 1));
|
||||||
counts[i]++;
|
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -410,15 +412,24 @@ public class CardStorageReader {
|
|||||||
}
|
}
|
||||||
|
|
||||||
System.out.println();
|
System.out.println();
|
||||||
|
System.out.println();
|
||||||
|
System.out.print("Total cards: " + totalParsedCount);
|
||||||
|
|
||||||
for (int i = 0; i < args.length; i++) {
|
for (int i = 1; i < args.length; i++) {
|
||||||
int count = counts[i];
|
List<String> singleOutput = output.get(i - 1);
|
||||||
System.out.println();
|
System.out.println();
|
||||||
System.out.print(args[i] + " - " + count + " card" + (count != 1 ? "s" : ""));
|
System.out.println();
|
||||||
|
System.out.println(args[i] + ":");
|
||||||
|
System.out.println();
|
||||||
|
for (String line : singleOutput) {
|
||||||
|
System.out.println(line);
|
||||||
|
}
|
||||||
|
System.out.println();
|
||||||
|
System.out.print("Total cards: " + singleOutput.size());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static boolean updateAbilityManaSymbols(CardRules rules, List<String> lines, File file) {
|
private static void updateAbilityManaSymbols(CardRules rules, List<String> lines, File file, List<String> output) {
|
||||||
boolean updated = false;
|
boolean updated = false;
|
||||||
String oracleText = rules.getOracleText();
|
String oracleText = rules.getOracleText();
|
||||||
String[] sentences = oracleText.replace(rules.getName(), "CARDNAME").split("\\.|\\\\n|\\\"|\\(|\\)");
|
String[] sentences = oracleText.replace(rules.getName(), "CARDNAME").split("\\.|\\\\n|\\\"|\\(|\\)");
|
||||||
@@ -444,8 +455,7 @@ public class CardStorageReader {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (Exception ex) {
|
catch (Exception ex) {
|
||||||
System.out.print(" - Exception: " + ex.getMessage());
|
output.add("<Exception (" + rules.getName() + ") " + ex.getMessage() + ">");
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (updated) {
|
if (updated) {
|
||||||
@@ -460,11 +470,9 @@ public class CardStorageReader {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
p.close();
|
p.close();
|
||||||
System.out.print(" - ability mana symbols updated");
|
output.add(rules.getName());
|
||||||
return true;
|
|
||||||
} catch (final Exception ex) {
|
} catch (final Exception ex) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user