MCPcopy Create free account
hub / github.com/Card-Forge/forge / PaperToken

Method PaperToken

forge-core/src/main/java/forge/item/PaperToken.java:59–85  ·  view source on GitHub ↗
(final CardRules c, CardEdition edition0, String imageFileName, String collectorNumber, String artist)

Source from the content-addressed store, hash-verified

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() {

Callers

nothing calls this directly

Calls 9

containsKeyMethod · 0.80
getNameMethod · 0.65
isEmptyMethod · 0.65
getMethod · 0.65
addMethod · 0.65
sizeMethod · 0.65
getTokensMethod · 0.45
equalsMethod · 0.45
getCodeMethod · 0.45

Tested by

no test coverage detected