mirror of
https://github.com/correl/mage.git
synced 2024-11-28 19:19:55 +00:00
Fixed mtgjson data;
This commit is contained in:
parent
1986b01bf6
commit
a4d797e473
3 changed files with 43 additions and 21 deletions
|
@ -34,6 +34,8 @@ class JsonCard {
|
|||
public List<String> printings;
|
||||
public String power;
|
||||
public String rarity;
|
||||
public boolean starter;
|
||||
public String side;
|
||||
public List<JsonRuling> rulings;
|
||||
public List<String> subtypes;
|
||||
public List<String> supertypes;
|
||||
|
@ -44,8 +46,4 @@ class JsonCard {
|
|||
public String uuid;
|
||||
public List<String> variations;
|
||||
public String watermark;
|
||||
|
||||
// unknown
|
||||
public boolean starter;
|
||||
public String side;
|
||||
}
|
||||
|
|
|
@ -12,7 +12,10 @@ import java.net.URL;
|
|||
import java.nio.file.Files;
|
||||
import java.nio.file.StandardCopyOption;
|
||||
import java.text.Normalizer;
|
||||
import java.util.*;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.zip.ZipInputStream;
|
||||
|
||||
public final class MtgJson {
|
||||
|
@ -60,16 +63,29 @@ public final class MtgJson {
|
|||
static {
|
||||
try {
|
||||
cards = loadAllCards();
|
||||
List<String> oldKeys = new ArrayList<>();
|
||||
|
||||
List<String> keysToDelete = new ArrayList<>();
|
||||
|
||||
// fix names
|
||||
Map<String, JsonCard> newKeys = new HashMap<>();
|
||||
for (String key : cards.keySet()) {
|
||||
if (key.contains("(")) {
|
||||
newKeys.put(key.replaceAll("\\(.*\\)", "").trim(), cards.get(key));
|
||||
oldKeys.add(key);
|
||||
keysToDelete.add(key);
|
||||
}
|
||||
}
|
||||
cards.putAll(newKeys);
|
||||
cards.keySet().removeAll(oldKeys);
|
||||
cards.keySet().removeAll(keysToDelete);
|
||||
|
||||
// remove wrong data (tokens)
|
||||
keysToDelete.clear();
|
||||
for (Map.Entry<String, JsonCard> record : cards.entrySet()) {
|
||||
if (record.getValue().layout.equals("token") || record.getValue().layout.equals("double_faced_token")) {
|
||||
keysToDelete.add(record.getKey());
|
||||
}
|
||||
}
|
||||
cards.keySet().removeAll(keysToDelete);
|
||||
|
||||
addAliases(cards);
|
||||
} catch (IOException e) {
|
||||
throw new RuntimeException(e);
|
||||
|
|
|
@ -1,17 +1,5 @@
|
|||
package mage.verify;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.lang.reflect.Constructor;
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
import java.lang.reflect.Modifier;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.NoSuchFileException;
|
||||
import java.nio.file.Paths;
|
||||
import java.util.*;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
import java.util.stream.Collectors;
|
||||
import mage.ObjectColor;
|
||||
import mage.abilities.keyword.MultikickerAbility;
|
||||
import mage.cards.*;
|
||||
|
@ -29,6 +17,19 @@ import org.mage.plugins.card.images.CardDownloadData;
|
|||
import org.mage.plugins.card.images.DownloadPictures;
|
||||
import org.reflections.Reflections;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.lang.reflect.Constructor;
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
import java.lang.reflect.Modifier;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.NoSuchFileException;
|
||||
import java.nio.file.Paths;
|
||||
import java.util.*;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* @author JayDi85
|
||||
*/
|
||||
|
@ -58,18 +59,25 @@ public class VerifyCardDataTest {
|
|||
skipListCreate("PT");
|
||||
skipListAddName("PT", "UST", "Garbage Elemental");
|
||||
skipListAddName("PT", "UST", "Infinity Elemental");
|
||||
skipListAddName("PT", "UNH", "Old Fogey");
|
||||
|
||||
// color
|
||||
skipListCreate("COLOR");
|
||||
|
||||
// cost
|
||||
skipListCreate("COST");
|
||||
skipListAddName("COST", "KTK", "Erase");
|
||||
skipListAddName("COST", "M13", "Erase");
|
||||
skipListAddName("COST", "ULG", "Erase");
|
||||
skipListAddName("COST", "H17", "Grimlock, Dinobot Leader");
|
||||
|
||||
// supertype
|
||||
skipListCreate("SUPERTYPE");
|
||||
|
||||
// type
|
||||
skipListCreate("TYPE");
|
||||
skipListAddName("TYPE", "UNH", "Old Fogey");
|
||||
skipListAddName("TYPE", "UST", "capital offense");
|
||||
|
||||
// subtype
|
||||
skipListCreate("SUBTYPE");
|
||||
|
|
Loading…
Reference in a new issue