Magic-League.com Forum Index Magic-League.com
Forums of Magic-League: Free Online Magic: the Gathering Play with Apprentice and Magic Workstation; casual or tournament play.
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Apprentice Card database


Goto page 1, 2  Next
 
Reply to topic    Magic-League.com Forum Index -> Apprentice
Author Message
PatrickGA



Joined: 17 Jan 2007
Posts: 11

PostPosted: Wed Jan 17, 2007 3:14 pm    Post subject: Apprentice Card database Reply with quote

I'm aware this isn't really about support on Apprentice, but I couldn't really find where else to put this... didn't quite belong in any other forum, either (including Non-MTG, because it is related to the card game). I decided it fit most here.

I'm taking a Programming course in a private college and for the Java module of the course, a large portion of the module will be developing our own application. After thinking about it a little (and a little boredom in class -- I was totally doing my homework, while playing MtG on Apprentice with someone on our closed network) I thought it would be cool to build a similar program that would support three or more players -- a feature I have yet to see in any of the freeware applications out there (not that I've really looked hard in the past year or two, but either way it seemed like a decent project idea and it got approval from my instructor).

The issue I'm coming across right now has nothing to do with the application itself, but the card database. I figured since the Apprentice database was covered in this site's signature anyway it'd be appropriate to use it as a reference, but I can't seem to find a way to properly decipher the sporadic use of delimiters. It's randomly line-feed, carriage-return and dash-delimited, so I can't conceive any way for my computer to make sense of which field is which.

I was wondering if anyone who knew more than me about the database could give me the algorithm used to read it or something... Or better yet, if anyone knows of the existence of a full XML card list, I'd be even more pleased... I ran a search and found documentation on someone using XML to create .dec files, but had no luck finding an actual card list.

Thanks for any and all support. Feel free to E-Mail me at PatrickGA@gmail.com.
Back to top
jheezy



Joined: 30 May 2006
Posts: 170

PostPosted: Wed Jan 17, 2007 5:11 pm    Post subject: Reply with quote

idk any of the technomalogical flibberflabber u said but the company who made apprentice is out of buisness and i think they would be the only ppl who would know the said flibberflabber
Back to top
ant900



Joined: 11 Oct 2004
Posts: 2449
Location: somewhere

PostPosted: Wed Jan 17, 2007 5:16 pm    Post subject: Reply with quote

I heard a rumor that the apprentice source code was revealed a month or so ago. Whether or not you can find it or not if it is true though is another matter.
Back to top
PatrickGA



Joined: 17 Jan 2007
Posts: 11

PostPosted: Wed Jan 17, 2007 6:05 pm    Post subject: Reply with quote

jheezy wrote:
idk any of the technomalogical flibberflabber u said but the company who made apprentice is out of buisness and i think they would be the only ppl who would know the said flibberflabber


I'm aware of their disbanding, but someone has been adding new cards to Apprentice as they are being released. I figured whoever has been doing that probably has an idea how it's being retrieved -- the program doesn't just "know" where to find the information, it needs to be instructed on how to read it.

If you want to get an idea what I mean (and some good fun for your brain while you're at it), try opening cardinfo.dat (Apprentice\Sets\cardinfo.dat) with Notepad. It's plain text, but the way the card information is laid out is absurd to read yourself, much less program a computer to read.

ant900 wrote:
I heard a rumor that the apprentice source code was revealed a month or so ago. Whether or not you can find it or not if it is true though is another matter.


That would be fantastic! Originally I was hoping I'd just be able to make the desired modifications instead of building it from the ground up, but when the instructor asked if it was open source, I realized it probably wasn't on the account of dragonstudios.com being down indefinitely.

I'll have a look around. Thanks.


Last edited by PatrickGA on Wed Jan 17, 2007 6:22 pm; edited 2 times in total
Back to top
Spyx



Joined: 31 Oct 2004
Posts: 678

PostPosted: Wed Jan 17, 2007 6:19 pm    Post subject: Reply with quote

2vs2 apprentice would be hella cool Very Happy
Back to top
PatrickGA



Joined: 17 Jan 2007
Posts: 11

PostPosted: Wed Jan 17, 2007 6:24 pm    Post subject: Reply with quote

Quote:
The program is freeware and is downloadable without need for charge nor registration.[4] However, when Dragonstar Studios disbanded, they did not release the source code due to the legal agreement between them and Wizards of the Coast.[5] Hence, Apprentice is frozen in time without the possibility of any future upgrades or bugfixes. However, the simple data format used to store cards has allowed new sets to be added and the registry of cards updated.


The full article at: http://en.wikipedia.org/wiki/Apprentice_(software)

My search quickly ended... unless that information is outdated, I suppose, but the article is dated January 7th, 2007.

If only the part about simple data formats were true.

Spyx wrote:
2vs2 apprentice would be hella cool Very Happy


I'd love to say "I could try to make a release version after it's been graded", but I'm afraid I might get my pants sued off by Wizards if I did considering that they made an agreement with Dragonstar not to release the Apprentice source code. And I'm pretty attached to my pants.

Anyone know of Wizards' actual standing on this?
Back to top
ant900



Joined: 11 Oct 2004
Posts: 2449
Location: somewhere

PostPosted: Wed Jan 17, 2007 6:52 pm    Post subject: Reply with quote

adding new sets? heck anyone can do it, Ive done it before, it isnt anything hard
Back to top
jheezy



Joined: 30 May 2006
Posts: 170

PostPosted: Wed Jan 17, 2007 7:13 pm    Post subject: Reply with quote

hey man srry bout the legal terms thing. but ya i heard that one of the guys who was workin on go beta had the source code for appr. it jus a rumor as ant900 pointed out.
Back to top
Laplie
League Staff


Joined: 31 Aug 2004
Posts: 527

PostPosted: Wed Jan 17, 2007 7:41 pm    Post subject: Reply with quote

simple data formats doesn't necessarily mean "human readible." If you look at the printout of most data formats, it would be completely unreadible binary garbage unless you process it somehow (or as they do in Java override Object.toString())

However, Appr's card format isn't that hard to read. Essentially, all the card text is printed with typeline and cost seperated out. The seperators are a bit weird.

Then all of the card names and sets are listed afterward.

-----

I don't see why you would need to know apprentice's card format though. If you are using Apprentice to connect to some sort of server like thing which handles the multiplayer stuff, then you don't need really need to know how apprentice stores cards.

If you are making your own program completely from scratch then you probably want to make your own format. You probably want to store the cards as a HashMap mapping card names to card objects (which will have fields for name/cost/text/etc). HashMaps are even serializable so you can save a HashMap object in memory to a file.

If you want to import cardnames, you probably want to visit gatherer.wizards.com . The plaintext version of the spoiler is very easy for a java program to parse.
Back to top
PatrickGA



Joined: 17 Jan 2007
Posts: 11

PostPosted: Wed Jan 17, 2007 8:29 pm    Post subject: Reply with quote

Laplie wrote:
simple data formats doesn't necessarily mean "human readible." If you look at the printout of most data formats, it would be completely unreadible binary garbage unless you process it somehow (or as they do in Java override Object.toString())

However, Appr's card format isn't that hard to read. Essentially, all the card text is printed with typeline and cost seperated out. The seperators are a bit weird.

Then all of the card names and sets are listed afterward.

-----

I don't see why you would need to know apprentice's card format though. If you are using Apprentice to connect to some sort of server like thing which handles the multiplayer stuff, then you don't need really need to know how apprentice stores cards.

If you are making your own program completely from scratch then you probably want to make your own format. You probably want to store the cards as a HashMap mapping card names to card objects (which will have fields for name/cost/text/etc). HashMaps are even serializable so you can save a HashMap object in memory to a file.

If you want to import cardnames, you probably want to visit gatherer.wizards.com . The plaintext version of the spoiler is very easy for a java program to parse.


I wouldn't be building it from scratch if I had the source code, but I don't. Apprentice's interface couldn't handle more than two simultaneous players as it stands, so I'm stuck building from the ground up unless I can get my hands on the source.

I'm also trying to avoid the pain in the posterior that is writing the entire database myself. I COULD do it, but 8000+ records is a little much and, frankly, not really in the project outline. Also, copying just any spoiler list might make future additions a little difficult... If I had to do it myself, I'd do it with XML, for sure. We're graded on reusability, and provided you understand the syntax XML is highly reusable.

Basically, the less work I have to do outside the server application, the better. The rest, I'll do if I have to, I suppose.

At the moment, I'm thinking that if I could find the plaintext spoiler you speak of, I could probably write a program to write the XML for me.

EDIT: Found it... I find their interface a little funky.

That'll work great. Thanks.
Back to top
coppro



Joined: 21 Aug 2005
Posts: 17

PostPosted: Wed Jan 17, 2007 8:48 pm    Post subject: Reply with quote

IIRC there is an open-source C program to edit them already - if you were to base it off that it might be quicker. Or it might not. I forget what it's called though, you'd have to search around Salvation.
Back to top
PatrickGA



Joined: 17 Jan 2007
Posts: 11

PostPosted: Thu Jan 18, 2007 5:33 am    Post subject: Reply with quote

The Wizards database is apparently retarded as well. They have each card stored several times -- once for each set it belongs to. Its lack of primary key makes it ridiculous to add any cards at all without ending up with duplicates (just querying "Forest" and filtering for lands brings back a buttload of the exact same record).

coppro wrote:
IIRC there is an open-source C program to edit them already - if you were to base it off that it might be quicker. Or it might not. I forget what it's called though, you'd have to search around Salvation.


While that sounds tempting, we haven't done any C, so my knowledge is very limited on it.

I'll have to use dummy data until I can find a way to write my own database.
Back to top
Laplie
League Staff


Joined: 31 Aug 2004
Posts: 527

PostPosted: Thu Jan 18, 2007 3:57 pm    Post subject: Reply with quote

Since it seems as though you need a little help. The following reads a text file with the plaintext version of the spoiler and puts it into a HashMap

Code:

import java.io.BufferedReader;
import java.io.FileReader;
import java.io.IOException;
import java.util.HashMap;
public class TextSpoilerParser {

   BufferedReader fileInput;

   public TextSpoilerParser(String filename) throws IOException {
      fileInput = new BufferedReader(new FileReader(filename));
   }
   
   public HashMap<String, MagicCard> generate() throws IOException {
      HashMap<String, MagicCard> mapping = new HashMap<String, MagicCard>();
      int temp = 0;
      
      String line = fileInput.readLine();
      MagicCard currentCard = new MagicCard();
      while (line != null) {
         if (temp == 0) {
            currentCard = new MagicCard();
            currentCard.name = line.substring(10).trim();
         } else if (temp == 1) {
            currentCard.cost = line.substring(6).trim();
         } else if (temp == 2) {
            currentCard.cardType = line.substring(6).trim();
         } else if (temp == 3) {
            currentCard.pt = line.substring(9).trim();
         } else if (temp == 4) {
            currentCard.text = line.substring(12).trim();
         }else if (temp == 5) {
            currentCard.set = line.substring(12).trim();
         }
         
         line = fileInput.readLine();
         temp++;
         if (temp == 7) {
            temp = 0;
            mapping.put(currentCard.name, currentCard);
         }
      }
      return mapping;
   }
}


And the MagicCard class:

Code:
public class MagicCard {
//TODO: Change to private, add getters/setters, create appropriate objects instead of strings
String name;
String cost;
String cardType;
String text;
String pt;
String set;
}


Of course there are lots of improvements that could be made. For example, right now everything is stored as a string. While "set" should probably be List<String>. And "cost" should be its own datatype. It will require more text processing.

Once you have the HashMap returned by generate(), turning that into an XML file should be very simple.
Back to top
PatrickGA



Joined: 17 Jan 2007
Posts: 11

PostPosted: Thu Jan 18, 2007 6:38 pm    Post subject: Reply with quote

Way ahead of you, but thanks for the concern. I wrote a program (a user-friendly and reusable one at that) that generated an XML file which currently contains only Type 2 cards, I won't bother with the others until the project is functional. I'm having a hard time with the retarded database structure of gatherer.wizards.com... It feels like one guy said, "hey, let's store each card once for each set and that way save ourselves the issue of redundancy in the set names", and the big kahuna said "yeah, I like that idea", and then another guy said "no! it'll be better if we store each card as a unique key and just list out the sets they appeared in for easier querying later!", and the big kahuna said "I like that idea too... let's do both!", and then they combined the horrid disadvantages of both to make one big frustrating heap of confusion.

Just for the sake of clarification, I agree completely with hypothetical gatherer.wizards DB designer #2. Hypothetical gatherer.wizards DB designer #1 was clearly a masochist.

Long story short, I have basic lands listed about 20 times over just in Type 2.
Back to top
Spyx



Joined: 31 Oct 2004
Posts: 678

PostPosted: Thu Jan 18, 2007 6:49 pm    Post subject: Reply with quote

PatrickGA wrote:

Long story short, I have basic lands listed about 20 times over just in Type 2.


That's how it's supposed to be. At least in mws when you go T2 -> forest you get 12 forests with different art.
Back to top
Display posts from previous:   
Reply to topic    Magic-League.com Forum Index -> Apprentice All times are GMT - 7 Hours
Goto page 1, 2  Next
Page 1 of 2

 


Powered by phpBB © 2001, 2005 phpBB Group
Magic: the Gathering Cards

All content on this page may not be reproduced without consent of Magic-League Directors.
Magic the Gathering is TM and copyright Wizards of the Coast, Inc, a subsidiary of Hasbro, Inc. All rights reserved.


About Us | Contact Us | Privacy Policy