Coding Cards in C Tutorial
Before you start coding new cards, make sure you know the basics of how to add non-coded cards. This can all be found in the basic tutorial, level 0.
Getting Started
The hardest part about coding cards in C may be getting started! These are the steps I followed to get up and running. Several of them may be unnecessary, but it's he only way I know. (I did this in Win XP)
- Download and install Camelbox (http://www.softpedia.com/progDownload/CamelBox-Download-105269.html)
- Choose to install all of the components offered, and make sure camelbox/bin is added to your path.
- Download the latest copy of the manalink distribution.
- Unzip the distribution into c:\magic as well as c:\camelbox\bin. (you should now have a c:\camelbox\bin\src directory with lots of stuff in it, as well as c:\camelbox\bin\build.pl)
- Make sure that yasm.exe and make.exe are in that directory.
- Open up the command prompt (programs->accessories->command prompt) and cd c:\camelbox\bin
- Run 'perl build.pl' from the command line. The code should compile without errors.
Adding a New Card
Now we'll try to add a trivial card, Rorix Bladewing. This same card is added in the tutorial, level 1.
- Open src\cards\cards.c in a text editor.
- Copy and paste any other card function (they all start with card_), and change the name of the function to card_rorix_bladewing.
- Delete all of the code in the card except the function declaration.
- Rorix has 2 coded abilities, haste and legendary. Look at the API for Magic Coding in C and see if those functions are available.
- They are both available in the API, so just add calls to those functions in your function.
- Your code should look like:
code...
- Run build.pl from the command line. Since we are creating a card for the first time, also pass to build the name of the card. I.e. build.pl rorix_bladewing
- Note the address at which rorix is added.
- Hopefully everything compiled. If not, fix any syntax errors and try again. When you call build, though, do not pass in the name of the card again. That is only required the first time.
- Open SkyMagic Editor and add your card. The address mentioned earlier is the code pointer for your card.
- Save, run csv2dat, etc. Your card has been added. Congratulations.
