mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-18 11:48:02 +00:00
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:
@@ -312,16 +312,20 @@ public final class CardDb implements ICardDatabase, IDeckGenPool {
|
|||||||
return tryGetCard(request);
|
return tryGetCard(request);
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getCardCollectorNumber(String cardName, String reqEdition) {
|
public String getCardCollectorNumber(String cardName, String reqEdition, int artIndex) {
|
||||||
cardName = getName(cardName);
|
cardName = getName(cardName);
|
||||||
CardEdition edition = editions.get(reqEdition);
|
CardEdition edition = editions.get(reqEdition);
|
||||||
if (edition == null)
|
if (edition == null)
|
||||||
return null;
|
return null;
|
||||||
|
int numMatches = 0;
|
||||||
for (CardInSet card : edition.getCards()) {
|
for (CardInSet card : edition.getCards()) {
|
||||||
if (card.name.equalsIgnoreCase(cardName)) {
|
if (card.name.equalsIgnoreCase(cardName)) {
|
||||||
|
numMatches += 1;
|
||||||
|
if (numMatches == artIndex) {
|
||||||
return card.collectorNumber;
|
return card.collectorNumber;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -50,8 +50,9 @@ public abstract class ImageFetcher {
|
|||||||
setDownload.append(ImageUtil.getDownloadUrl(paperCard, backFace));
|
setDownload.append(ImageUtil.getDownloadUrl(paperCard, backFace));
|
||||||
downloadUrls.add(setDownload.toString());
|
downloadUrls.add(setDownload.toString());
|
||||||
|
|
||||||
|
int artIndex = Integer.parseInt(imageKey.split("\\|")[2]);
|
||||||
final StaticData data = StaticData.instance();
|
final StaticData data = StaticData.instance();
|
||||||
final String cardNum = data.getCommonCards().getCardCollectorNumber(paperCard.getName(), paperCard.getEdition());
|
final String cardNum = data.getCommonCards().getCardCollectorNumber(paperCard.getName(), paperCard.getEdition(), artIndex);
|
||||||
if (cardNum != null) {
|
if (cardNum != null) {
|
||||||
String suffix = "";
|
String suffix = "";
|
||||||
if (paperCard.getRules().getOtherPart() != null) {
|
if (paperCard.getRules().getOtherPart() != null) {
|
||||||
|
|||||||
Reference in New Issue
Block a user