| 57 | } |
| 58 | |
| 59 | public PaperToken(final CardRules c, CardEdition edition0, String imageFileName, String collectorNumber, String artist) { |
| 60 | this.cardRules = c; |
| 61 | this.name = c.getName(); |
| 62 | this.edition = edition0; |
| 63 | this.collectorNumber = collectorNumber; |
| 64 | this.artist = artist; |
| 65 | |
| 66 | if (collectorNumber != null && !collectorNumber.isEmpty() && edition != null && edition.getTokens().containsKey(imageFileName)) { |
| 67 | int idx = 0; |
| 68 | // count the one with the same collectorNumber |
| 69 | for (CardEdition.EditionEntry t : edition.getTokens().get(imageFileName)) { |
| 70 | ++idx; |
| 71 | if (!t.collectorNumber().equals(collectorNumber)) { |
| 72 | continue; |
| 73 | } |
| 74 | // TODO make better image file names when collector number is known |
| 75 | // for the right index, we need to count the ones with wrong collector number too |
| 76 | this.imageFileName.add(String.format("%s|%s|%s|%d", imageFileName, edition.getCode(), collectorNumber, idx)); |
| 77 | } |
| 78 | this.artIndex = this.imageFileName.size(); |
| 79 | } else if (null == edition || CardEdition.UNKNOWN == edition) { |
| 80 | this.imageFileName.add(imageFileName); |
| 81 | } else { |
| 82 | // Fallback if CollectorNumber is not used |
| 83 | this.imageFileName.add(String.format("%s|%s", imageFileName, edition.getCode())); |
| 84 | } |
| 85 | } |
| 86 | |
| 87 | @Override |
| 88 | public String getName() { |