From 2a12e788d528553fe8023ee33049eebc38d3c97b Mon Sep 17 00:00:00 2001 From: Oleg Agafonov Date: Sat, 11 Nov 2017 13:02:49 +0400 Subject: [PATCH 1/9] clean git source --- .../target/maven-archiver/pom.properties | 5 ----- 1 file changed, 5 deletions(-) delete mode 100644 Mage.Server.Plugins/Mage.Game.PennyDreadfulCommanderFreeForAll/target/maven-archiver/pom.properties diff --git a/Mage.Server.Plugins/Mage.Game.PennyDreadfulCommanderFreeForAll/target/maven-archiver/pom.properties b/Mage.Server.Plugins/Mage.Game.PennyDreadfulCommanderFreeForAll/target/maven-archiver/pom.properties deleted file mode 100644 index 8603daf326..0000000000 --- a/Mage.Server.Plugins/Mage.Game.PennyDreadfulCommanderFreeForAll/target/maven-archiver/pom.properties +++ /dev/null @@ -1,5 +0,0 @@ -#Generated by Maven -#Sun Oct 22 00:34:49 EDT 2017 -version=1.4.26 -groupId=org.mage -artifactId=mage-game-pennydreadfulcommanderfreeforall From badaed63cb2846a9dec7cbdfba041f961288c34d Mon Sep 17 00:00:00 2001 From: Oleg Agafonov Date: Sun, 12 Nov 2017 02:06:24 +0400 Subject: [PATCH 2/9] fix #4148 error on downloading double faces cards from scryfall --- .../card/dl/sources/ScryfallImageSource.java | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/Mage.Client/src/main/java/org/mage/plugins/card/dl/sources/ScryfallImageSource.java b/Mage.Client/src/main/java/org/mage/plugins/card/dl/sources/ScryfallImageSource.java index 759a9bdacf..b95cc3fefd 100644 --- a/Mage.Client/src/main/java/org/mage/plugins/card/dl/sources/ScryfallImageSource.java +++ b/Mage.Client/src/main/java/org/mage/plugins/card/dl/sources/ScryfallImageSource.java @@ -214,10 +214,18 @@ public enum ScryfallImageSource implements CardImageSource { @Override public String generateURL(CardDownloadData card) throws Exception { - return "https://api.scryfall.com/cards/" + formatSetName(card.getSet()) + "/" - + card.getCollectorId() - + (card.isSecondSide() ? "b" : "") - + "?format=image"; + + if (card.isTwoFacedCard()) { + // double faced cards do not supporte by API (need direct link for img) + // example: https://img.scryfall.com/cards/large/en/xln/173b.jpg + return "https://img.scryfall.com/cards/large/en/" + formatSetName(card.getSet()) + "/" + + card.getCollectorId() + (card.isSecondSide() ? "b" : "a") + ".jpg"; + }else { + // single face cards support by single API call (redirect to img link) + // example: https://api.scryfall.com/cards/xln/121?format=image + return "https://api.scryfall.com/cards/" + formatSetName(card.getSet()) + "/" + + card.getCollectorId() + "?format=image"; + } } @Override From 9b95e20d83270b34525ac30fd6fea557a23ffd55 Mon Sep 17 00:00:00 2001 From: Oleg Agafonov Date: Sun, 12 Nov 2017 06:16:29 +0400 Subject: [PATCH 3/9] Fix error on download images of Ixalan set from Wizards site --- .../org/mage/plugins/card/dl/sources/WizardCardsImageSource.java | 1 + 1 file changed, 1 insertion(+) diff --git a/Mage.Client/src/main/java/org/mage/plugins/card/dl/sources/WizardCardsImageSource.java b/Mage.Client/src/main/java/org/mage/plugins/card/dl/sources/WizardCardsImageSource.java index 5ea83188bf..f5b83c9779 100644 --- a/Mage.Client/src/main/java/org/mage/plugins/card/dl/sources/WizardCardsImageSource.java +++ b/Mage.Client/src/main/java/org/mage/plugins/card/dl/sources/WizardCardsImageSource.java @@ -451,6 +451,7 @@ public enum WizardCardsImageSource implements CardImageSource { setsAliases.put("WMCQ", "World Magic Cup Qualifier"); setsAliases.put("WTH", "Weatherlight"); setsAliases.put("WWK", "Worldwake"); + setsAliases.put("XLN", "Ixalan"); setsAliases.put("ZEN", "Zendikar"); languageAliases = new HashMap<>(); From b97edec5b98a2ba779ef0eef0f942d663f4febcf Mon Sep 17 00:00:00 2001 From: Oleg Agafonov Date: Sun, 12 Nov 2017 07:34:45 +0400 Subject: [PATCH 4/9] Fix error on download backside.jpg symbol --- .../mage/plugins/card/dl/sources/DirectLinksForDownload.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Mage.Client/src/main/java/org/mage/plugins/card/dl/sources/DirectLinksForDownload.java b/Mage.Client/src/main/java/org/mage/plugins/card/dl/sources/DirectLinksForDownload.java index 0ab60ad086..374257a693 100644 --- a/Mage.Client/src/main/java/org/mage/plugins/card/dl/sources/DirectLinksForDownload.java +++ b/Mage.Client/src/main/java/org/mage/plugins/card/dl/sources/DirectLinksForDownload.java @@ -22,7 +22,7 @@ import static org.mage.plugins.card.dl.DownloadJob.toFile; */ public class DirectLinksForDownload implements Iterable { - private static final String backsideUrl = "http://upload.wikimedia.org/wikipedia/en/a/aa/Magic_the_gathering-card_back.jpg"; + private static final String backsideUrl = "https://upload.wikimedia.org/wikipedia/en/a/aa/Magic_the_gathering-card_back.jpg"; private static final Map directLinks = new LinkedHashMap<>(); From 12b420d68b697e862e1cee472dcbcf50bac9f558 Mon Sep 17 00:00:00 2001 From: Oleg Agafonov Date: Wed, 15 Nov 2017 00:09:31 +0400 Subject: [PATCH 5/9] Add new logs and checks in symbols download (for easy setup and fix settings) --- .../plugins/card/dl/sources/GathererSets.java | 66 ++++++++++++++++++- 1 file changed, 65 insertions(+), 1 deletion(-) diff --git a/Mage.Client/src/main/java/org/mage/plugins/card/dl/sources/GathererSets.java b/Mage.Client/src/main/java/org/mage/plugins/card/dl/sources/GathererSets.java index 41a6fb93dc..e3a117a51b 100644 --- a/Mage.Client/src/main/java/org/mage/plugins/card/dl/sources/GathererSets.java +++ b/Mage.Client/src/main/java/org/mage/plugins/card/dl/sources/GathererSets.java @@ -9,11 +9,15 @@ import java.util.Iterator; import mage.cards.ExpansionSet; import mage.cards.Sets; import org.mage.plugins.card.dl.DownloadJob; + import static org.mage.plugins.card.dl.DownloadJob.fromURL; import static org.mage.plugins.card.dl.DownloadJob.toFile; +import org.apache.log4j.Logger; public class GathererSets implements Iterable { + private static final Logger logger = Logger.getLogger(GathererSets.class); + private static final String SETS_PATH = File.separator + "sets"; private static final File DEFAULT_OUT_DIR = new File("plugins" + File.separator + "images" + SETS_PATH); private static File outDir = DEFAULT_OUT_DIR; @@ -60,6 +64,8 @@ public class GathererSets implements Iterable { "SOI", "EMN", "KLD", "AER", "AKH", "HOU", + "XLN", "C17", + "RIX", "DOM", "M19", // not released "E01" }; @@ -105,7 +111,7 @@ public class GathererSets implements Iterable { symbolsReplacements.put("PCY", "PR"); symbolsReplacements.put("PLS", "PS"); symbolsReplacements.put("POR", "PO"); - symbolsReplacements.put("PO2", "P2"); + symbolsReplacements.put("P02", "P2"); symbolsReplacements.put("PTK", "PK"); symbolsReplacements.put("STH", "ST"); symbolsReplacements.put("TMP", "TE"); @@ -124,6 +130,42 @@ public class GathererSets implements Iterable { } } + // checks for wrong card settings and support (easy to control what all good) + private static final HashMap setsToDonwload = new HashMap<>(); + + private void CheckSearchResult(String searchCode, ExpansionSet foundedExp, boolean canDownloadTask){ + + // duplicated in settings + ExpansionSet existsExp = setsToDonwload.get(searchCode); + if (existsExp != null) { + logger.error(String.format("Symbols: founded duplicated code: %s", searchCode)); + } else { + setsToDonwload.put(searchCode, foundedExp); + } + + // not found + if (foundedExp == null) { + logger.error(String.format("Symbols: can't find set by code: %s", searchCode)); + return; + } + + // checks for founded sets only + + // to early to download + if (!canDownloadTask){ + logger.warn(String.format("Symbols: early to download, set is not released: %s (%s) after %s", searchCode, foundedExp.getName(), foundedExp.getReleaseDate())); + } + } + + private void AnalyseSearchResult(){ + // analyze supported sets and show wrong settings (who without symbol settings) + for (ExpansionSet set : Sets.getInstance().values()) { + if (setsToDonwload.get(set.getCode()) == null) { + logger.warn(String.format("Symbols: set is not configured: %s (%s)", set.getCode(), set.getName())); + } + } + } + @Override public Iterator iterator() { Calendar c = Calendar.getInstance(); @@ -131,35 +173,57 @@ public class GathererSets implements Iterable { c.add(Calendar.DATE, +14); // Try to load the symbols eralies 14 days before release date Date compareDate = c.getTime(); ArrayList jobs = new ArrayList<>(); + boolean canDownload = false; + + setsToDonwload.clear(); + for (String symbol : symbols) { ExpansionSet exp = Sets.findSet(symbol); + canDownload = false; if (exp != null && exp.getReleaseDate().before(compareDate)) { + canDownload = true; jobs.add(generateDownloadJob(symbol, "C", "C")); jobs.add(generateDownloadJob(symbol, "U", "U")); jobs.add(generateDownloadJob(symbol, "R", "R")); } + CheckSearchResult(symbol, exp, canDownload); } + for (String symbol : withMythics) { ExpansionSet exp = Sets.findSet(symbol); + canDownload = false; if (exp != null && exp.getReleaseDate().before(compareDate)) { + canDownload = true; jobs.add(generateDownloadJob(symbol, "C", "C")); jobs.add(generateDownloadJob(symbol, "U", "U")); jobs.add(generateDownloadJob(symbol, "R", "R")); jobs.add(generateDownloadJob(symbol, "M", "M")); } + CheckSearchResult(symbol, exp, canDownload); } + for (String symbol : onlyMythics) { ExpansionSet exp = Sets.findSet(symbol); + canDownload = false; if (exp != null && exp.getReleaseDate().before(compareDate)) { + canDownload = true; jobs.add(generateDownloadJob(symbol, "M", "M")); } } + for (String symbol : onlyMythicsAsSpecial) { ExpansionSet exp = Sets.findSet(symbol); + canDownload = false; if (exp != null && exp.getReleaseDate().before(compareDate)) { + canDownload = true; jobs.add(generateDownloadJob(symbol, "M", "S")); } + CheckSearchResult(symbol, exp, canDownload); } + + // check wrong settings + AnalyseSearchResult(); + return jobs.iterator(); } From 080b4fc1a2a876d9fd761a32001e4a94008b825d Mon Sep 17 00:00:00 2001 From: Oleg Agafonov Date: Wed, 15 Nov 2017 01:44:10 +0400 Subject: [PATCH 6/9] Add new logs and checks in symbols download (for easy setup and fix settings) --- .../plugins/card/dl/sources/GathererSets.java | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/Mage.Client/src/main/java/org/mage/plugins/card/dl/sources/GathererSets.java b/Mage.Client/src/main/java/org/mage/plugins/card/dl/sources/GathererSets.java index e3a117a51b..1e1305f1a6 100644 --- a/Mage.Client/src/main/java/org/mage/plugins/card/dl/sources/GathererSets.java +++ b/Mage.Client/src/main/java/org/mage/plugins/card/dl/sources/GathererSets.java @@ -16,6 +16,7 @@ import org.apache.log4j.Logger; public class GathererSets implements Iterable { + private static final int DAYS_BEFORE_RELEASE_TO_DOWNLOAD = +14; // Try to load the symbols eralies 14 days before release date private static final Logger logger = Logger.getLogger(GathererSets.class); private static final String SETS_PATH = File.separator + "sets"; @@ -40,7 +41,7 @@ public class GathererSets implements Iterable { "LRW", "MOR", "SHM", "EVE", "MED", "ME2", "ME3", "ME4", - "POR", "PO2", "PTK", + "POR", "P02", "PTK", "ARC", "DD3EVG", "W16", "W17"}; @@ -153,13 +154,18 @@ public class GathererSets implements Iterable { // to early to download if (!canDownloadTask){ - logger.warn(String.format("Symbols: early to download, set is not released: %s (%s) after %s", searchCode, foundedExp.getName(), foundedExp.getReleaseDate())); + Calendar c = Calendar.getInstance(); + c.setTime(foundedExp.getReleaseDate()); + c.add(Calendar.DATE, -1 * DAYS_BEFORE_RELEASE_TO_DOWNLOAD); + logger.warn(String.format("Symbols: early to download: %s (%s), available after %s", + searchCode, foundedExp.getName(), c.getTime())); } } private void AnalyseSearchResult(){ - // analyze supported sets and show wrong settings (who without symbol settings) + // analyze supported sets and show wrong settings for (ExpansionSet set : Sets.getInstance().values()) { + // not configured at all if (setsToDonwload.get(set.getCode()) == null) { logger.warn(String.format("Symbols: set is not configured: %s (%s)", set.getCode(), set.getName())); } @@ -170,7 +176,7 @@ public class GathererSets implements Iterable { public Iterator iterator() { Calendar c = Calendar.getInstance(); c.setTime(new Date()); - c.add(Calendar.DATE, +14); // Try to load the symbols eralies 14 days before release date + c.add(Calendar.DATE, DAYS_BEFORE_RELEASE_TO_DOWNLOAD); Date compareDate = c.getTime(); ArrayList jobs = new ArrayList<>(); boolean canDownload = false; @@ -209,6 +215,7 @@ public class GathererSets implements Iterable { canDownload = true; jobs.add(generateDownloadJob(symbol, "M", "M")); } + CheckSearchResult(symbol, exp, canDownload); } for (String symbol : onlyMythicsAsSpecial) { From 45aad8b6bc915379e9bbcebc1365b0ce770b7247 Mon Sep 17 00:00:00 2001 From: Oleg Agafonov Date: Wed, 15 Nov 2017 02:43:38 +0400 Subject: [PATCH 7/9] add new checks for symbol download --- .../plugins/card/dl/sources/GathererSets.java | 77 +++++++++++++++---- 1 file changed, 64 insertions(+), 13 deletions(-) diff --git a/Mage.Client/src/main/java/org/mage/plugins/card/dl/sources/GathererSets.java b/Mage.Client/src/main/java/org/mage/plugins/card/dl/sources/GathererSets.java index 1e1305f1a6..6f81effd83 100644 --- a/Mage.Client/src/main/java/org/mage/plugins/card/dl/sources/GathererSets.java +++ b/Mage.Client/src/main/java/org/mage/plugins/card/dl/sources/GathererSets.java @@ -6,8 +6,10 @@ import java.util.Calendar; import java.util.Date; import java.util.HashMap; import java.util.Iterator; + import mage.cards.ExpansionSet; import mage.cards.Sets; +import mage.constants.Rarity; import org.mage.plugins.card.dl.DownloadJob; import static org.mage.plugins.card.dl.DownloadJob.fromURL; @@ -16,6 +18,24 @@ import org.apache.log4j.Logger; public class GathererSets implements Iterable { + private class CheckResult { + String code; + ExpansionSet set; + boolean haveCommon; + boolean haveUncommon; + boolean haveRare; + boolean haveMyth; + + private CheckResult(String ACode, ExpansionSet ASet, boolean AHaveCommon, boolean AHaveUncommon, boolean AHhaveRare, boolean AHaveMyth) { + code = ACode; + set = ASet; + haveCommon = AHaveCommon; + haveUncommon = AHaveUncommon; + haveRare = AHhaveRare; + haveMyth = AHaveMyth; + } + } + private static final int DAYS_BEFORE_RELEASE_TO_DOWNLOAD = +14; // Try to load the symbols eralies 14 days before release date private static final Logger logger = Logger.getLogger(GathererSets.class); @@ -132,16 +152,18 @@ public class GathererSets implements Iterable { } // checks for wrong card settings and support (easy to control what all good) - private static final HashMap setsToDonwload = new HashMap<>(); - - private void CheckSearchResult(String searchCode, ExpansionSet foundedExp, boolean canDownloadTask){ + private static final HashMap setsToDonwload = new HashMap<>(); + private void CheckSearchResult(String searchCode, ExpansionSet foundedExp, boolean canDownloadTask, + boolean haveCommon, boolean haveUncommon, boolean haveRare, boolean haveMyth){ // duplicated in settings - ExpansionSet existsExp = setsToDonwload.get(searchCode); - if (existsExp != null) { + CheckResult res = setsToDonwload.get(searchCode); + + if (res != null) { logger.error(String.format("Symbols: founded duplicated code: %s", searchCode)); } else { - setsToDonwload.put(searchCode, foundedExp); + res = new CheckResult(searchCode, foundedExp, haveCommon, haveUncommon, haveRare, haveMyth); + setsToDonwload.put(searchCode, res); } // not found @@ -164,12 +186,41 @@ public class GathererSets implements Iterable { private void AnalyseSearchResult(){ // analyze supported sets and show wrong settings + Date startedDate = new Date(); + for (ExpansionSet set : Sets.getInstance().values()) { - // not configured at all - if (setsToDonwload.get(set.getCode()) == null) { + + CheckResult res = setsToDonwload.get(set.getCode()); + + // 1. not configured at all + if (res == null) { logger.warn(String.format("Symbols: set is not configured: %s (%s)", set.getCode(), set.getName())); + continue; // can't do other checks + } + + // 2. do not load needed card rarity: + // - simple check for base type, not all + // - when card not implemented then download is not necessary + // WARNING, need too much time (60+ secs), only for debug mode, may be move to tests? + if (logger.isDebugEnabled()) { + if ((set.getCardsByRarity(Rarity.COMMON).size() > 0) && !res.haveCommon) { + logger.error(String.format("Symbols: set have common cards, but don't download icon: %s (%s)", set.getCode(), set.getName())); + } + if ((set.getCardsByRarity(Rarity.UNCOMMON).size() > 0) && !res.haveUncommon) { + logger.error(String.format("Symbols: set have uncommon cards, but don't download icon: %s (%s)", set.getCode(), set.getName())); + } + if ((set.getCardsByRarity(Rarity.RARE).size() > 0) && !res.haveRare) { + logger.error(String.format("Symbols: set have rare cards, but don't download icon: %s (%s)", set.getCode(), set.getName())); + } + if ((set.getCardsByRarity(Rarity.MYTHIC).size() > 0) && !res.haveMyth) { + logger.error(String.format("Symbols: set have mythic cards, but don't download icon: %s (%s)", set.getCode(), set.getName())); + } } } + + Date endedDate = new Date(); + long secs = (endedDate.getTime() - startedDate.getTime()) / 1000; + logger.debug(String.format("Symbols: check time: %d seconds", secs)); } @Override @@ -179,7 +230,7 @@ public class GathererSets implements Iterable { c.add(Calendar.DATE, DAYS_BEFORE_RELEASE_TO_DOWNLOAD); Date compareDate = c.getTime(); ArrayList jobs = new ArrayList<>(); - boolean canDownload = false; + boolean canDownload; setsToDonwload.clear(); @@ -192,7 +243,7 @@ public class GathererSets implements Iterable { jobs.add(generateDownloadJob(symbol, "U", "U")); jobs.add(generateDownloadJob(symbol, "R", "R")); } - CheckSearchResult(symbol, exp, canDownload); + CheckSearchResult(symbol, exp, canDownload, true, true, true, false); } for (String symbol : withMythics) { @@ -205,7 +256,7 @@ public class GathererSets implements Iterable { jobs.add(generateDownloadJob(symbol, "R", "R")); jobs.add(generateDownloadJob(symbol, "M", "M")); } - CheckSearchResult(symbol, exp, canDownload); + CheckSearchResult(symbol, exp, canDownload, true, true, true, true); } for (String symbol : onlyMythics) { @@ -215,7 +266,7 @@ public class GathererSets implements Iterable { canDownload = true; jobs.add(generateDownloadJob(symbol, "M", "M")); } - CheckSearchResult(symbol, exp, canDownload); + CheckSearchResult(symbol, exp, canDownload, false, false, false, true); } for (String symbol : onlyMythicsAsSpecial) { @@ -225,7 +276,7 @@ public class GathererSets implements Iterable { canDownload = true; jobs.add(generateDownloadJob(symbol, "M", "S")); } - CheckSearchResult(symbol, exp, canDownload); + CheckSearchResult(symbol, exp, canDownload, false, false, false, true); } // check wrong settings From feb53492e64326b5a6665f2eed7918cc5bf5c723 Mon Sep 17 00:00:00 2001 From: Oleg Agafonov Date: Wed, 15 Nov 2017 20:10:17 +0400 Subject: [PATCH 8/9] Add new checks for symbol download settings Fix error on download some symbols --- .../plugins/card/dl/sources/GathererSets.java | 131 ++++++++++-------- 1 file changed, 74 insertions(+), 57 deletions(-) diff --git a/Mage.Client/src/main/java/org/mage/plugins/card/dl/sources/GathererSets.java b/Mage.Client/src/main/java/org/mage/plugins/card/dl/sources/GathererSets.java index 6f81effd83..0d174ceed0 100644 --- a/Mage.Client/src/main/java/org/mage/plugins/card/dl/sources/GathererSets.java +++ b/Mage.Client/src/main/java/org/mage/plugins/card/dl/sources/GathererSets.java @@ -36,14 +36,14 @@ public class GathererSets implements Iterable { } } - private static final int DAYS_BEFORE_RELEASE_TO_DOWNLOAD = +14; // Try to load the symbols eralies 14 days before release date + private static final int DAYS_BEFORE_RELEASE_TO_DOWNLOAD = +14; // Try to load the symbolsBasic eralies 14 days before release date private static final Logger logger = Logger.getLogger(GathererSets.class); private static final String SETS_PATH = File.separator + "sets"; private static final File DEFAULT_OUT_DIR = new File("plugins" + File.separator + "images" + SETS_PATH); private static File outDir = DEFAULT_OUT_DIR; - private static final String[] symbols = {"10E", "9ED", "8ED", "7ED", "6ED", "5ED", "4ED", "3ED", "2ED", "LEB", "LEA", + private static final String[] symbolsBasic = {"10E", "9ED", "8ED", "7ED", "6ED", "5ED", "4ED", "3ED", "2ED", "LEB", "LEA", "HOP", "ARN", "ATQ", "LEG", "DRK", "FEM", "HML", "ICE", "ALL", "CSP", @@ -63,12 +63,15 @@ public class GathererSets implements Iterable { "MED", "ME2", "ME3", "ME4", "POR", "P02", "PTK", "ARC", "DD3EVG", - "W16", "W17"}; + "W16", "W17", + "APAC", "ARENA", "CHR", "CLASH", "CP", "DD3GVL", "DPA", "EURO", "FNMP", "GPX", "GRC", "GUR", "H17", "JR", "MBP", "MGDC", "MLP", "MPRP", "MPS-AKH", "PTC", "S00", "S99", "SUS", "SWS", "UGIN", "UGL", "V10", "V17", "WMCQ", // need to fix + "H09", "PD2", "PD3", "UNH", "CM1", "E02", "V11", "M25", "UST", "IMA", "DD2", "EVG", "DDC", "DDE", "DDD", "DDT", "8EB", "9EB" // ok + // current testing + }; - private static final String[] withMythics = {"M10", "M11", "M12", "M13", "M14", "M15", "ORI", - "ANB", + private static final String[] symbolsBasicWithMyth = {"M10", "M11", "M12", "M13", "M14", "M15", "ORI", "DDF", "DDG", "DDH", "DDI", "DDJ", "DDK", "DDL", "DDM", "DDN", - "DD3DVD", "DD3GLV", "DD3JVC", "DDO", "DDP", "DDQ", "DDR", "DDS", + "DD3DVD", "DD3JVC", "DDO", "DDP", "DDQ", "DDR", "DDS", "ALA", "CON", "ARB", "ZEN", "WWK", "ROE", "SOM", "MBS", "NPH", @@ -90,57 +93,58 @@ public class GathererSets implements Iterable { "E01" }; - private static final String[] onlyMythics = { - "DRB", "V09", "V12", "V12", "V13", "V14", "V15", "V16", "EXP" + private static final String[] symbolsOnlyMyth = { + "DRB", "V09", "V12", "V13", "V14", "V15", "V16", "EXP" }; - private static final String[] onlyMythicsAsSpecial = { + private static final String[] symbolsOnlySpecial = { "MPS" }; - private static final HashMap symbolsReplacements = new HashMap<>(); + private static final HashMap codeReplacements = new HashMap<>(); static { - symbolsReplacements.put("2ED", "2U"); - symbolsReplacements.put("3ED", "3E"); - symbolsReplacements.put("4ED", "4E"); - symbolsReplacements.put("5ED", "5E"); - symbolsReplacements.put("6ED", "6E"); - symbolsReplacements.put("7ED", "7E"); - symbolsReplacements.put("ALL", "AL"); - symbolsReplacements.put("APC", "AP"); - symbolsReplacements.put("ARN", "AN"); - symbolsReplacements.put("ATQ", "AQ"); - symbolsReplacements.put("CMA", "CM1"); - symbolsReplacements.put("DD3DVD", "DD3_DVD"); - symbolsReplacements.put("DD3EVG", "DD3_EVG"); - symbolsReplacements.put("DD3GLV", "DD3_GLV"); - symbolsReplacements.put("DD3JVC", "DD3_JVC"); - symbolsReplacements.put("DRK", "DK"); - symbolsReplacements.put("EXO", "EX"); - symbolsReplacements.put("FEM", "FE"); - symbolsReplacements.put("HML", "HM"); - symbolsReplacements.put("ICE", "IA"); - symbolsReplacements.put("INV", "IN"); - symbolsReplacements.put("LEA", "1E"); - symbolsReplacements.put("LEB", "2E"); - symbolsReplacements.put("LEG", "LE"); - symbolsReplacements.put("MPS", "MPS_KLD"); - symbolsReplacements.put("MIR", "MI"); - symbolsReplacements.put("MMQ", "MM"); - symbolsReplacements.put("NEM", "NE"); - symbolsReplacements.put("ODY", "OD"); - symbolsReplacements.put("PCY", "PR"); - symbolsReplacements.put("PLS", "PS"); - symbolsReplacements.put("POR", "PO"); - symbolsReplacements.put("P02", "P2"); - symbolsReplacements.put("PTK", "PK"); - symbolsReplacements.put("STH", "ST"); - symbolsReplacements.put("TMP", "TE"); - symbolsReplacements.put("UDS", "CG"); - symbolsReplacements.put("ULG", "GU"); - symbolsReplacements.put("USG", "UZ"); - symbolsReplacements.put("VIS", "VI"); - symbolsReplacements.put("WTH", "WL"); + codeReplacements.put("2ED", "2U"); + codeReplacements.put("3ED", "3E"); + codeReplacements.put("4ED", "4E"); + codeReplacements.put("5ED", "5E"); + codeReplacements.put("6ED", "6E"); + codeReplacements.put("7ED", "7E"); + codeReplacements.put("ALL", "AL"); + codeReplacements.put("APC", "AP"); + codeReplacements.put("ARN", "AN"); + codeReplacements.put("ATQ", "AQ"); + codeReplacements.put("CMA", "CM1"); + codeReplacements.put("DD3DVD", "DD3_DVD"); + codeReplacements.put("DD3EVG", "DD3_EVG"); + codeReplacements.put("DD3JVC", "DD3_JVC"); + codeReplacements.put("DRK", "DK"); + codeReplacements.put("EXO", "EX"); + codeReplacements.put("FEM", "FE"); + codeReplacements.put("HML", "HM"); + codeReplacements.put("ICE", "IA"); + codeReplacements.put("INV", "IN"); + codeReplacements.put("LEA", "1E"); + codeReplacements.put("LEB", "2E"); + codeReplacements.put("LEG", "LE"); + codeReplacements.put("MPS", "MPS_KLD"); + codeReplacements.put("MIR", "MI"); + codeReplacements.put("MMQ", "MM"); + codeReplacements.put("NEM", "NE"); + codeReplacements.put("ODY", "OD"); + codeReplacements.put("PCY", "PR"); + codeReplacements.put("PLS", "PS"); + codeReplacements.put("POR", "PO"); + codeReplacements.put("P02", "P2"); + codeReplacements.put("PTK", "PK"); + codeReplacements.put("STH", "ST"); + codeReplacements.put("TMP", "TE"); + codeReplacements.put("UDS", "CG"); + codeReplacements.put("ULG", "GU"); + codeReplacements.put("USG", "UZ"); + codeReplacements.put("VIS", "VI"); + codeReplacements.put("WTH", "WL"); + codeReplacements.put("8EB", "8ED"); // inner xmage set for 8th edition + codeReplacements.put("9EB", "8ED"); // inner xmage set for 9th edition } public GathererSets(String path) { @@ -153,6 +157,14 @@ public class GathererSets implements Iterable { // checks for wrong card settings and support (easy to control what all good) private static final HashMap setsToDonwload = new HashMap<>(); + private static final HashMap codesToIgnoreCheck = new HashMap<>(); + static { + // xMage have inner sets for 8th and 9th Edition for booster workaround (cards from core game do not include in boosters) + // see https://mtg.gamepedia.com/8th_Edition/Core_Game + // check must ignore that sets + //codesToIgnoreCheck.put("8EB", "8th Edition Box"); + //codesToIgnoreCheck.put("9EB", "9th Edition Box"); + } private void CheckSearchResult(String searchCode, ExpansionSet foundedExp, boolean canDownloadTask, boolean haveCommon, boolean haveUncommon, boolean haveRare, boolean haveMyth){ @@ -190,6 +202,11 @@ public class GathererSets implements Iterable { for (ExpansionSet set : Sets.getInstance().values()) { + // ignore some inner sets + if (codesToIgnoreCheck.get(set.getCode()) != null){ + continue; + } + CheckResult res = setsToDonwload.get(set.getCode()); // 1. not configured at all @@ -234,7 +251,7 @@ public class GathererSets implements Iterable { setsToDonwload.clear(); - for (String symbol : symbols) { + for (String symbol : symbolsBasic) { ExpansionSet exp = Sets.findSet(symbol); canDownload = false; if (exp != null && exp.getReleaseDate().before(compareDate)) { @@ -246,7 +263,7 @@ public class GathererSets implements Iterable { CheckSearchResult(symbol, exp, canDownload, true, true, true, false); } - for (String symbol : withMythics) { + for (String symbol : symbolsBasicWithMyth) { ExpansionSet exp = Sets.findSet(symbol); canDownload = false; if (exp != null && exp.getReleaseDate().before(compareDate)) { @@ -259,7 +276,7 @@ public class GathererSets implements Iterable { CheckSearchResult(symbol, exp, canDownload, true, true, true, true); } - for (String symbol : onlyMythics) { + for (String symbol : symbolsOnlyMyth) { ExpansionSet exp = Sets.findSet(symbol); canDownload = false; if (exp != null && exp.getReleaseDate().before(compareDate)) { @@ -269,7 +286,7 @@ public class GathererSets implements Iterable { CheckSearchResult(symbol, exp, canDownload, false, false, false, true); } - for (String symbol : onlyMythicsAsSpecial) { + for (String symbol : symbolsOnlySpecial) { ExpansionSet exp = Sets.findSet(symbol); canDownload = false; if (exp != null && exp.getReleaseDate().before(compareDate)) { @@ -287,8 +304,8 @@ public class GathererSets implements Iterable { private DownloadJob generateDownloadJob(String set, String rarity, String urlRarity) { File dst = new File(outDir, set + '-' + rarity + ".jpg"); - if (symbolsReplacements.containsKey(set)) { - set = symbolsReplacements.get(set); + if (codeReplacements.containsKey(set)) { + set = codeReplacements.get(set); } String url = "http://gatherer.wizards.com/Handlers/Image.ashx?type=symbol&set=" + set + "&size=small&rarity=" + urlRarity; return new DownloadJob(set + '-' + rarity, fromURL(url), toFile(dst)); From b53d57bce9030de36f358104dc80ccb906b91990 Mon Sep 17 00:00:00 2001 From: Oleg Agafonov Date: Wed, 15 Nov 2017 21:21:36 +0400 Subject: [PATCH 9/9] Fix error on download some symbols --- .../plugins/card/dl/sources/GathererSets.java | 29 ++++++++++--------- 1 file changed, 15 insertions(+), 14 deletions(-) diff --git a/Mage.Client/src/main/java/org/mage/plugins/card/dl/sources/GathererSets.java b/Mage.Client/src/main/java/org/mage/plugins/card/dl/sources/GathererSets.java index 0d174ceed0..496768a6cf 100644 --- a/Mage.Client/src/main/java/org/mage/plugins/card/dl/sources/GathererSets.java +++ b/Mage.Client/src/main/java/org/mage/plugins/card/dl/sources/GathererSets.java @@ -64,8 +64,10 @@ public class GathererSets implements Iterable { "POR", "P02", "PTK", "ARC", "DD3EVG", "W16", "W17", - "APAC", "ARENA", "CHR", "CLASH", "CP", "DD3GVL", "DPA", "EURO", "FNMP", "GPX", "GRC", "GUR", "H17", "JR", "MBP", "MGDC", "MLP", "MPRP", "MPS-AKH", "PTC", "S00", "S99", "SUS", "SWS", "UGIN", "UGL", "V10", "V17", "WMCQ", // need to fix - "H09", "PD2", "PD3", "UNH", "CM1", "E02", "V11", "M25", "UST", "IMA", "DD2", "EVG", "DDC", "DDE", "DDD", "DDT", "8EB", "9EB" // ok + //"APAC" -- gatherer do not have that set, scrly have PALP + //"ARENA" -- is't many set with different codes, not one + "CLASH", "CP", "DD3GVL", "DPA", "EURO", "FNMP", "GPX", "GRC", "GUR", "H17", "JR", "MBP", "MGDC", "MLP", "MPRP", "MPS-AKH", "PTC", "S00", "S99", "SUS", "SWS", "UGIN", "UGL", "V10", "V17", "WMCQ", // need to fix + "H09", "PD2", "PD3", "UNH", "CM1", "E02", "V11", "M25", "UST", "IMA", "DD2", "EVG", "DDC", "DDE", "DDD", "DDT", "8EB", "9EB", "CHR" // ok // current testing }; @@ -145,6 +147,7 @@ public class GathererSets implements Iterable { codeReplacements.put("WTH", "WL"); codeReplacements.put("8EB", "8ED"); // inner xmage set for 8th edition codeReplacements.put("9EB", "8ED"); // inner xmage set for 9th edition + codeReplacements.put("CHR", "CH"); } public GathererSets(String path) { @@ -156,26 +159,26 @@ public class GathererSets implements Iterable { } // checks for wrong card settings and support (easy to control what all good) - private static final HashMap setsToDonwload = new HashMap<>(); + private static final HashMap setsToDownload = new HashMap<>(); private static final HashMap codesToIgnoreCheck = new HashMap<>(); static { // xMage have inner sets for 8th and 9th Edition for booster workaround (cards from core game do not include in boosters) // see https://mtg.gamepedia.com/8th_Edition/Core_Game // check must ignore that sets - //codesToIgnoreCheck.put("8EB", "8th Edition Box"); - //codesToIgnoreCheck.put("9EB", "9th Edition Box"); + codesToIgnoreCheck.put("8EB", "8th Edition Box"); + codesToIgnoreCheck.put("9EB", "9th Edition Box"); } private void CheckSearchResult(String searchCode, ExpansionSet foundedExp, boolean canDownloadTask, boolean haveCommon, boolean haveUncommon, boolean haveRare, boolean haveMyth){ // duplicated in settings - CheckResult res = setsToDonwload.get(searchCode); + CheckResult res = setsToDownload.get(searchCode); if (res != null) { logger.error(String.format("Symbols: founded duplicated code: %s", searchCode)); } else { res = new CheckResult(searchCode, foundedExp, haveCommon, haveUncommon, haveRare, haveMyth); - setsToDonwload.put(searchCode, res); + setsToDownload.put(searchCode, res); } // not found @@ -207,7 +210,7 @@ public class GathererSets implements Iterable { continue; } - CheckResult res = setsToDonwload.get(set.getCode()); + CheckResult res = setsToDownload.get(set.getCode()); // 1. not configured at all if (res == null) { @@ -215,10 +218,8 @@ public class GathererSets implements Iterable { continue; // can't do other checks } - // 2. do not load needed card rarity: - // - simple check for base type, not all - // - when card not implemented then download is not necessary - // WARNING, need too much time (60+ secs), only for debug mode, may be move to tests? + // 2. missing rarity icon: + // WARNING, need too much time (60+ secs), only for debug mode if (logger.isDebugEnabled()) { if ((set.getCardsByRarity(Rarity.COMMON).size() > 0) && !res.haveCommon) { logger.error(String.format("Symbols: set have common cards, but don't download icon: %s (%s)", set.getCode(), set.getName())); @@ -237,7 +238,7 @@ public class GathererSets implements Iterable { Date endedDate = new Date(); long secs = (endedDate.getTime() - startedDate.getTime()) / 1000; - logger.debug(String.format("Symbols: check time: %d seconds", secs)); + logger.debug(String.format("Symbols: check completed after %d seconds", secs)); } @Override @@ -249,7 +250,7 @@ public class GathererSets implements Iterable { ArrayList jobs = new ArrayList<>(); boolean canDownload; - setsToDonwload.clear(); + setsToDownload.clear(); for (String symbol : symbolsBasic) { ExpansionSet exp = Sets.findSet(symbol);