0
Design question for RPG
For my game I need many different monsters and a factory class that can return random monsters. Should I create an Enum MonsterType with GOLEM, SPIDER, DRAGON and so on (would be easer to maintain) or should I use inheritance (would be difficult to return a random monster)? Monsters in my game have an Attack, Defense and HP stat and some weapons are effective against specific monster types, like fire is effective against Spiders. Thanks in advance. :))
3 Respuestas
+ 7
You should use Enum, It's easier to work with them, especially for your case
+ 1
If the amount of types is small sure, if not look into databases
0
One advantage of the inheritance could be, that classes can implement interfaces like Tameable, Venomous, Lootable or something (I do not have some yet, but maybe I'll implement such features later). Is there a solution for that problem with the enum style?
The data base solution is a cool one, since you can easily add new monsters. But it's way harder to create, isn't it? Is there a simple free data base that's accessible with Java?