mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-16 18:58:00 +00:00
FIX Issue #1413
This commit includes support to the XMage format in Deck Recognizer along with corresponding new tests and updates to labels for UI Signed-off-by: leriomaggio <valeriomaggio@gmail.com>
This commit is contained in:
@@ -206,7 +206,13 @@ public class DeckRecognizer {
|
|||||||
REX_CARD_COUNT, REX_CARD_NAME, REX_COLL_NUMBER, REX_SET_CODE, REX_FOIL_MTGGOLDFISH);
|
REX_CARD_COUNT, REX_CARD_NAME, REX_COLL_NUMBER, REX_SET_CODE, REX_FOIL_MTGGOLDFISH);
|
||||||
public static final Pattern CARD_COLLNO_SET_PATTERN = Pattern.compile(REX_FULL_REQUEST_CARD_COLLNO_SET);
|
public static final Pattern CARD_COLLNO_SET_PATTERN = Pattern.compile(REX_FULL_REQUEST_CARD_COLLNO_SET);
|
||||||
|
|
||||||
// 6. Card-Only Request (Amount?)
|
// 6. XMage format (Amount?, [Set:Collector Number] Card Name)
|
||||||
|
public static final String REX_FULL_REQUEST_XMAGE = String.format(
|
||||||
|
"^(%s\\s)?\\s*(\\[)?%s:%s(\\])\\s+%s\\s*%s$",
|
||||||
|
REX_CARD_COUNT, REX_SET_CODE, REX_COLL_NUMBER, REX_CARD_NAME, REX_FOIL_MTGGOLDFISH);
|
||||||
|
public static final Pattern SET_COLLNO_CARD_XMAGE_PATTERN = Pattern.compile(REX_FULL_REQUEST_XMAGE);
|
||||||
|
|
||||||
|
// 7. Card-Only Request (Amount?)
|
||||||
public static final String REX_CARDONLY = String.format(
|
public static final String REX_CARDONLY = String.format(
|
||||||
"(%s\\s)?\\s*%s\\s*%s", REX_CARD_COUNT, REX_CARD_NAME, REX_FOIL_MTGGOLDFISH);
|
"(%s\\s)?\\s*%s\\s*%s", REX_CARD_COUNT, REX_CARD_NAME, REX_FOIL_MTGGOLDFISH);
|
||||||
public static final Pattern CARD_ONLY_PATTERN = Pattern.compile(REX_CARDONLY);
|
public static final Pattern CARD_ONLY_PATTERN = Pattern.compile(REX_CARDONLY);
|
||||||
@@ -382,7 +388,8 @@ public class DeckRecognizer {
|
|||||||
Pattern[] patternsWithCollNumber = new Pattern[] {
|
Pattern[] patternsWithCollNumber = new Pattern[] {
|
||||||
CARD_SET_COLLNO_PATTERN,
|
CARD_SET_COLLNO_PATTERN,
|
||||||
SET_CARD_COLLNO_PATTERN,
|
SET_CARD_COLLNO_PATTERN,
|
||||||
CARD_COLLNO_SET_PATTERN
|
CARD_COLLNO_SET_PATTERN,
|
||||||
|
SET_COLLNO_CARD_XMAGE_PATTERN
|
||||||
};
|
};
|
||||||
for (Pattern pattern : patternsWithCollNumber) {
|
for (Pattern pattern : patternsWithCollNumber) {
|
||||||
Matcher matcher = pattern.matcher(line);
|
Matcher matcher = pattern.matcher(line);
|
||||||
|
|||||||
@@ -1208,7 +1208,7 @@ public class DeckRecognizerTest extends ForgeCardMockTestCase {
|
|||||||
assertEquals(counterSpellCard.getEdition(), "MMQ");
|
assertEquals(counterSpellCard.getEdition(), "MMQ");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test void testInvalidCardRequestWhenReleaseDAteConstraintsAreUp(){
|
@Test void testInvalidCardRequestWhenReleaseDateConstraintsAreUp(){
|
||||||
StaticData magicDb = FModel.getMagicDb();
|
StaticData magicDb = FModel.getMagicDb();
|
||||||
CardDb db = magicDb.getCommonCards();
|
CardDb db = magicDb.getCommonCards();
|
||||||
CardDb altDb = magicDb.getVariantCards();
|
CardDb altDb = magicDb.getVariantCards();
|
||||||
@@ -1234,6 +1234,12 @@ public class DeckRecognizerTest extends ForgeCardMockTestCase {
|
|||||||
assertNull(cardToken.getCard());
|
assertNull(cardToken.getCard());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*==================================
|
||||||
|
* TEST RECOGNISE CARD EXTRA FORMATS
|
||||||
|
* =================================
|
||||||
|
*/
|
||||||
|
|
||||||
|
// === MTG Goldfish
|
||||||
@Test void testFoilRequestInMTGGoldfishExportFormat(){
|
@Test void testFoilRequestInMTGGoldfishExportFormat(){
|
||||||
String mtgGoldfishRequest = "18 Forest <254> [THB]";
|
String mtgGoldfishRequest = "18 Forest <254> [THB]";
|
||||||
Pattern target = DeckRecognizer.CARD_COLLNO_SET_PATTERN;
|
Pattern target = DeckRecognizer.CARD_COLLNO_SET_PATTERN;
|
||||||
@@ -1313,6 +1319,7 @@ public class DeckRecognizerTest extends ForgeCardMockTestCase {
|
|||||||
assertTrue(forestCard.isFoil());
|
assertTrue(forestCard.isFoil());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// === TappedOut Markdown Format
|
||||||
@Test void testPurgeLinksInLineRequests(){
|
@Test void testPurgeLinksInLineRequests(){
|
||||||
String line = "* 1 [Ancestral Recall](http://tappedout.nethttp://tappedout.net/mtg-card/ancestral-recall/)";
|
String line = "* 1 [Ancestral Recall](http://tappedout.nethttp://tappedout.net/mtg-card/ancestral-recall/)";
|
||||||
String expected = "* 1 [Ancestral Recall]";
|
String expected = "* 1 [Ancestral Recall]";
|
||||||
@@ -1341,4 +1348,61 @@ public class DeckRecognizerTest extends ForgeCardMockTestCase {
|
|||||||
assertEquals(ancestralRecallCard.getName(), "Ancestral Recall");
|
assertEquals(ancestralRecallCard.getName(), "Ancestral Recall");
|
||||||
assertEquals(ancestralRecallCard.getEdition(), "VMA");
|
assertEquals(ancestralRecallCard.getEdition(), "VMA");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// === XMage Format
|
||||||
|
@Test void testMatchCardRequestXMageFormat(){
|
||||||
|
String xmageFormatRequest = "1 [LRW:51] Amoeboid Changeling";
|
||||||
|
Pattern target = DeckRecognizer.SET_COLLNO_CARD_XMAGE_PATTERN;
|
||||||
|
Matcher matcher = target.matcher(xmageFormatRequest);
|
||||||
|
assertTrue(matcher.matches());
|
||||||
|
assertEquals(matcher.group(DeckRecognizer.REGRP_CARDNO), "1");
|
||||||
|
assertEquals(matcher.group(DeckRecognizer.REGRP_CARD), "Amoeboid Changeling"); // TRIM
|
||||||
|
assertEquals(matcher.group(DeckRecognizer.REGRP_SET), "LRW");
|
||||||
|
assertEquals(matcher.group(DeckRecognizer.REGRP_COLLNR), "51");
|
||||||
|
assertNull(matcher.group(DeckRecognizer.REGRP_FOIL_GFISH));
|
||||||
|
|
||||||
|
// Test that this line matches only with this pattern
|
||||||
|
|
||||||
|
target = DeckRecognizer.CARD_SET_PATTERN;
|
||||||
|
matcher = target.matcher(xmageFormatRequest);
|
||||||
|
assertFalse(matcher.matches());
|
||||||
|
|
||||||
|
target = DeckRecognizer.SET_CARD_PATTERN;
|
||||||
|
matcher = target.matcher(xmageFormatRequest);
|
||||||
|
assertFalse(matcher.matches());
|
||||||
|
|
||||||
|
target = DeckRecognizer.CARD_SET_COLLNO_PATTERN;
|
||||||
|
matcher = target.matcher(xmageFormatRequest);
|
||||||
|
assertFalse(matcher.matches());
|
||||||
|
|
||||||
|
target = DeckRecognizer.SET_CARD_COLLNO_PATTERN;
|
||||||
|
matcher = target.matcher(xmageFormatRequest);
|
||||||
|
assertFalse(matcher.matches());
|
||||||
|
|
||||||
|
target = DeckRecognizer.CARD_COLLNO_SET_PATTERN;
|
||||||
|
matcher = target.matcher(xmageFormatRequest);
|
||||||
|
assertFalse(matcher.matches());
|
||||||
|
|
||||||
|
target = DeckRecognizer.CARD_ONLY_PATTERN;
|
||||||
|
matcher = target.matcher(xmageFormatRequest);
|
||||||
|
assertFalse(matcher.matches());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test void testRecognizeCardTokenInXMageFormatRequest(){
|
||||||
|
StaticData magicDb = FModel.getMagicDb();
|
||||||
|
CardDb db = magicDb.getCommonCards();
|
||||||
|
CardDb altDb = magicDb.getVariantCards();
|
||||||
|
DeckRecognizer recognizer = new DeckRecognizer(db, altDb);
|
||||||
|
|
||||||
|
String xmageFormatRequest = "1 [LRW:51] Amoeboid Changeling";
|
||||||
|
Token xmageCardToken = recognizer.recogniseCardToken(xmageFormatRequest);
|
||||||
|
assertNotNull(xmageCardToken);
|
||||||
|
assertEquals(xmageCardToken.getType(), TokenType.LEGAL_CARD_REQUEST);
|
||||||
|
assertEquals(xmageCardToken.getNumber(), 1);
|
||||||
|
assertNotNull(xmageCardToken.getCard());
|
||||||
|
PaperCard acCard = xmageCardToken.getCard();
|
||||||
|
assertEquals(acCard.getName(), "Amoeboid Changeling");
|
||||||
|
assertEquals(acCard.getEdition(), "LRW");
|
||||||
|
assertEquals(acCard.getCollectorNumber(), "51");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2676,7 +2676,7 @@ lblGuideTipsDeckSection={0}: Similarly, the Card List can be organised by Deck S
|
|||||||
lblGuideTipsDeckName={0}: Assign a name to your card list. Just type "Deck" or "Name", followed by the name you want. \
|
lblGuideTipsDeckName={0}: Assign a name to your card list. Just type "Deck" or "Name", followed by the name you want. \
|
||||||
This will be used as (new) name for the Deck.
|
This will be used as (new) name for the Deck.
|
||||||
lblGuideTipsDeckFormats={0}: The following Deck formats are supported for immediate import: MTG Arena; \
|
lblGuideTipsDeckFormats={0}: The following Deck formats are supported for immediate import: MTG Arena; \
|
||||||
MTG Goldfish (all export); TappedOut (all export, but CSV); DeckStats.net; Deck ".dec" files.
|
MTGO, XMage, MTG Goldfish (all export); TappedOut (all export, but CSV); DeckStats.net; Deck ".dec" files.
|
||||||
lblGuideTipsTitleCount=Card Amount
|
lblGuideTipsTitleCount=Card Amount
|
||||||
lblGuideTipsTitleSet=Card Art
|
lblGuideTipsTitleSet=Card Art
|
||||||
lblGuideTipsTitleCardType=Card Types
|
lblGuideTipsTitleCardType=Card Types
|
||||||
|
|||||||
Reference in New Issue
Block a user