Page 1 of 1

Card coding

PostPosted: 18 Aug 2010, 13:10
by zaroblan
Greetings,

I would dearly like to get into coding cards for Forge. I have been developing for over 20 years in a variety of language ... and have been playing Magic since Unlimited. Forge has become a very large part of my Magic life and I would like to contribute.

I have downloaded the source code. I am very new to Java, but use C++ and C# on a daily basis so the language is nothing new. What I cannot seem to find is where the cards are actually defined or coded. Please could you give me some pointers where to start so I can get cracking.

Thanks in advance,

Robert Lancaster

Re: Card coding

PostPosted: 18 Aug 2010, 13:21
by Rob Cashwalker
I've been there... I'm a VB programmer at heart, but nearly any language makes sense to a good programmer.

There are a few main classes to look at for the card code. CardFactory(s) contain almost everything that deals with spell effects or abilities that activate and do something. GameAction and GameActionUtil contain continuous effects. Beyond that, there is card-specific code strewn all over the place... depends on what the card function needs to do.

Re: Card coding

PostPosted: 18 Aug 2010, 13:34
by friarsol
One thing Rob didn't mention is that the structure of the card appears in the cards.txt file which is parsed by the CardFactory files. Unless a cards abilities have been keyworded, there will need to be some additional code added into the appropriate CardFactory file. We've had a big push lately to try to group abilities into types so we can code similar abilities all together as a keyword. I have similar coding experience (C++/C#) and you'll be fine coding Java just like it was C# in a majority of circumstances.

Re: Card coding

PostPosted: 18 Aug 2010, 14:07
by zaroblan
Thanks for the response Rob and friarisol!
The code and cards.txt look pretty easy to understand.
Just a quick question. Once I have added cards to the txt file what is the next step?
It would be really handy to have some kind of developers guide.

Can I edit the cards.txt file that was included with the last release (7-16) and add simple type cards and they would be available in the game?

Is there a free java compiler I can use to build the application to test my changes?

Re: Card coding

PostPosted: 18 Aug 2010, 14:08
by Chris H.
Every card has some data located in the cards.txt file. This is a good starting place. There is a list of keywords on our forum and you should examine the listing.

Much of the card (and keyword) code can be found in the CardFactory class files:

    CardFactory_Auras.java
    CardFactory_Creatures.java
    CardFactory_Equipment.java
    CardFactory_Lands.java
    CardFactory_Planeswalkers.java
    CardFactory.java

Re: Card coding

PostPosted: 18 Aug 2010, 16:04
by Rob Cashwalker
It's real tough to spend the evening speaking fluent Java, then have to switch gears in the morning to VB - Like I forget to write "Dim" a lot....
Also interesting - I don't forget the ";" as much in Java as I do in Perl... and I don't accidentally use it in VB.

The Java runtime environment is all you need to "compile". We mostly use Eclipse, which handles the compilation and debugging. There's a thread here for getting started with eclipse and pulling the SVN archive.

Re: Card coding

PostPosted: 20 Aug 2010, 18:13
by mtgrares
zaroblan wrote:Forge has become a very large part of my Magic life and I would like to contribute.
I think that's cool. I'm glad that you enjoy Forge so much. :D