I'm new to object-oriented programming, and I'm struggling to think of OOP.
What I want to do is a game of RPG.
I have the Hero class (the user) which has such properties: name, hair_style, power. and these methods: speak, attack, defend
I want to add more methods (spells) dynamically, as the hero learn more spells.
I do not know what is the best way to do this. I can think of the following:
Create a class 'spell' and each magic spell to have a class extends from it and add to Hero a property of type 'spell' (must be an array). When the hero try to use some spell would have to try the entire array to see if there is such magic (method). (Probably wrong)
How did you do that? Ty