Adding ArtPreference attr to allow for more flexibility when recognising cards

Signed-off-by: leriomaggio <valeriomaggio@gmail.com>
This commit is contained in:
leriomaggio
2021-09-17 19:29:03 +01:00
parent 7d1542ced3
commit e6cfafb431

View File

@@ -19,6 +19,7 @@ package forge.deck;
import com.google.common.collect.Lists; import com.google.common.collect.Lists;
import forge.StaticData; import forge.StaticData;
import forge.card.CardDb;
import forge.card.CardEdition; import forge.card.CardEdition;
import forge.card.CardType; import forge.card.CardType;
import forge.item.IPaperCard; import forge.item.IPaperCard;
@@ -291,8 +292,9 @@ public class DeckRecognizer {
private Date releaseDateConstraint = null; private Date releaseDateConstraint = null;
// This two parameters are controlled only via setter methods // This two parameters are controlled only via setter methods
private List<String> allowedSetCodes = null; // as imposed by current format private List<String> allowedSetCodes = null;
private DeckFormat deckFormat = null; // private DeckFormat deckFormat = null;
private CardDb.CardArtPreference artPreference = StaticData.instance().getCardArtPreference(); // init as default
public Token recognizeLine(final String rawLine, DeckSection referenceSection) { public Token recognizeLine(final String rawLine, DeckSection referenceSection) {
if (rawLine == null) if (rawLine == null)
@@ -397,11 +399,12 @@ public class DeckRecognizer {
// unless it is illegal for current format or invalid with selected date. // unless it is illegal for current format or invalid with selected date.
PaperCard pc = null; PaperCard pc = null;
if (hasGameFormatConstraints()) { if (hasGameFormatConstraints()) {
pc = data.getCardFromSupportedEditions(cardName, isFoil, this.allowedSetCodes, pc = data.getCardFromSupportedEditions(cardName, isFoil, this.artPreference,
this.allowedSetCodes,
this.releaseDateConstraint); this.releaseDateConstraint);
} }
if (pc == null) if (pc == null)
pc = data.getCardFromSupportedEditions(cardName, isFoil, null, pc = data.getCardFromSupportedEditions(cardName, isFoil, this.artPreference, null,
this.releaseDateConstraint); this.releaseDateConstraint);
if (pc != null) { if (pc != null) {
@@ -616,4 +619,6 @@ public class DeckRecognizer {
public void setDeckFormatConstraint(DeckFormat deckFormat0){ public void setDeckFormatConstraint(DeckFormat deckFormat0){
this.deckFormat = deckFormat0; this.deckFormat = deckFormat0;
} }
public void setArtPreference(CardDb.CardArtPreference artPref){ this.artPreference = artPref; }
} }