Hey everyone,
I'm considering redoing the way my game handles skills.
Currently I have a bunch of boolean variables that are false by default, but that are set to true as the skill needs them (energy blast has causesDamage set to true, for example). Some skills have messages that the game displays when the skill is activated or when it hits a target as well. When a skill is used, it goes through a set of if statements for the different boolean variables to trigger all of that skill's effects, eg if damagesAttributes == true, then lowerTargetAttributes(), or if causesDamagee == true, then lowerTargetHp().
I think it might be better for me to change it so it is handled like this though:
I give each skill a number of effects, and each possible effect (CAUSES_DAMAGE and all that) is associated with a constant integer. Then a skill like energy blast will just need one effect (the aforementioned CAUSES_DAMAGE), but for more complicated abilities, I could allow for more complex effects, like the lightning bolt skill could have two effects: CAUSES_DAMAGE for the first one, and the second effect could be trigger CAUSES_PARALYSIS with a 1 in 3 chance or so. I could then give each individual effect within a skill its own message upon being triggered, so if lightning bolt does paralyze the target, I could have it say "The /targetCharacter has been paralyzed!" or something to that effect. Then when the actual skill is triggered, I could do a for loop for the number of effects that skill has, and put a switch statement for which effect it is inside, so I don't need to unnecessarily have the program go over every possible effect for every skill that gets used.
I don't know if I've made things clear enough for you to really tell how I'm doing this, but I'm a self-taught programmer, and I don't have a ton of experience, so I thought I'd ask, which method do you think is better? Is there another way I could be doing this that would be better than either method? My primary concern is that it has the versatility to do a lot of the things I want to be able to do with it, with simplicity being secondary.