Hi everybody,
After a short pause i recently picked up programming for fun again. I am currently working on a collectible card game (like MtG but then with a somewhat smaller scope ;-).
The thing is that i am unsure how to create my class structure. Right now i have a class called Card and some subclasses for (for example, when staying in MtG terminology: an Instant).
However, when i am adding my cards, i have to use a lot of Switch statements. For example (still using instants from MtG):
Switch (card)
case Lightning Bolt:
dealDamage(3)
case Terror:
destroyCreature(creature)
Of course this is completely impossible to manage with a lot of cards. What would the class structure of MtG look like:
- Object
- Card : Object
- Sorcery/Instant/Creature : Card
- Terror, Lightning bolt, etc : Instant
So in the end you would get approximately 500+ classes. That doesn't feel right either.
What is the solution here?
Thank you very much in advance!