mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-15 10:18:01 +00:00
New test cases (and extended implementation) accounting for cards from UNKNONW sets to be correctly retrieved.
This commit is contained in:
@@ -181,7 +181,7 @@ public final class CardDb implements ICardDatabase, IDeckGenPool {
|
|||||||
}
|
}
|
||||||
String collectorNumber = cNrPos > 0 ? info[cNrPos].substring(1, info[cNrPos].length() - 1) : IPaperCard.NO_COLLECTOR_NUMBER;
|
String collectorNumber = cNrPos > 0 ? info[cNrPos].substring(1, info[cNrPos].length() - 1) : IPaperCard.NO_COLLECTOR_NUMBER;
|
||||||
String setName = setPos > 0 ? info[setPos] : null;
|
String setName = setPos > 0 ? info[setPos] : null;
|
||||||
if ("???".equals(setName)) {
|
if (setName != null && setName.equals(CardEdition.UNKNOWN.getCode())) { // ???
|
||||||
setName = null;
|
setName = null;
|
||||||
}
|
}
|
||||||
// finally, check whether any between artIndex and CollectorNumber has been set
|
// finally, check whether any between artIndex and CollectorNumber has been set
|
||||||
@@ -456,10 +456,8 @@ public final class CardDb implements ICardDatabase, IDeckGenPool {
|
|||||||
if (cards == null)
|
if (cards == null)
|
||||||
return null;
|
return null;
|
||||||
// Either No Edition has been specified OR as a fallback in case of any error!
|
// Either No Edition has been specified OR as a fallback in case of any error!
|
||||||
// get card using the default policy strategy (Latest, Earliest, or Random)
|
// get card using the default card art preference
|
||||||
// Note: Request is transformed back into the unique line,
|
result = getCardFromEditions(request.cardName, this.defaultCardArtPreference, request.artIndex);
|
||||||
// embedding all the information; Parameter Name is counter intuitive though.
|
|
||||||
result = getCardFromEditions(request.cardName);
|
|
||||||
return result != null && request.isFoil ? result.getFoiled() : result;
|
return result != null && request.isFoil ? result.getFoiled() : result;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -647,8 +645,14 @@ public final class CardDb implements ICardDatabase, IDeckGenPool {
|
|||||||
// Collect the list of all editions found for target card
|
// Collect the list of all editions found for target card
|
||||||
LinkedHashSet<CardEdition> cardEditions = new LinkedHashSet<>();
|
LinkedHashSet<CardEdition> cardEditions = new LinkedHashSet<>();
|
||||||
for (PaperCard card : cards) {
|
for (PaperCard card : cards) {
|
||||||
CardEdition ed = editions.get(card.getEdition());
|
String setCode = card.getEdition();
|
||||||
cardEditions.add(ed);
|
if (setCode.equals(CardEdition.UNKNOWN.getCode()))
|
||||||
|
cardEditions.add(CardEdition.UNKNOWN);
|
||||||
|
else {
|
||||||
|
CardEdition ed = editions.get(card.getEdition());
|
||||||
|
if (ed != null)
|
||||||
|
cardEditions.add(ed);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
// Filter Cards Editions based on set preferences
|
// Filter Cards Editions based on set preferences
|
||||||
List<CardEdition> acceptedEditions = Lists.newArrayList(Iterables.filter(cardEditions, new Predicate<CardEdition>() {
|
List<CardEdition> acceptedEditions = Lists.newArrayList(Iterables.filter(cardEditions, new Predicate<CardEdition>() {
|
||||||
@@ -906,7 +910,7 @@ public final class CardDb implements ICardDatabase, IDeckGenPool {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public StringBuilder appendCardToStringBuilder(PaperCard card, StringBuilder sb) {
|
public StringBuilder appendCardToStringBuilder(PaperCard card, StringBuilder sb) {
|
||||||
final boolean hasBadSetInfo = "???".equals(card.getEdition()) || StringUtils.isBlank(card.getEdition());
|
final boolean hasBadSetInfo = (card.getEdition()).equals(CardEdition.UNKNOWN.getCode()) || StringUtils.isBlank(card.getEdition());
|
||||||
sb.append(card.getName());
|
sb.append(card.getName());
|
||||||
if (card.isFoil()) {
|
if (card.isFoil()) {
|
||||||
sb.append(CardDb.foilSuffix);
|
sb.append(CardDb.foilSuffix);
|
||||||
|
|||||||
@@ -1929,5 +1929,21 @@ public class CardDbTestCase extends ForgeCardMockTestCase {
|
|||||||
assertEquals(this.cardDb.getCardArtPreference(), CardDb.CardArtPreference.LATEST_ART_ALL_EDITIONS);
|
assertEquals(this.cardDb.getCardArtPreference(), CardDb.CardArtPreference.LATEST_ART_ALL_EDITIONS);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testCardFromUnknownSet(){
|
||||||
|
String unknownCardName = "Unkwnonw Card Name";
|
||||||
|
PaperCard unknownCard = new PaperCard(CardRules.getUnsupportedCardNamed(unknownCardName),
|
||||||
|
CardEdition.UNKNOWN.getCode(), CardRarity.Unknown);
|
||||||
|
this.cardDb.addCard(unknownCard);
|
||||||
|
assertTrue(this.cardDb.getAllCards().contains(unknownCard));
|
||||||
|
assertNotNull(this.cardDb.getAllCards(unknownCardName));
|
||||||
|
assertEquals(this.cardDb.getAllCards(unknownCardName).size(), 1);
|
||||||
|
|
||||||
|
PaperCard retrievedPaperCard = this.cardDb.getCard(unknownCardName);
|
||||||
|
assertNotNull(retrievedPaperCard);
|
||||||
|
assertEquals(retrievedPaperCard.getName(), unknownCardName);
|
||||||
|
assertEquals(retrievedPaperCard.getEdition(), CardEdition.UNKNOWN.getCode());
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user