Re-add to carddb the integration with CardPreferences on Mobile version

On Mobile Forge Port (only) there is the possibility to set a preferred art for a card, from card catalog.
Once a card art is selected, it will always be returned for that specific art whenever no other specific edition is specified.
This commit adds changes to cardDb setPreferredArtMethod (API) and CardRequest.fromString to work with any preferred art (if any).

CardRequests reflects this change by adding another (private) constructor which expects to create a CardRequest from a preferredArt entry in the form of (CardName|SetCode|ArtIndex)
This commit is contained in:
leriomaggio
2021-09-10 14:09:25 +01:00
parent 9d235924ec
commit 27ab4c35a3
2 changed files with 30 additions and 12 deletions

View File

@@ -2102,7 +2102,7 @@ public class CardDbTestCase extends ForgeCardMockTestCase {
}
@Test void testCardPreferenceSetReturnsAlwaysTheSelectedArtNoMatterTheRequest(){
@Test void testThatWithCardPreferenceSetAndNoRequestForSpecificEditionAlwaysReturnsPreferredArt(){
String cardRequest = CardDb.CardRequest.compose("Island", "MIR", 3);
PaperCard islandCard = this.cardDb.getCard(cardRequest);
assertNotNull(islandCard);
@@ -2118,8 +2118,24 @@ public class CardDbTestCase extends ForgeCardMockTestCase {
assertNotNull(islandCard);
// Now card should be from the preferred art no matter the request
assertEquals(islandCard.getName(), "Island");
assertEquals(islandCard.getEdition(), "TMP");
assertEquals(islandCard.getArtIndex(), 1);
// Now just asking for an Island
islandCard = this.cardDb.getCard("Island");
assertNotNull(islandCard);
assertEquals(islandCard.getName(), "Island");
assertEquals(islandCard.getEdition(), "MIR");
assertEquals(islandCard.getArtIndex(), 3);
// Now asking for a foiled island - I will get the one from preferred art - but foiled
cardRequest = CardDb.CardRequest.compose("Island", true);
islandCard = this.cardDb.getCard(cardRequest);
assertNotNull(islandCard);
assertEquals(islandCard.getName(), "Island");
assertEquals(islandCard.getEdition(), "MIR");
assertEquals(islandCard.getArtIndex(), 3);
assertTrue(islandCard.isFoil());
}
}