This commit is contained in:
betasteward 2015-03-01 22:03:28 -05:00
commit 1276b1c91c
9 changed files with 277 additions and 210 deletions

View file

@ -27,7 +27,7 @@ public class ConstructedFormats {
private static final String[] constructedFormats = {
ALL, STANDARD, EXTENDED, MODERN,
"* Khans of Tarkir Block", "Khans of Tarkir", "Fate Reforged", /*"Dragons of Tarkir"*/
"* Khans of Tarkir Block", "Khans of Tarkir", "Fate Reforged", "Dragons of Tarkir",
"* Theros Block", "Journey into Nyx", "Born of the Gods", "Theros",
"* Return to Ravnica Block", "Dragon's Maze", "Gatecrash", "Return to Ravnica",
"* Innistrad Block", "Avacyn Restored", "Dark Ascension", "Innistrad",
@ -113,7 +113,10 @@ public class ConstructedFormats {
public static List<String> getSetsByFormat(String format) {
if (format.equals("* Khans of Tarkir Block")) {
return Arrays.asList("KTK", "FRF");
return Arrays.asList("KTK", "FRF","DTK");
}
if (format.equals("Dragons of Tarkir")) {
return Arrays.asList("DTK");
}
if (format.equals("Fate Reforged")) {
return Arrays.asList("FRF");

View file

@ -44,8 +44,7 @@ public class GathererSets implements Iterable<DownloadJob> {
"MMA",
"THS", "BNG", "JOU",
"CNS", "VMA",
"KTK", "FRF"
};
"KTK", "FRF", "DTK"};
private static final HashMap<String, String> symbolsReplacements = new HashMap<>();
static {

View file

@ -16,6 +16,7 @@ public class MagicCardsImageSource implements CardImageSource {
private static final Map<String, String> setNameTokenReplacement = new HashMap<String, String>() {
{
put("DTK", "dragons-of-tarkir");
put("GRC","wpngateway");
put("MBP","media-inserts");
put("MLP", "launch-party");

View file

@ -1,203 +1,204 @@
package org.mage.plugins.card.dl.sources;
import org.jsoup.Jsoup;
import org.jsoup.nodes.Document;
import org.jsoup.select.Elements;
import org.mage.plugins.card.images.CardDownloadData;
import java.io.IOException;
import java.util.HashMap;
import java.util.Map;
/**
*
* @author North
*/
public class WizardCardsImageSource implements CardImageSource {
private static CardImageSource instance;
private static Map<String, String> setsAliases;
private final Map<String, Map<String, String>> sets;
public static CardImageSource getInstance() {
if (instance == null) {
instance = new WizardCardsImageSource();
}
return instance;
}
public WizardCardsImageSource() {
sets = new HashMap<>();
setsAliases = new HashMap<>();
setsAliases.put("FRF", "fatereforged/cig");
setsAliases.put("C14", "commander2014/cig");
setsAliases.put("KTK", "khansoftarkir/cig");
setsAliases.put("M15", "magic2015coreset/cig");
setsAliases.put("CNS", "vintagemasters/cig");
setsAliases.put("CNS", "conspiracy/cig");
setsAliases.put("JOU", "journeyintonyx/cig");
setsAliases.put("BNG", "bornofthegods/cig");
setsAliases.put("C13", "commander2013/cig");
setsAliases.put("THS", "theros/cig");
setsAliases.put("M14", "magic2014coreset/cig");
setsAliases.put("MMA", "modernmasters/cig");
setsAliases.put("DGM", "dragonsmaze/cig");
setsAliases.put("GTC", "gatecrash/cig");
setsAliases.put("RTR", "returntoravnica/cig");
setsAliases.put("M13", "magic2013/cig");
setsAliases.put("AVR", "avacynrestored/cig");
setsAliases.put("DKA", "darkascension/cig");
setsAliases.put("ISD", "innistrad/cig");
setsAliases.put("M12", "magic2012/cig");
setsAliases.put("CMD", "commander/cig");
setsAliases.put("NPH", "newphyrexia/spoiler");
setsAliases.put("MBS", "mirrodinbesieged/spoiler");
setsAliases.put("SOM", "scarsofmirrodin/spoiler");
setsAliases.put("M11", "magic2011/spoiler");
setsAliases.put("ROE", "riseoftheeldrazi/spoiler");
setsAliases.put("WWK", "worldwake/spoiler");
setsAliases.put("ZEN", "zendikar/spoiler");
setsAliases.put("M10", "magic2010/spoiler");
setsAliases.put("ARB", "alarareborn/spoiler");
setsAliases.put("CON", "conflux/spoiler");
setsAliases.put("ALA", "shardsofalara/spoiler");
setsAliases.put("PC2", "planechase2012edition/cig");
setsAliases.put("PTK", "portalthreekingdoms/cig");
setsAliases.put("EVG", "elvesvsgoblins/cig");
setsAliases.put("DD2", "jacevschandra/cig");
setsAliases.put("DDC", "divinevsdemonic/cig");
setsAliases.put("DDD", "garrukvsliliana/cig");
setsAliases.put("DDE", "phyrexiavsthecoalition/cig");
setsAliases.put("DDF", "elspethvstezzeret/cig");
setsAliases.put("DDG", "knightsvsdragons/cig");
setsAliases.put("DDH", "ajanivsnicolbolas/cig");
setsAliases.put("DDI", "venservskoth/cig");
setsAliases.put("DDJ", "izzetvsgolgari/cig");
setsAliases.put("DDK", "sorinvstibalt/cig");
setsAliases.put("DDL", "heroesvsmonsters/cig");
setsAliases.put("DDM", "jacevsvraska/cig");
setsAliases.put("DDN", "speedvscunning/cig");
}
private Map<String, String> getSetLinks(String cardSet) {
Map<String, String> setLinks = new HashMap<>();
try {
String urlDocument;
if (cardSet.equals("M15")) {
urlDocument = "http://magic.wizards.com/en/content/magic-2015-core-set-card-set-archive-products-game-info";
Document doc = Jsoup.connect(urlDocument).get();
Elements cardsImages = doc.select("div.advanced-card img");
for (int i = 0; i < cardsImages.size(); i++) {
String cardName = normalizeName(cardsImages.get(i).attr("alt"));
if (cardName != null && !cardName.isEmpty()) {
if (cardName.equals("Forest") || cardName.equals("Swamp") || cardName.equals("Mountain") || cardName.equals("Island") || cardName.equals("Plains")) {
int landNumber = 1;
while (setLinks.get((cardName + landNumber).toLowerCase()) != null) {
landNumber++;
}
cardName += landNumber;
}
setLinks.put(cardName.toLowerCase(), cardsImages.get(i).attr("src"));
} else {
setLinks.put(Integer.toString(i), cardsImages.get(i).attr("src"));
}
}
} else {
urlDocument = "http://www.wizards.com/magic/tcg/article.aspx?x=mtg/tcg/" + setsAliases.get(cardSet);
Document doc = Jsoup.connect(urlDocument).get();
Elements cardsImages = doc.select("img[height$=370]");
for (int i = 0; i < cardsImages.size(); i++) {
String cardName = normalizeName(cardsImages.get(i).attr("title"));
if (cardName != null && !cardName.isEmpty()) {
if (cardName.equals("Forest") || cardName.equals("Swamp") || cardName.equals("Mountain") || cardName.equals("Island") || cardName.equals("Plains")) {
int landNumber = 1;
while (setLinks.get((cardName + landNumber).toLowerCase()) != null) {
landNumber++;
}
cardName += landNumber;
}
setLinks.put(cardName.toLowerCase(), cardsImages.get(i).attr("src"));
} else {
setLinks.put(Integer.toString(i), cardsImages.get(i).attr("src"));
}
}
cardsImages = doc.select("img[height$=470]");
for (int i = 0; i < cardsImages.size(); i++) {
String cardName = normalizeName(cardsImages.get(i).attr("title"));
if (cardName != null && !cardName.isEmpty()) {
String[] cardNames = cardName.replace(")", "").split(" \\(");
for (String name : cardNames) {
setLinks.put(name.toLowerCase(), cardsImages.get(i).attr("src"));
}
} else {
setLinks.put(Integer.toString(i), cardsImages.get(i).attr("src"));
}
}
}
} catch (IOException ex) {
System.out.println("Exception when parsing the wizards page: " + ex.getMessage());
}
return setLinks;
}
private String normalizeName(String name) {
return name.replace("\u2014", "-").replace("\u2019", "'")
.replace("\u00C6", "AE").replace("\u00E6", "ae")
.replace("\u00C1", "A").replace("\u00E1", "a")
.replace("\u00C2", "A").replace("\u00E2", "a")
.replace("\u00D6", "O").replace("\u00F6", "o")
.replace("\u00DB", "U").replace("\u00FB", "u")
.replace("\u00DC", "U").replace("\u00FC", "u")
.replace("\u00E9", "e").replace("&", "//")
.replace("Hintreland Scourge", "Hinterland Scourge");
}
@Override
public String generateURL(CardDownloadData card) throws Exception {
Integer collectorId = card.getCollectorId();
String cardSet = card.getSet();
if (collectorId == null || cardSet == null) {
throw new Exception("Wrong parameters for image: collector id: " + collectorId + ",card set: " + cardSet);
}
if (card.isFlippedSide()) { //doesn't support rotated images
return null;
}
if (setsAliases.get(cardSet) != null) {
Map<String, String> setLinks = sets.get(cardSet);
if (setLinks == null) {
setLinks = getSetLinks(cardSet);
sets.put(cardSet, setLinks);
}
String link = setLinks.get(card.getDownloadName().toLowerCase());
if (link == null) {
if (setLinks.size() >= collectorId) {
link = setLinks.get(Integer.toString(collectorId - 1));
} else {
link = setLinks.get(Integer.toString(collectorId - 21));
if (link != null) {
link = link.replace(Integer.toString(collectorId - 20), (Integer.toString(collectorId - 20) + "a"));
}
}
}
if (link != null && !link.startsWith("http://")) {
link = "http://www.wizards.com" + link;
}
return link;
}
return null;
}
@Override
public String generateTokenUrl(CardDownloadData card) {
return null;
}
@Override
public Float getAverageSize() {
return 60.0f;
}
}
package org.mage.plugins.card.dl.sources;
import org.jsoup.Jsoup;
import org.jsoup.nodes.Document;
import org.jsoup.select.Elements;
import org.mage.plugins.card.images.CardDownloadData;
import java.io.IOException;
import java.util.HashMap;
import java.util.Map;
/**
*
* @author North
*/
public class WizardCardsImageSource implements CardImageSource {
private static CardImageSource instance;
private static Map<String, String> setsAliases;
private final Map<String, Map<String, String>> sets;
public static CardImageSource getInstance() {
if (instance == null) {
instance = new WizardCardsImageSource();
}
return instance;
}
public WizardCardsImageSource() {
sets = new HashMap<>();
setsAliases = new HashMap<>();
setsAliases.put("DTK", "dragonsoftarkir/cig");
setsAliases.put("FRF", "fatereforged/cig");
setsAliases.put("C14", "commander2014/cig");
setsAliases.put("KTK", "khansoftarkir/cig");
setsAliases.put("M15", "magic2015coreset/cig");
setsAliases.put("CNS", "vintagemasters/cig");
setsAliases.put("CNS", "conspiracy/cig");
setsAliases.put("JOU", "journeyintonyx/cig");
setsAliases.put("BNG", "bornofthegods/cig");
setsAliases.put("C13", "commander2013/cig");
setsAliases.put("THS", "theros/cig");
setsAliases.put("M14", "magic2014coreset/cig");
setsAliases.put("MMA", "modernmasters/cig");
setsAliases.put("DGM", "dragonsmaze/cig");
setsAliases.put("GTC", "gatecrash/cig");
setsAliases.put("RTR", "returntoravnica/cig");
setsAliases.put("M13", "magic2013/cig");
setsAliases.put("AVR", "avacynrestored/cig");
setsAliases.put("DKA", "darkascension/cig");
setsAliases.put("ISD", "innistrad/cig");
setsAliases.put("M12", "magic2012/cig");
setsAliases.put("CMD", "commander/cig");
setsAliases.put("NPH", "newphyrexia/spoiler");
setsAliases.put("MBS", "mirrodinbesieged/spoiler");
setsAliases.put("SOM", "scarsofmirrodin/spoiler");
setsAliases.put("M11", "magic2011/spoiler");
setsAliases.put("ROE", "riseoftheeldrazi/spoiler");
setsAliases.put("WWK", "worldwake/spoiler");
setsAliases.put("ZEN", "zendikar/spoiler");
setsAliases.put("M10", "magic2010/spoiler");
setsAliases.put("ARB", "alarareborn/spoiler");
setsAliases.put("CON", "conflux/spoiler");
setsAliases.put("ALA", "shardsofalara/spoiler");
setsAliases.put("PC2", "planechase2012edition/cig");
setsAliases.put("PTK", "portalthreekingdoms/cig");
setsAliases.put("EVG", "elvesvsgoblins/cig");
setsAliases.put("DD2", "jacevschandra/cig");
setsAliases.put("DDC", "divinevsdemonic/cig");
setsAliases.put("DDD", "garrukvsliliana/cig");
setsAliases.put("DDE", "phyrexiavsthecoalition/cig");
setsAliases.put("DDF", "elspethvstezzeret/cig");
setsAliases.put("DDG", "knightsvsdragons/cig");
setsAliases.put("DDH", "ajanivsnicolbolas/cig");
setsAliases.put("DDI", "venservskoth/cig");
setsAliases.put("DDJ", "izzetvsgolgari/cig");
setsAliases.put("DDK", "sorinvstibalt/cig");
setsAliases.put("DDL", "heroesvsmonsters/cig");
setsAliases.put("DDM", "jacevsvraska/cig");
setsAliases.put("DDN", "speedvscunning/cig");
}
private Map<String, String> getSetLinks(String cardSet) {
Map<String, String> setLinks = new HashMap<>();
try {
String urlDocument;
if (cardSet.equals("M15")) {
urlDocument = "http://magic.wizards.com/en/content/magic-2015-core-set-card-set-archive-products-game-info";
Document doc = Jsoup.connect(urlDocument).get();
Elements cardsImages = doc.select("div.advanced-card img");
for (int i = 0; i < cardsImages.size(); i++) {
String cardName = normalizeName(cardsImages.get(i).attr("alt"));
if (cardName != null && !cardName.isEmpty()) {
if (cardName.equals("Forest") || cardName.equals("Swamp") || cardName.equals("Mountain") || cardName.equals("Island") || cardName.equals("Plains")) {
int landNumber = 1;
while (setLinks.get((cardName + landNumber).toLowerCase()) != null) {
landNumber++;
}
cardName += landNumber;
}
setLinks.put(cardName.toLowerCase(), cardsImages.get(i).attr("src"));
} else {
setLinks.put(Integer.toString(i), cardsImages.get(i).attr("src"));
}
}
} else {
urlDocument = "http://www.wizards.com/magic/tcg/article.aspx?x=mtg/tcg/" + setsAliases.get(cardSet);
Document doc = Jsoup.connect(urlDocument).get();
Elements cardsImages = doc.select("img[height$=370]");
for (int i = 0; i < cardsImages.size(); i++) {
String cardName = normalizeName(cardsImages.get(i).attr("title"));
if (cardName != null && !cardName.isEmpty()) {
if (cardName.equals("Forest") || cardName.equals("Swamp") || cardName.equals("Mountain") || cardName.equals("Island") || cardName.equals("Plains")) {
int landNumber = 1;
while (setLinks.get((cardName + landNumber).toLowerCase()) != null) {
landNumber++;
}
cardName += landNumber;
}
setLinks.put(cardName.toLowerCase(), cardsImages.get(i).attr("src"));
} else {
setLinks.put(Integer.toString(i), cardsImages.get(i).attr("src"));
}
}
cardsImages = doc.select("img[height$=470]");
for (int i = 0; i < cardsImages.size(); i++) {
String cardName = normalizeName(cardsImages.get(i).attr("title"));
if (cardName != null && !cardName.isEmpty()) {
String[] cardNames = cardName.replace(")", "").split(" \\(");
for (String name : cardNames) {
setLinks.put(name.toLowerCase(), cardsImages.get(i).attr("src"));
}
} else {
setLinks.put(Integer.toString(i), cardsImages.get(i).attr("src"));
}
}
}
} catch (IOException ex) {
System.out.println("Exception when parsing the wizards page: " + ex.getMessage());
}
return setLinks;
}
private String normalizeName(String name) {
return name.replace("\u2014", "-").replace("\u2019", "'")
.replace("\u00C6", "AE").replace("\u00E6", "ae")
.replace("\u00C1", "A").replace("\u00E1", "a")
.replace("\u00C2", "A").replace("\u00E2", "a")
.replace("\u00D6", "O").replace("\u00F6", "o")
.replace("\u00DB", "U").replace("\u00FB", "u")
.replace("\u00DC", "U").replace("\u00FC", "u")
.replace("\u00E9", "e").replace("&", "//")
.replace("Hintreland Scourge", "Hinterland Scourge");
}
@Override
public String generateURL(CardDownloadData card) throws Exception {
Integer collectorId = card.getCollectorId();
String cardSet = card.getSet();
if (collectorId == null || cardSet == null) {
throw new Exception("Wrong parameters for image: collector id: " + collectorId + ",card set: " + cardSet);
}
if (card.isFlippedSide()) { //doesn't support rotated images
return null;
}
if (setsAliases.get(cardSet) != null) {
Map<String, String> setLinks = sets.get(cardSet);
if (setLinks == null) {
setLinks = getSetLinks(cardSet);
sets.put(cardSet, setLinks);
}
String link = setLinks.get(card.getDownloadName().toLowerCase());
if (link == null) {
if (setLinks.size() >= collectorId) {
link = setLinks.get(Integer.toString(collectorId - 1));
} else {
link = setLinks.get(Integer.toString(collectorId - 21));
if (link != null) {
link = link.replace(Integer.toString(collectorId - 20), (Integer.toString(collectorId - 20) + "a"));
}
}
}
if (link != null && !link.startsWith("http://")) {
link = "http://www.wizards.com" + link;
}
return link;
}
return null;
}
@Override
public String generateTokenUrl(CardDownloadData card) {
return null;
}
@Override
public Float getAverageSize() {
return 60.0f;
}
}

View file

@ -65,6 +65,6 @@ ddd=gvl
unh=uh
dde=pvc
# Remove setname as soon as the images can be downloaded
ignore.urls=TOK
ignore.urls=TOK,DTK
# sets ordered by release time (newest goes first)
token.lookup.order=FRF,KTK,M15,VMA,CNS,JOU,BNG,THS,DDL,M14,MMA,DGM,GTC,RTR,M13,AVR,DDI,DKA,ISD,M12,NPH,MBS,SOM,M11,ROE,DDE,WWK,ZEN,M10,GVL,ARB,DVD,CFX,JVC,ALA,EVE,SHM,EVG,MOR,LRW,10E,CLS,CHK,GRC
token.lookup.order=DTK,FRF,KTK,M15,VMA,CNS,JOU,BNG,THS,DDL,M14,MMA,DGM,GTC,RTR,M13,AVR,DDI,DKA,ISD,M12,NPH,MBS,SOM,M11,ROE,DDE,WWK,ZEN,M10,GVL,ARB,DVD,CFX,JVC,ALA,EVE,SHM,EVG,MOR,LRW,10E,CLS,CHK,GRC

View file

@ -0,0 +1,60 @@
/*
* Copyright 2010 BetaSteward_at_googlemail.com. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification, are
* permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this list of
* conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
* of conditions and the following disclaimer in the documentation and/or other materials
* provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY BetaSteward_at_googlemail.com ``AS IS'' AND ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
* FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL BetaSteward_at_googlemail.com OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* The views and conclusions contained in the software and documentation are those of the
* authors and should not be interpreted as representing official policies, either expressed
* or implied, of BetaSteward_at_googlemail.com.
*/
package mage.sets;
import java.util.GregorianCalendar;
import mage.cards.ExpansionSet;
import mage.constants.SetType;
/**
*
* @author fireshoes
*/
public class DragonsOfTarkir extends ExpansionSet {
private static final DragonsOfTarkir fINSTANCE = new DragonsOfTarkir();
public static DragonsOfTarkir getInstance() {
return fINSTANCE;
}
private DragonsOfTarkir() {
super("Dragons of Tarkir", "DTK", "mage.sets.dragonsoftarkir", new GregorianCalendar(2015, 3, 27).getTime(), SetType.EXPANSION);
this.blockName = "Dragons of Tarkir";
this.hasBoosters = true;
this.hasBasicLands = true;
this.numBoosterLands = 1;
this.numBoosterCommon = 10;
this.numBoosterUncommon = 3;
this.numBoosterRare = 1;
this.ratioBoosterMythic = 8;
}
}

View file

@ -16,6 +16,7 @@ Conflux|conflux|
Dark Ascension|darkascension|
Darksteel|darksteel|
Dissension|dissension|
Dragons of Tarkir[dragonsoftarkir]
Dragon's Maze|dragonsmaze|
Duel Decks: Ajani vs. Nicol Bolas|ajanivsnicolbolas|
Duel Decks: Divine vs. Demonic|divinevsdemonic|

View file

@ -25570,4 +25570,5 @@ Curse of the Bloody Tome|WPN Gateway|80|Special|{2}{U}|Enchantment — Aura Curs
Curse of Thirst|WPN Gateway|81|Special|{4}{B}|Enchantment — Aura Curse|||Enchant player$At the beginning of enchanted player's upkeep, Curse of Thirst deals damage to that player equal to the number of Curses attached to him or her.|
Nearheath Stalker|WPN Gateway|82|Special|{4}{R}|Creature — Vampire Rogue|4|1|Undying <i>(When this creature dies, if it had no +1/+1 counters on it, return it to the battlefield under its owner's control with a +1/+1 counter on it.)</i>|
Bloodcrazed Neonate|WPN Gateway|83|Special|{1}{R}|Creature — Vampire|2|1|Bloodcrazed Neonate attacks each turn if able.$Whenever Bloodcrazed Neonate deals combat damage to a player, put a +1/+1 counter on it.|
Boneyard Wurm|WPN Gateway|84|Special|{1}{G}|Creature — Wurm|*|*|Boneyard Wurm's power and toughness are each equal to the number of creature cards in your graveyard.|
Boneyard Wurm|WPN Gateway|84|Special|{1}{G}|Creature — Wurm|*|*|Boneyard Wurm's power and toughness are each equal to the number of creature cards in your graveyard.|
Dragonlord's Reaper|Dragons of Tarkir|96|Rare|{5}{B}{B}|Creature - Dragon|5|6|Flying$When Dragonlord's Reaper enters the battlefield, if you cast it from your hand and there are five or more other creatures on the battlefield, destroy all other creatures.|

View file

@ -31,6 +31,7 @@ Dissension|DIS|
Deckmasters|DKM|
Dragon's Maze|DGM|
The Dark|DRK|
Dragons of Tarkir[DTK]
Duel Decks: Ajani vs. Nicol Bolas|DDH|
Duel Decks: Elves vs. Goblins|EVG|
Duel Decks: Divine vs. Demonic|DDC|