It is currently 27 May 2019, 07:06
   
Text Size

Magic the Gathering binary database

General Discussion of the Intricacies

Moderator: CCGHQ Admins

Magic the Gathering binary database

Postby laxika » 14 Jun 2012, 19:17

Hy guys!

Here is the full Avacyn Restored database dump from magicinfo. I'm working on a collection manager so I'll slowly dump the whole site. This dump have all data (on all avaidable languages from german to chinese). The power and thougness fields are not always what they says. When the first type is creature, its power/thougness (if its */* then * is dumped as 127), when the card is a planeswalker, power equals with the planeswalker's loyalty.

Link: http://uppit.com/gccifp1cwlyq/carddb_1.db
(Scan it if you want, .db extension is not runnable anyways.)

How to read it: Here is the writing then the reading mechanism in java.

Writing:
Code: Select all
//Save the cards
            RandomAccessFile file = new RandomAccessFile("carddb_" + SET_ID + ".db", "rw");
            //Dumper version
            file.writeByte(VERSION);
            //ID of the set, avr = 1, later we goin to have more sets dumped
            file.writeShort(SET_ID);
            //Write the card count in the set
            file.writeShort(SET_CARD_COUNT);
            for (Card c : cards) {
                System.out.println("Writing card: " + c.getSetId());

                //The id of the card in the collection
                file.writeInt(COLLECTION_START_ID);

                //How many lang data avaidable for the card
                file.writeByte(c.getLangAmount());
                for (int i = 0; i < c.getLangAmount(); i++) {
                    LangData save = c.getLangData(i);

                    //Lang ID
                    file.writeByte(save.getLangId());
                    //Save the data for that lang
                    file.writeUTF(save.getCardName());
                    file.writeUTF(save.getCardText());
                    file.writeUTF(save.getCardExtraText());
                }

                //Save the illustrator's id
                file.writeShort(c.getIllustrator());

                //The amount of types where this card is legal
                file.writeByte(c.getLegalityAmount());
                for (int i = 0; i < c.getLegalityAmount(); i++) {
                    //Save the ids of the types where this card is legal
                    file.writeByte(c.getLegalityData(i));
                }

                //The amount of rulings
                file.writeByte(c.getRulingsAmount());
                for (int i = 0; i < c.getRulingsAmount(); i++) {
                    Ruling rul = c.getRuling(i);

                    //Ruling day
                    file.writeByte(rul.getDay());
                    //Ruling month
                    file.writeByte(rul.getMonth());
                    //Ruling year
                    file.writeShort(rul.getYear());
                    //The ruling text
                    file.writeUTF(rul.getRuling());
                }

                //The Primary type (eg Creature)
                file.writeShort(c.getFirstType());
                //The subtype (eg Angel) -1 if no secondary
                file.writeShort(c.getSecondaryType());
                //Sub-subtype -1 if nothing
                file.writeShort(c.getThirdType());

                //ID in the set
                file.writeShort(c.getSetId());

                //The cost in string (eg 8BB or GG or 1RG)
                file.writeUTF(c.getCost());

                //rarity, 0 = C, 1 = U, 2 = R, 3 = M
                file.writeByte(c.getRarity());

                //Power, -1 if no power
                file.writeByte(c.getPower());
                //Toughness, -1 if no toughness
                file.writeByte(c.getThougness());
                COLLECTION_START_ID++;
            }
            System.out.println("Finished writing");
            file.close();
Reading:
Code: Select all
package magiccollectorprodumpertest;

import java.io.IOException;
import java.io.RandomAccessFile;
import java.util.logging.Level;
import java.util.logging.Logger;

public class MagicCollectorProDumperTest {

    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) {
        try {
            RandomAccessFile file = new RandomAccessFile("carddb_1.db", "r");
            System.out.println("Dumper version: "+file.readByte());
            System.out.println("Set id: " + file.readShort());
            int count = file.readShort();

            System.out.println("Card count: " + count);
            for (int i = 0; i < count; i++) {
                int cardId = file.readInt();
                System.out.println("CardID: "+cardId);
                int langCount = file.readByte();

                for (int j = 0; j < langCount; j++) {
                    int id = file.readByte();
                    System.out.println("Lang ID(" + id + ") Name: " + file.readUTF());
                    System.out.println("Lang ID(" + id + ") Text: " + file.readUTF());
                    System.out.println("Lang ID(" + id + ") ExtraText: " + file.readUTF());
                }
                System.out.println("Illustrator: " + file.readShort());

                int legalityAmount = file.readByte();
                System.out.println("Legality amount: " + legalityAmount);
                for (int j = 0; j < legalityAmount; j++) {
                    System.out.println("Legality: " + file.readByte());
                }

                int rulingAmount = file.readByte();
                for (int j = 0; j < rulingAmount; j++) {
                    int day = file.readByte();
                    int month = file.readByte();
                    int year = file.readShort();

                    System.out.println("Ruling: " + year + "." + month + "." + day + ".: " + file.readUTF());
                }

                System.out.println("First type: " + file.readShort());
                System.out.println("Second type: " + file.readShort());
                System.out.println("Third type: " + file.readShort());
                System.out.println("ID in the set: " + file.readShort());
                System.out.println("Cost: " + file.readUTF());
                System.out.println("Rarity: " + file.readByte());
                System.out.println("Power: " + file.readByte());
                System.out.println("Thougness: " + file.readByte());
                System.out.println("_________END CARD_________\n\n");
            }

            file.close();
        } catch (IOException ex) {
            Logger.getLogger(MagicCollectorProDumperTest.class.getName()).log(Level.SEVERE, null, ex);
        }
    }
}
Illustrator ids:
Code: Select all
1 = James Ryman
2 = Terese Nielsen
3 = Greg Staples
4 = Allen Williams
5 = Cynthia Sheppard
6 = Jason Chan
7 = Igor Kieryluk
8 = John Stanko
9 = Jaime Jones
10 = Karl Kopinski
11 = Michael C. Hayes
12 = Howard Lyon
13 = Johannes Voss
14 = Sam Wolfe Connelly
15 = Steven Belledin
17 = Steve Prescott
16 = Lucas Graciano
19 = Todd Lockwood
18 = Scott Chou
21 = Eric Deschamps
20 = Chris Rahn
23 = Gabor Szikszai
22 = David Rapoza
25 = Dan Scott
24 = Bud Cook
27 = Erica Yang
26 = David Palumbo
29 = Clint Cearley
28 = Volkan Baga
31 = James Paick
30 = Wayne England
34 = Tomasz Jedruszek
35 = Raymond Swanland
32 = Matt Stewart
33 = Svetlin Velinov
38 = Winona Nelson
39 = Izzy
36 = Cliff Childs
37 = Anthony Palumbo
42 = Vincent Proce
43 = Daarken
40 = Ryan Yee
41 = Jason Felix
46 = John Avon
47 = Dave Kendall
44 = Wesley Burt
45 = Christopher Moeller
51 = Slawomir Maniak
50 = Franz Vohwinkel
49 = Anthony Francisco
48 = Kev Walker
55 = Ryan Pancoast
54 = Nic Klein
53 = Trevor Claxton
52 = Nils Hamm
59 = Zoltan Boros
58 = Jason A. Engle
57 = Mike Sass
56 = Steve Argyle
63 = Jung Park
62 = Wayne Reynolds
61 = Drew Baker
60 = Mike Bierek
68 = Eytan Zana
69 = Lars Grant-West
70 = Daniel Ljunggren
64 = Adam Paquette
65 = Peter Mohrbacher
66 = Richard Wright
67 = Sam Burley
Legality ids:
Code: Select all
1 = Legal in Vintage (Type 1)
2 = Legal in Legacy (Type 1.5)
3 = Legal in Extended (Type 1.X)
4 = Legal in Standard (Type 2)
5 = Legal in Classic (MTGO)
6 = Legal in Commander
7 = Legal in Modern
Type IDs:
Code: Select all
1 = Creature
2 = Angel
3 = Instant
4 = Wall
5 = Legendary Creature
6 = Enchantment
7 = Aura
8 = Human
9 = Cleric
10 = Sorcery
11 = Scout
12 = Soldier
13 = Wizard
14 = Spirit
15 = Knight
17 = Horror
16 = Zombie
19 = Griffin
18 = Bird
21 = Drake
20 = Rogue
23 = Tamiyo
22 = Planeswalker
25 = Assassin
24 = Vampire
27 = Shade
26 = Demon
29 = Skeleton
28 = Bat
31 = Archer
30 = Dragon
34 = Hound
35 = Warrior
32 = Devil
33 = Elemental
38 = Tibalt
39 = Beast
36 = Berserker
37 = Shaman
42 = Spider
43 = Wolf
40 = Bear
41 = Treefolk
46 = Wurm
47 = Artifact
44 = Boar
45 = Druid
51 = Land
50 = Construct
49 = Artifact Creature
48 = Equipment
55 = Swamp
54 = Island
53 = Plains
52 = Basic Land
57 = Forest
56 = Mountain
If needed I can add a date field to the header of the dump, because legality/rulings data can be obsolete very fast.

Please write some feedback if you need more of this. I don't want to waste my time uploading editions if they are not needed/used.
laxika
 
Posts: 14
Joined: 26 Mar 2012, 22:43
Has thanked: 0 time
Been thanked: 0 time

Return to Magic Rules Engine Programming

Who is online

Users browsing this forum: No registered users and 2 guests


Who is online

In total there are 2 users online :: 0 registered, 0 hidden and 2 guests (based on users active over the past 10 minutes)
Most users ever online was 287 on 31 Mar 2019, 04:11

Users browsing this forum: No registered users and 2 guests

Login Form