» Sections
» XNA Projects
ClusterStorm
» PSP Homebrew
Casino Addict
Squarez
WiFi Jukebox
SecureText
Binary (Demo)
» Favorite Links
SourceForge.net
xbox360.qj.net
PSPUpdates.qj.net
PSP Video 9
PS2nfo.com
AnalogX.com
vBulletin

j!nx
» Donate
If you've enjoyed any of our freeware and would like to make a donation of any amount, you can do so using PayPal.

» MTGO .dec Format
Last Updated: 10/14/2004

NOTICE: This example is for VB6, not VB.NET!

Here are the 2 type records I created for reading magic .dec files.

I haven't figured out what the "header" information contains, except for the card count which is the total # of cards in the .dec file, not including the sideboard.

Public Type mtgdeckheader
Header As String * 8
Cards As Integer
Extra As String * 2
End Type

Public Type mtgdeckcard
ID1 As Byte
ID2 As Byte
ID3 As Byte
ID4 As Byte

SerialNum As Long
Extra1 As Long
Extra2 As Long

End Type

Dim myheader as mtgdeckheader
Dim mycard as mtgdeccard
Dim sidecards As Integer
Dim unkn as Integer

open "c:\mydeck.dec" for binary as #1
get #1,,myheader

for x=1 to myheader.Cards
get #1,,mycard
next x

get #1,,sidecards
get #1,,unkn

for x=1 to sidecards
get #1,,mycard
next x

close #1

I typed this off the top of my head, so hopefully there are no mistakes! I did cut & paste the type records.

As you can see, the sideboard is stored right after the normal deck, so if the sideboard count contains 0, then there is no sideboard. Otherwise, get the sideboard count and read in all those cards.

All cards have a unique serial num, which is a tracking device for wizards. When you organize your deck, MTGO knows exactly which card is which. When creating you own .dec file, you can leave the serial # blank, and MTGO will still read the .dec file. Since Magic allows people to share .dec files with each other, it obviously doesn't matter what's in the field since no one will ever have the same serial #'s.

The sample program above will read all of the cards from your .dec file. It doesn't do anything with the cards, but it shows how to read the .dec file. Then you look at the ID bytes to do card matching. This is a 32-byte field, so you can use a long to read in the ID also.

The hardest part is matching ID's to the cards. Magic published this list in the cardmap.txt file, included with MTGO. This contains lots of old sets not part of MTGO. It does contain Legions, Scourage, Onslaught, Odyssey, Torment & Judgment. I have created a new card list for Mirrodin, Darksteel and 5th Dawn. See the MTG DB freeware section for this file.

Using this card file, it matches ID's to card/set. From here you can build a database of your own to store these ID's matched to the card. ID's in the card file are in decimal format. You can check the card ID byte by byte, or by checking the entire 32-bit long. It's up to you.

I go on wizards website and download all of the spoiler text files, then I import the information from that into my database, to get the rest of the cards information.

I had to manually match up the cards for Mirrodin, Darksteel & 5th Dawn which is a pain in the ass, but takes about 15-30 minutes per set.

If you notice, the database I have on my website is called "mini" cause I also have a Magic DB I created which stores ALL the information including the flavor text and the card instructions text (taken from the spoiler txt files).

I'm making ALL of my magic programs open source to help other developers create programs for MTG and MTGO. I just need to get some free time to remove all kinds of test code which I have commented out.


Added Note:

Bit 4 of the ID3 byte is whether or not the card is a premium/foil card. If set to 1 it is a foil, otherwise it is a normal card.



Copyright ©1999 - 2006, GlobWare