update ImageKey for Other

This commit is contained in:
Hans Mackowiak
2025-05-12 07:13:06 +02:00
committed by Chris H
parent 9caa024fa5
commit 559daf9fce
3 changed files with 9 additions and 9 deletions

View File

@@ -1001,14 +1001,14 @@ public class StaticData {
if (realSetCode != null) { if (realSetCode != null) {
CardEdition.EditionEntry ee = this.editions.get(realSetCode).findOther(name); CardEdition.EditionEntry ee = this.editions.get(realSetCode).findOther(name);
if (ee != null) { // TODO add collector Number and new ImageKey format if (ee != null) { // TODO add collector Number and new ImageKey format
return ImageKeys.getTokenKey(name + "_" + realSetCode.toLowerCase()); return ImageKeys.getTokenKey(String.format("%s|%s|%s", name, realSetCode, ee.collectorNumber()));
} }
} }
} }
for (CardEdition e : this.editions) { for (CardEdition e : this.editions) {
CardEdition.EditionEntry ee = e.findOther(name); CardEdition.EditionEntry ee = e.findOther(name);
if (ee != null) { // TODO add collector Number and new ImageKey format if (ee != null) { // TODO add collector Number and new ImageKey format
return ImageKeys.getTokenKey(name + "_" + e.getCode().toLowerCase()); return ImageKeys.getTokenKey(String.format("%s|%s|%s", name, e.getCode(), ee.collectorNumber()));
} }
} }
// final fallback // final fallback

View File

@@ -65,9 +65,9 @@ public class PaperToken implements InventoryItemFromSet, IPaperCard {
if (collectorNumber != null && !collectorNumber.isEmpty() && edition != null && edition.getTokens().containsKey(imageFileName)) { if (collectorNumber != null && !collectorNumber.isEmpty() && edition != null && edition.getTokens().containsKey(imageFileName)) {
int idx = 0; int idx = 0;
// count the one with the same collectorNumber // count the one with the same collectorNumber
for (CardEdition.TokenInSet t : edition.getTokens().get(imageFileName)) { for (CardEdition.EditionEntry t : edition.getTokens().get(imageFileName)) {
++idx; ++idx;
if (!t.collectorNumber.equals(collectorNumber)) { if (!t.collectorNumber().equals(collectorNumber)) {
continue; continue;
} }
// TODO make better image file names when collector number is known // TODO make better image file names when collector number is known

View File

@@ -46,10 +46,10 @@ public class TokenDb implements ITokenDatabase {
public void preloadTokens() { public void preloadTokens() {
for (CardEdition edition : this.editions) { for (CardEdition edition : this.editions) {
for (Map.Entry<String, Collection<CardEdition.TokenInSet>> inSet : edition.getTokens().asMap().entrySet()) { for (Map.Entry<String, Collection<CardEdition.EditionEntry>> inSet : edition.getTokens().asMap().entrySet()) {
String name = inSet.getKey(); String name = inSet.getKey();
String fullName = String.format("%s_%s", name, edition.getCode().toLowerCase()); String fullName = String.format("%s_%s", name, edition.getCode().toLowerCase());
for (CardEdition.TokenInSet t : inSet.getValue()) { for (CardEdition.EditionEntry t : inSet.getValue()) {
allTokenByName.put(fullName, addTokenInSet(edition, name, t)); allTokenByName.put(fullName, addTokenInSet(edition, name, t));
} }
} }
@@ -65,14 +65,14 @@ public class TokenDb implements ITokenDatabase {
return false; return false;
} }
for (CardEdition.TokenInSet t : edition.getTokens().get(name)) { for (CardEdition.EditionEntry t : edition.getTokens().get(name)) {
allTokenByName.put(fullName, addTokenInSet(edition, name, t)); allTokenByName.put(fullName, addTokenInSet(edition, name, t));
} }
return true; return true;
} }
protected PaperToken addTokenInSet(CardEdition edition, String name, CardEdition.TokenInSet t) { protected PaperToken addTokenInSet(CardEdition edition, String name, CardEdition.EditionEntry t) {
return new PaperToken(rulesByName.get(name), edition, name, t.collectorNumber, t.artistName); return new PaperToken(rulesByName.get(name), edition, name, t.collectorNumber(), t.artistName());
} }
// try all editions to find token // try all editions to find token