Page 1 of 1

Card Scripting Docs

PostPosted: 16 Mar 2012, 09:04
by satsujin
Hello Folks,

I just found Forge and it looks very interesting but I was wondering if there was a more definitive guide for the scripting of cards in cardsfolder.zip than the wiki API page on slightlymagic
Also, could anyone point me in the direction of which java class handles the parsing of the card script? From what I can tell, ReadCard.java just reads the file cards.txt which has limited cards with only Keywords and no script and not the whole selection in cardsfolder.zip. In fact, nothing seems to point to the files in cardsfolder.zip.
I believe I have the latest version of Forge(1.2.4) but my source folder does not seem to contain some java files mentioned in the blog like CardFactoryCreatures. Where can I get the latest source build?

Thanks in advance :D

Re: Card Scripting Docs

PostPosted: 16 Mar 2012, 09:50
by moomarc
satsujin wrote:Hello Folks,

I just found Forge and it looks very interesting but I was wondering if there was a more definitive guide for the scripting of cards in cardsfolder.zip than the wiki API page on slightlymagic
Also, could anyone point me in the direction of which java class handles the parsing of the card script? From what I can tell, ReadCard.java just reads the file cards.txt which has limited cards with only Keywords and no script and not the whole selection in cardsfolder.zip. In fact, nothing seems to point to the files in cardsfolder.zip.
I believe I have the latest version of Forge(1.2.4) but my source folder does not seem to contain some java files mentioned in the blog like CardFactoryCreatures. Where can I get the latest source build?

Thanks in advance :D
Unfortunately there's nothing more definitive than the wiki with regards to the scripting API. Generally speaking, finding cards similar to the card you trying to script is a good starting point, then expand with what you need from the wiki, then if there's still something you're not sure of ask in the Card Development Questions thread here. Once you've been doing it for a while you generally get to something that the current api can't handle so you start digging into the code, and once you're in there, there's no going back. In there you'll either find that what you need exists already but hasn't made it to a card or the wiki yet, or start adding things you need. Its a really helpful bunch of guys leading the development, so ask away.

With regards to the source code, it can't be developed straight from the download version. You'll need to download it from svn. The wiki does have thorough instruction for getting the dev environment up and running, so check out http://www.slightlymagic.net/wiki/Forge#Development and in particular How to get started developing Forge

Re: Card Scripting Docs

PostPosted: 16 Mar 2012, 10:12
by Chris H.
The wiki instructions are not up to date. I had planned to add some new material but have been busy recently.

Version 1.2.5 can be found at: Forge Beta: 03-09-2012 ver 1.2.5 rev 14663.

Re: Card Scripting Docs

PostPosted: 16 Mar 2012, 10:52
by moomarc
Thanks Chris. Hadn't realise that it had changed.

Re: Card Scripting Docs

PostPosted: 16 Mar 2012, 13:33
by satsujin
Thanks guys! But I'm still wondering which parts of the source handle parsing the script. Is it AbilityFactory.java? 'cos I don't have that file. The link to the 1.2.5 beta build doesn't contain any source files either. I suspect I may have downloaded a prior version of the sourcefiles which is why I'm missing classes like AbilityFactory and CardFactoryCreature that are mentioned in the blog.
Also, how does SVars work? The wiki makes it out to be some sort of metadata tag but cards like Abeyance show effects(like DBDraw) being listed there.
Sorry if this is a repeat post. I typed it again since I couldn't see my reply listed in the forum.

Re: Card Scripting Docs

PostPosted: 16 Mar 2012, 13:47
by friarsol
satsujin wrote:Thanks guys! But I'm still wondering which parts of the source handle parsing the script. Is it AbilityFactory.java? 'cos I don't have that file. The link to the 1.2.5 beta build doesn't contain any source files either. I suspect I may have downloaded a prior version of the sourcefiles which is why I'm missing classes like AbilityFactory and CardFactoryCreature that are mentioned in the blog.
Also, how does SVars work? The wiki makes it out to be some sort of metadata tag but cards like Abeyance show effects(like DBDraw) being listed there.
Sorry if this is a repeat post. I typed it again since I couldn't see my reply listed in the forum.
As moomarc stated below, the releases do not come with source, they only come with the jar (executables) and resource files.

Most of the scripting is handled by the AbilityFactory.java and related classes that start with AbilityFactory.

SVars are just string variables that sit on a card. Generally these are meta-data, but sometimes we need to use them for nesting abilities (such as Abeyance); otherwise, the card would have difficulty parsing where one ability starts and the next began.

Re: Card Scripting Docs

PostPosted: 16 Mar 2012, 13:52
by Chris H.
satsujin wrote:Thanks guys! But I'm still wondering which parts of the source handle parsing the script. Is it AbilityFactory.java? 'cos I don't have that file. The link to the 1.2.5 beta build doesn't contain any source files either. I suspect I may have downloaded a prior version of the sourcefiles which is why I'm missing classes like AbilityFactory and CardFactoryCreature that are mentioned in the blog.
`
Follow the instructions that are found on this wiki page:

How to get started developing Forge

and this will provide you with the instructions that are needed to pull a copy of the most recent source files to your computer. These instructions assume that you will be using Eclipse as a development package.

Re: Card Scripting Docs

PostPosted: 16 Mar 2012, 13:59
by moomarc
If you downloaded the source from anywhere other than the source linked to in the wiki, it was old source. And it looks like CardReader.java does the parsing. (Edit: Chris beat me to it for the second time today! :mrgreen: Anyway...)

With regards to SVars, its basically any additional data including SubAbilities. In the case of Abeyance (a rather complicated one to start with :D ), the svar DBDraw is a subability of the effect spell. The svars STCantBeCast and STCantBeActivated are abilities added to the effect card. To break the card down:
* Name:, ManaCost:, Types:, Text: and End are on all scripts and self-explanatory.
* A:SP or A:AB differentiates between a cast spell or activated ability.
* "A:SP$ Effect" tells the engine that its an Effect AbilityFactory.
* The next parameters in the line can be in any order and are specific to the AF in use.
* Each ability can also have a subability designated by "SubAbility$ variablename" which tells the engine to parse SVar:variablename next.
* Subabilities can have their own subabilities.
* The other 'factories' you'll see are triggers (lines start with T:Mode$), static abilities (S:Mode$) and replacement effects (R:Event$)

The wiki covers each of these fairly well, this just explained the basic structure.

Re: Card Scripting Docs

PostPosted: 16 Mar 2012, 17:07
by satsujin
I downloaded all the source I could get my hands on using TortoiseSVN since I already have a Java IDE(NaviCoder) and getting Eclipse just to get the SVN would prolly be a waste. I'll look through it, daunting though it seems, and see what turns up. Like I said, this looks interesting. Thanks to all of you. Btw, how are you all thanking each other officially on the forum?

Re: Card Scripting Docs

PostPosted: 16 Mar 2012, 17:35
by moomarc
Next to the 'Quote' button on each post is the thumbs up button used for thanking someone if you don't want to make a new post in response.

Any other questions about the code or general Forge stuff, just ask and someone will be able to help.