Monday, April 13, 2009

Plaintext Creatures and Cards.txt

If you don’t know what cards.txt is about, let me tell you. Cards.txt has a long listing of creature like this:

Raging Goblin
R
Creature Goblin Berserker
1/1
Haste

Simple creatures can be added to MTG Forge just by adding them to cards.txt which is read when the program starts up (runtime). At first cards.txt was just a simple way to save me some coding, versus coding all these creatures in Java, but cards.txt has evolved to support a number of regular abilities like haste and flying, as well as other abilities like cycling and “comes into play tapped.”

Cards.txt has become one of the most important parts of MTG Forge. Cards.txt has been expanded to include spells like Shock and other spells that damage creatures or players. Cards.txt supports a large number of “regular keywords” like regenerate, flying, defender, reach, first strike, double strike, flash, fear, landwalk, wither and indestructible.

Cards.txt also recognizes mana abilities. This is the text for Forest:

Forest
no cost
Basic Land Forest
tap: add G

Creatures can also have mana abilities like Llanowar Elves.

Llanowar Elves
G
Creature Elf Druid
1/1
tap: add G

And the mother of all mana creatures, Birds of Paradise, can be added by using cards.txt

Birds of Paradise
G
Creature Bird
0/1
tap: add W
tap: add B
tap: add U
tap: add R
tap: add G
Flying

Plain text is very powerful and should be used as often as possible. (I prefer plain text over XML but your tastes may vary.)

Words that cards.txt recognizes

Comes into play tapped.
Cycling:{mana cost}
Defender
Devour:{mangitude}
Double Strike
Fear
First Strike
Flash
Flying
Forestwalk
Haste
Indestructible
Islandwalk
KPump {mana cost}:{keyword}
Morph:{manaCost}
Mountainwalk
Plainswalk
PTPump {mana cost}:{+-p}/{+-t}
PTKPump {mana cost}:{+-p}/{+-t}/{keyword}
Reach
RegenerateMe:{mana cost}
Remove three spore counters from this card: Put a 1/1 green Saproling creature token into play.
SearchMerc:{manacost}
SearchRebel:{manacost}
Shadow
spDamageCP:{damage}
spDamageP:{damage}
Swampwalk
tap: add 1
tap: add B
tap: add G
tap: add R
tap: add U
tap: add W
TgtKPump {mana/tap cost}:{keyword}
This creature can block as though it had flying.
This creature can block only creatures with flying.
This creature cannot block
Trample
Unblockable
Vigilance
Whenever a creature dealt damage by this card this turn is put into a graveyard, put a +1/+1 counter on this card.
Wither

3 comments:

Jack Mixes said...

"Simple creatures can be added to MTG Forge just by adding them to cards.txt"

That has to be one of the coolest features of this program, right after quest mode I guess.

Forge said...

cards.txt had humble beginnings but I can't imagine MTG Forge without it now. Hopefully protection will be added soon :)

Arturo said...

Hello,

I think this file should be a parsable file, just like html is. Including tags would make the "coding" of cards far easier. And allow direct modification, as well as a program to write it.

By referencing abilities with numbers you could easily reference flying, haste and others... just as well handling corner cases like doran (which would be later on hard coded)

if you wanna chat, write me at arturo.san at est.fib.upc.edu