I am trying to write a kind of a trading card game here, in some way, it is similar to Magic The Gathering, or the Yu-Gi-Oh! card game.
For those of you who are not familiar with it, basically, in the game, there is a special kind of card (Spell cards/ Trap cards/ etc.), which have special effects that can bend the rules of the game. What I totally have no idea is, how to implement the logic of these cards. I have some idea of storing the card's data with some flags that can signal what kind of ability it has, but that would be very limited in what it can do (only some simple stats modification, maybe).
To give you an idea of what kind of effects these cards can have, here is some example of the spell card effects that are present in the Yu-Gi-Oh! card game:
- Revive a creature that has been destroyed
- Take control of the opponent's creature
- Modify stats of the creature based on some conditions (e.g. Number of creature with certain names that have been destroyed)
- Special summon a certain creatures if the some conditions are fulfilled.
- Fuse two or more creatures into a stronger creature.
- Immunity to some of the special cards' effect.
Konami has made several video games of the game, complete with the AI and thousands of cards variety. I don't think it is actually possible to hard-code the entire database, is it?
Now, of course what I am trying to do is in no where as complex as those games, but I am curious, how do they implement these?