I am planning to start development on a video game based on a trading card game (think
Pokèmon Trading Card Game or
Duels of the Planeswalkers). The decks will be fixed, and I am not concerned about writing AI at the moment; however, what I am concerned with, is the logic.
Since I don't want to write a class for every card, I'd like to pull in information from a database regarding the cards statistics and abilities. This breaks down when you begin to think how each card can have non-ability rules text (in Magic, think of Flying as an ability and "Whenever this creature deals damage to more than one blocking creature, the blocking creatures' controller gains one life" as a non-ability).
I have determined that each ability will usually only occur at specific times, leading me to an event-driven solution. Typical events are things like: Entering play, leaving play, dealing damage, taking damage, attacking, blocking, becoming the target of a spell or ability,
et cetera. On these events, I want to check for the cards' abilities and perform whatever actions are required.
Taking the above ability into consideration ("Whenever this creature deals damage to more than one blocking creature, the blocking creatures' controller gains one life"), it would occur during the "deal damage" event. It would need to know if it was blocked, if it dealt damage to the blocking creature, and if it dealt damage to another blocking creature. If so, its controller would have a "gain life" event with a value of one (other shit could happen during this event, too).
Does anyone have any experience with something like this? I really don't want to write a scripting language for these cards, nor do I want to write complex scripts for every single card. I was thinking of using an aspect-oriented approach, but I'm not sure where to being looking for information on implementing it in a situation like this. As always, any help or suggestions would be appreciated.
