BUG FIX for Smart Card Art selection

This subtle bug occurred whenever the algorithm for smart card art selection wanted to add a card with multiple arts and the number of cards per art to add was not even. To avoid zeros, the cardsPerArtIndex was set at least to one, and so the rest - leading then to adding too many (extra) cards not originally present in the deck.

Thanks to @Snoops for the heads up.
This commit is contained in:
leriomaggio
2021-09-12 00:56:44 +01:00
parent a5aa29f65e
commit fb092c77a4

View File

@@ -366,8 +366,8 @@ public class Deck extends DeckBase implements Iterable<Entry<DeckSection, CardPo
String setCode = alternativeCardPrint.getEdition(); String setCode = alternativeCardPrint.getEdition();
boolean isFoil = alternativeCardPrint.isFoil(); boolean isFoil = alternativeCardPrint.isFoil();
int cardsPerArtIndex = totalNrToAdd / nrOfAvailableArts; int cardsPerArtIndex = totalNrToAdd / nrOfAvailableArts;
int restOfCardsToAdd = cardsPerArtIndex > 0 ? totalNrToAdd % nrOfAvailableArts : 0;
cardsPerArtIndex = Math.max(1, cardsPerArtIndex); // make sure is never zero cardsPerArtIndex = Math.max(1, cardsPerArtIndex); // make sure is never zero
int restOfCardsToAdd = totalNrToAdd % nrOfAvailableArts;
int cardsAdded = 0; int cardsAdded = 0;
PaperCard alternativeCardArt = null; PaperCard alternativeCardArt = null;
for (int artIndex = 1; artIndex <= nrOfAvailableArts; artIndex++){ for (int artIndex = 1; artIndex <= nrOfAvailableArts; artIndex++){