Assign paths to CardRules so we can report where issues come from

This commit is contained in:
Chris H
2025-07-25 21:56:08 -04:00
parent cf11802fbe
commit 0aa8c933d8
4 changed files with 40 additions and 4 deletions

View File

@@ -391,7 +391,9 @@ public class CardStorageReader {
try (InputStream fileInputStream = java.nio.file.Files.newInputStream(file.toPath())) {
reader.reset();
final List<String> lines = readScript(fileInputStream);
return reader.readCard(lines, Files.getNameWithoutExtension(file.getName()));
CardRules rules = reader.readCard(lines, Files.getNameWithoutExtension(file.getName()));
rules.setPath(file.getPath());
return rules;
} catch (final FileNotFoundException ex) {
throw new RuntimeException("CardReader : run error -- file not found: " + file.getPath(), ex);
} catch (final Exception ex) {
@@ -410,7 +412,9 @@ public class CardStorageReader {
protected final CardRules loadCard(final CardRules.Reader rulesReader, final ZipEntry entry) {
try (InputStream zipInputStream = this.zip.getInputStream(entry)) {
rulesReader.reset();
return rulesReader.readCard(readScript(zipInputStream), Files.getNameWithoutExtension(entry.getName()));
CardRules rules = rulesReader.readCard(readScript(zipInputStream), Files.getNameWithoutExtension(entry.getName()));
rules.setPath(entry.getName());
return rules;
} catch (final IOException exn) {
throw new RuntimeException(exn);
}

View File

@@ -434,13 +434,13 @@ public final class CardDb implements ICardDatabase, IDeckGenPool {
}
if (upcomingSet != null) {
System.err.println("Upcoming set " + upcomingSet + " dated in the future. All unaccounted cards will be added to this set with unknown rarity.");
System.err.println("Upcoming set " + upcomingSet + " dated in the future. All `upcoming` cards will be added to this set with unknown rarity.");
}
for (CardRules cr : rulesByName.values()) {
if (!contains(cr.getName())) {
if (!cr.isCustom()) {
if (upcomingSet != null) {
if (upcomingSet != null && cr.getPath() != null && cr.getPath().contains("upcoming/")) {
addCard(new PaperCard(cr, upcomingSet.getCode(), CardRarity.Unknown));
} else if (enableUnknownCards && !this.filtered.contains(cr.getName())) {
System.err.println("The card " + cr.getName() + " was not assigned to any set. Adding it to UNKNOWN set... to fix see res/editions/ folder. ");

View File

@@ -53,6 +53,7 @@ public final class CardRules implements ICardCharacteristics {
private boolean addsWildCardColor;
private int setColorID;
private boolean custom;
private String path;
public CardRules(ICardFace[] faces, CardSplitType altMode, CardAiHints cah) {
splitType = altMode;
@@ -193,6 +194,9 @@ public final class CardRules implements ICardCharacteristics {
public String getNormalizedName() { return normalizedName; }
public void setNormalizedName(String filename) { normalizedName = filename; }
public String getPath() { return path; }
public void setPath(String path) { this.path = path; }
public CardAiHints getAiHints() {
return aiHints;
}

View File

@@ -0,0 +1,28 @@
[metadata]
Code=OE01
Date=2017-06-16
Name=Archenemy: Nicol Bolas Schemes
Type=Multiplayer
ScryfallCode=OE01
[cards]
1* C Because I Have Willed It @Adrian Majkrzak
2* C Behold My Grandeur @Zack Stella
3* C Bow to My Command @Dan Murayama Scott
4* C Choose Your Demise @Nils Hamm
5* C Delight in the Hunt @Titus Lunter
6* C Every Dream a Nightmare @Mathias Kollros
7* C For Each of You, a Gift @Marco Nelor
8* C Know Evil @Anthony Palumbo
9* C Make Yourself Useful @David Gaillet
10* C The Mighty Will Fall @Volkan Baǵa
11* C My Forces Are Innumerable @Seb McKinnon
12* C My Laughter Echoes @Steve Argyle
13* C No One Will Hear Your Cries @McLean Kendree
14* C Pay Tribute to Me @Aaron Miller
15* C Power Without Equal @Christine Choi
16* C A Reckoning Approaches @Yeong-Hao Han
17* C There Is No Refuge @Tomasz Jedruszek
18* C This World Belongs to Me @Min Yum
19* C What's Yours Is Now Mine @Steve Argyle
20* C When Will You Learn? @Yohann Schepacz