Sometimes thinking about a Magic card really confuses me. Generally a card is a spell right? And if that card is a creature, that spell generates a creature. The confusing part is that the card represents the spell for the creature and the creature itself. This isn’t confusing if you have physical card, but it does confuse me, a Magic programmer. And cards don’t go on the stack, only spells do.
The stack is the only zone that doesn’t hold cards. Technically the stack only holds spells and abilities. MTG Forge version 1 tries to stay true to the rules, no Card objects can be added to the stack, only SpellAbilities. (All spells and abilities are represented by a SpellAbility object. This object implements the functionality of the card. Using Wrath of God as an example, its SpellAbility would destroy all creatures.)
Since Magic is all about moving cards, it is difficult when you play a card to move it from your hand to the stack, since the stack doesn’t hold cards. I decided that I would let the stack hold cards and each Card object would hold a SpellAbility object. All I am really doing is swapping Card and SpellAbility. Currently only SpellAbility objects are added to the stack but and they hold a reference to the card that they represent.
Allowing the stack to hold cards makes moving cards much, much easier. The stack is a zone but you had to treat it as a special exception since it didn’t hold cards. Now I can write a simple moveCard() function that will work all the time.
moveCard(Card card, String zoneTo, String zoneFrom)
Incantus, another Magic program, adheres strictly to the rules and each card has characterstistics. Below is taken from Magic’s comprehensive rules.
201.2. An object’s characteristics are name, mana cost, color, type, subtype, supertype, expansion symbol, rules text, abilities, power, and toughness.