Fixed test and sample decks

This commit is contained in:
Oleg Agafonov 2020-08-10 18:24:21 +04:00
parent 3a1b741509
commit 8b2bc064cd
7 changed files with 30 additions and 20 deletions

View file

@ -24,7 +24,7 @@
2 [M15:198] Satyr Wayfinder 2 [M15:198] Satyr Wayfinder
2 [THS:155] Commune with the Gods 2 [THS:155] Commune with the Gods
2 [THS:180] Sylvan Caryatid 2 [THS:180] Sylvan Caryatid
1 [MBP:77] Sylvan Caryatid 1 [THS:180] Sylvan Caryatid
2 [THS:110] Whip of Erebos 2 [THS:110] Whip of Erebos
1 [F14:2] Elvish Mystic 1 [F14:2] Elvish Mystic
3 [KTK:81] Murderous Cut 3 [KTK:81] Murderous Cut
@ -41,4 +41,4 @@ SB: 2 [KTK:8] End Hostilities
SB: 1 [JOU:66] Doomwake Giant SB: 1 [JOU:66] Doomwake Giant
SB: 1 [C14:213] Reclamation Sage SB: 1 [C14:213] Reclamation Sage
SB: 1 [THS:101] Read the Bones SB: 1 [THS:101] Read the Bones
SB: 1 [MBP:103] Nissa, Worldwaker SB: 1 [M15:187] Nissa, Worldwaker

View file

@ -27,7 +27,7 @@
2 [9ED:322] Llanowar Wastes 2 [9ED:322] Llanowar Wastes
4 [THS:180] Sylvan Caryatid 4 [THS:180] Sylvan Caryatid
1 [ARC:150] Forest 1 [ARC:150] Forest
SB: 1 [MBP:101] Liliana Vess SB: 1 [M15:103] Liliana Vess
SB: 2 [M15:169] Back to Nature SB: 2 [M15:169] Back to Nature
SB: 1 [F14:8] Bile Blight SB: 1 [F14:8] Bile Blight
SB: 2 [BNG:61] Bile Blight SB: 2 [BNG:61] Bile Blight
@ -35,5 +35,5 @@ SB: 1 [C14:158] Read the Bones
SB: 1 [M15:187] Nissa, Worldwaker SB: 1 [M15:187] Nissa, Worldwaker
SB: 1 [KTK:8] End Hostilities SB: 1 [KTK:8] End Hostilities
SB: 2 [KTK:163] Anafenza, the Foremost SB: 2 [KTK:163] Anafenza, the Foremost
SB: 1 [MBP:103] Nissa, Worldwaker SB: 1 [M15:187] Nissa, Worldwaker
SB: 3 [BNG:65] Drown in Sorrow SB: 3 [BNG:65] Drown in Sorrow

View file

@ -19,7 +19,7 @@
1 [SOM:238] Swamp 1 [SOM:238] Swamp
1 [DDO:1] Elspeth, Sun's Champion 1 [DDO:1] Elspeth, Sun's Champion
1 [G09:6] Bloodstained Mire 1 [G09:6] Bloodstained Mire
2 [MBP:98] Goblin Rabblemaster 2 [M15:145] Goblin Rabblemaster
1 [KTK:31] Wingmate Roc 1 [KTK:31] Wingmate Roc
2 [KTK:97] Arc Lightning 2 [KTK:97] Arc Lightning
1 [9ED:320] Caves of Koilos 1 [9ED:320] Caves of Koilos
@ -35,14 +35,14 @@
1 [TPR:262] Mountain 1 [TPR:262] Mountain
SB: 1 [ULG:7] Erase SB: 1 [ULG:7] Erase
SB: 1 [THS:15] Glare of Heresy SB: 1 [THS:15] Glare of Heresy
SB: 1 [MBP:75] Chandra, Pyromaster SB: 1 [M15:134] Chandra, Pyromaster
SB: 2 [THS:112] Anger of the Gods SB: 2 [THS:112] Anger of the Gods
SB: 1 [THS:101] Read the Bones SB: 1 [THS:101] Read the Bones
SB: 1 [KTK:104] Burn Away SB: 1 [KTK:104] Burn Away
SB: 1 [THS:107] Thoughtseize SB: 1 [THS:107] Thoughtseize
SB: 1 [C14:158] Read the Bones SB: 1 [C14:158] Read the Bones
SB: 1 [KTK:186] Mardu Charm SB: 1 [KTK:186] Mardu Charm
SB: 1 [MGDC:38] Utter End SB: 1 [KTK:210] Utter End
SB: 1 [KTK:9] Erase SB: 1 [KTK:9] Erase
SB: 2 [KTK:8] End Hostilities SB: 2 [KTK:8] End Hostilities
SB: 1 [THS:9] Elspeth, Sun's Champion SB: 1 [THS:9] Elspeth, Sun's Champion

View file

@ -19,7 +19,7 @@
1 [ALA:230] Plains 1 [ALA:230] Plains
2 [M10:226] Glacial Fortress 2 [M10:226] Glacial Fortress
1 [M12:227] Glacial Fortress 1 [M12:227] Glacial Fortress
2 [MBP:32] Mirran Crusader 2 [MBS:14] Mirran Crusader
3 [M12:3] Angelic Destiny 3 [M12:3] Angelic Destiny
1 [LRW:34] Oblivion Ring 1 [LRW:34] Oblivion Ring
1 [ZEN:232] Plains 1 [ZEN:232] Plains

View file

@ -2,12 +2,12 @@ NAME:RB Aggro
1 [SOM:242] Mountain 1 [SOM:242] Mountain
1 [INV:344] Mountain 1 [INV:344] Mountain
1 [INV:345] Mountain 1 [INV:345] Mountain
1 [ZEN:263] Mountain 1 [ZEN:242a] Mountain
1 [SHM:294] Mountain 1 [SHM:294] Mountain
1 [ZEN:264] Mountain 1 [ZEN:242a] Mountain
1 [SHM:295] Mountain 1 [SHM:295] Mountain
1 [SHM:296] Mountain 1 [SHM:296] Mountain
1 [ZEN:262] Mountain 1 [ZEN:242a] Mountain
1 [ISD:261] Mountain 1 [ISD:261] Mountain
1 [ISD:260] Mountain 1 [ISD:260] Mountain
1 [AVR:240] Mountain 1 [AVR:240] Mountain
@ -19,7 +19,7 @@ NAME:RB Aggro
1 [M10:245] Mountain 1 [M10:245] Mountain
1 [M10:242] Mountain 1 [M10:242] Mountain
1 [M10:243] Mountain 1 [M10:243] Mountain
1 [PGRU:3] Mountain 1 [PGRU:4] Mountain
1 [MRD:299] Mountain 1 [MRD:299] Mountain
1 [SOM:245] Mountain 1 [SOM:245] Mountain
1 [SOM:244] Mountain 1 [SOM:244] Mountain
@ -67,5 +67,5 @@ NAME:RB Aggro
1 [TSP:295] Mountain 1 [TSP:295] Mountain
1 [TSP:294] Mountain 1 [TSP:294] Mountain
1 [ISD:259] Mountain 1 [ISD:259] Mountain
LAYOUT MAIN:(2,1)(CMC,true,5)|()([PGRU:3],[SHM:296],[AVR:240],[SHM:295],[SHM:294],[TSP:295],[TSP:294],[10E:379],[SOM:245],[ZEN:262],[ZEN:245],[10E:378],[SOM:244],[SOM:243],[ZEN:244],[SOM:242],[ZEN:243],[ZEN:242],[ALA:243],[ALA:242],[M12:245],[CHK:299],[M12:243],[M12:244],[CHK:300],[CHK:301],[M12:242],[CHK:302],[10E:376],[M11:243],[M11:242],[M11:245],[M11:244],[MBS:152],[ALA:244],[ALA:245],[ZEN:263],[ZEN:264],[RAV:301],[RAV:300],[RAV:299],[USG:345],[USG:346],[M10:242],[RAV:302],[USG:343],[USG:344],[ISD:259],[ROE:244],[ISD:261],[ISD:260],[ROE:241],[ROE:242],[ROE:243],[MRD:301],[MRD:300],[MRD:299],[M10:244],[M10:243],[M10:245],[LRW:294],[TMP:343],[LRW:295],[LRW:296],[LRW:297],[TMP:343],[MRD:302],[TMP:343],[TMP:343],[INV:345],[INV:344]) LAYOUT MAIN:(2,1)(CMC,true,5)|()([PGRU:4],[SHM:296],[AVR:240],[SHM:295],[SHM:294],[TSP:295],[TSP:294],[10E:379],[SOM:245],[ZEN:242a],[ZEN:245],[10E:378],[SOM:244],[SOM:243],[ZEN:244],[SOM:242],[ZEN:243],[ZEN:242],[ALA:243],[ALA:242],[M12:245],[CHK:299],[M12:243],[M12:244],[CHK:300],[CHK:301],[M12:242],[CHK:302],[10E:376],[M11:243],[M11:242],[M11:245],[M11:244],[MBS:152],[ALA:244],[ALA:245],[ZEN:242a],[ZEN:242a],[RAV:301],[RAV:300],[RAV:299],[USG:345],[USG:346],[M10:242],[RAV:302],[USG:343],[USG:344],[ISD:259],[ROE:244],[ISD:261],[ISD:260],[ROE:241],[ROE:242],[ROE:243],[MRD:301],[MRD:300],[MRD:299],[M10:244],[M10:243],[M10:245],[LRW:294],[TMP:343],[LRW:295],[LRW:296],[LRW:297],[TMP:343],[MRD:302],[TMP:343],[TMP:343],[INV:345],[INV:344])
LAYOUT SIDEBOARD:(0,0)(COLOR_IDENTITY,true,5)| LAYOUT SIDEBOARD:(0,0)(COLOR_IDENTITY,true,5)|

View file

@ -115,11 +115,12 @@ public final class MtgJson {
if (stream == null) { if (stream == null) {
File file = new File(filename); File file = new File(filename);
if (!file.exists()) { if (!file.exists()) {
System.out.println("Downloading " + filename + " to " + file.getAbsolutePath());
URLConnection connection = new URL("https://mtgjson.com/files/" + filename).openConnection(); URLConnection connection = new URL("https://mtgjson.com/files/" + filename).openConnection();
connection.setRequestProperty("user-agent", "xmage"); connection.setRequestProperty("user-agent", "xmage");
InputStream download = connection.getInputStream(); InputStream download = connection.getInputStream();
Files.copy(download, file.toPath(), StandardCopyOption.REPLACE_EXISTING); Files.copy(download, file.toPath(), StandardCopyOption.REPLACE_EXISTING);
System.out.println("Downloaded " + filename + " to " + file.getAbsolutePath()); System.out.println("Downloading DONE");
} else { } else {
System.out.println("Using " + filename + " from " + file.getAbsolutePath()); System.out.println("Using " + filename + " from " + file.getAbsolutePath());
} }

View file

@ -193,9 +193,10 @@ public class VerifyCardDataTest {
skipListAddName(SKIP_LIST_SCRYFALL_DOWNLOAD_SETS, "SWS"); // Star Wars skipListAddName(SKIP_LIST_SCRYFALL_DOWNLOAD_SETS, "SWS"); // Star Wars
// sample decks checking - some decks can contains unimplemented cards, so ignore it // sample decks checking - some decks can contains unimplemented cards, so ignore it
// file name must be related to sample-decks folder
// for linux/windows build system use paths constructor // for linux/windows build system use paths constructor
skipListCreate(SKIP_LIST_SAMPLE_DECKS); skipListCreate(SKIP_LIST_SAMPLE_DECKS);
skipListAddName(SKIP_LIST_SAMPLE_DECKS, Paths.get("\\Commander\\Commander 2019\\Merciless Rage.dck").toString()); // TODO: delete after Aeon Engine implemented skipListAddName(SKIP_LIST_SAMPLE_DECKS, Paths.get("Commander", "Commander 2019", "Merciless Rage.dck").toString()); // TODO: delete after Aeon Engine implemented
} }
private final ArrayList<String> outputMessages = new ArrayList<>(); private final ArrayList<String> outputMessages = new ArrayList<>();
@ -481,11 +482,19 @@ public class VerifyCardDataTest {
public void test_checkSampleDecks() { public void test_checkSampleDecks() {
Collection<String> errorsList = new ArrayList<>(); Collection<String> errorsList = new ArrayList<>();
// collect all files // workaround to run verify test from IDE or from maven's project root folder
final String rootPath = Paths.get("..\\Mage.Client\\release\\sample-decks").toString(); Path rootPath = Paths.get("Mage.Client", "release", "sample-decks");
if (!Files.exists(rootPath)) {
rootPath = Paths.get("..", "Mage.Client", "release", "sample-decks");
}
if (!Files.exists(rootPath)) {
Assert.fail("Sample decks: unknown root folder " + rootPath.toAbsolutePath().toString());
}
// collect all files in all root's folders
Collection<Path> filesList = new ArrayList<>(); Collection<Path> filesList = new ArrayList<>();
try { try {
Files.walkFileTree(Paths.get(rootPath), new SimpleFileVisitor<Path>() { Files.walkFileTree(rootPath, new SimpleFileVisitor<Path>() {
@Override @Override
public FileVisitResult visitFile(Path file, BasicFileAttributes attrs) throws IOException { public FileVisitResult visitFile(Path file, BasicFileAttributes attrs) throws IOException {
filesList.add(file); filesList.add(file);
@ -496,12 +505,12 @@ public class VerifyCardDataTest {
e.printStackTrace(); e.printStackTrace();
errorsList.add("Error: sample deck - can't get folder content - " + e.getMessage()); errorsList.add("Error: sample deck - can't get folder content - " + e.getMessage());
} }
Assert.assertTrue("Sample decks: can't find any deck files in " + rootPath, filesList.size() > 0); Assert.assertTrue("Sample decks: can't find any deck files in " + rootPath.toAbsolutePath().toString(), filesList.size() > 0);
// try to open deck files // try to open deck files
int totalErrorFiles = 0; int totalErrorFiles = 0;
for (Path deckFile : filesList) { for (Path deckFile : filesList) {
String deckName = deckFile.toString().replace(rootPath, ""); String deckName = rootPath.relativize(deckFile).toString();
if (skipListHaveName(SKIP_LIST_SAMPLE_DECKS, deckName)) { if (skipListHaveName(SKIP_LIST_SAMPLE_DECKS, deckName)) {
continue; continue;
} }