correct how collectorNumber is located

The existing logic will always return the first match for a given card
name, even if there are multiple different printings of the same card
name within a set. This change aligns the collectorNumber with the
alternate art index.

Signed-off-by: Jamin W. Collins <jamin.collins@gmail.com>
This commit is contained in:
Jamin W. Collins
2020-03-03 21:18:38 -07:00
parent e325f42ca8
commit ff31718839
2 changed files with 8 additions and 3 deletions

View File

@@ -312,14 +312,18 @@ public final class CardDb implements ICardDatabase, IDeckGenPool {
return tryGetCard(request);
}
public String getCardCollectorNumber(String cardName, String reqEdition) {
public String getCardCollectorNumber(String cardName, String reqEdition, int artIndex) {
cardName = getName(cardName);
CardEdition edition = editions.get(reqEdition);
if (edition == null)
return null;
int numMatches = 0;
for (CardInSet card : edition.getCards()) {
if (card.name.equalsIgnoreCase(cardName)) {
return card.collectorNumber;
numMatches += 1;
if (numMatches == artIndex) {
return card.collectorNumber;
}
}
}
return null;