I've got a design problem. I'm doing a project for school, which is remaking a 2D game. I chose to make pokémon red which was originally for the game boy system.
Now in this game there are 165 different attacks, which are grouped by attackes who actually do the same but are less strong etc..
Anyway I've got about 50 different ways of how an attack has to be executed, some have to lower that stat, some have to raise another, some do this kind of damage, others do damage to enemy and the user, sometimes it inflicts a special status etc.
The way I solved this now is a method in the battle class where I check which group the attack belonged too, and then if a match was found, it executes the code it says right there. But this is so unbelievably messy. Right now I load the basic stats and names en which group of code they belong too from a textfile.
What I could do is to make an abstract class and then make 165 derived classes, one for each attack. That way I could just have an attack pointer of the abstract class type, but I can just call execute on it, and it will execute the code from the class the attack really is. But... 165 classes? Seems pretty messy to me too...
Another way would be to add things to my datafile, like flags of this attack can result in poisoning, and if so how much % chance there is to do so, etc...
Then I could write the code once en just check the flags what parts have to be executed. But in this case I would have alot of datamembers in the attack class, so I don't know if this would be a good idea as well.
I know there are design patterns which totally kick ass, but the only one we learned this year was the singleton, we will learn about the rest next year
So now i'm looking for some tips if there is a design pattern that I can use, or just general tips about how I could do this in a clean way.
I will be having the same problem with items later on, since each item does something different... .
edit: don't really know if this should be in this subforum or in game programming, didn't notice there even was a game programming section till after making this post
sorry if this should have gone in game programming :P



LinkBack URL
About LinkBacks





