All characters have abilities, but not all have Magicka. |
So that means that the Character class should have the ability member, and all other classes should inherit it.
If some of the classes need Magicka, then create an abstract class called Magical which has the Magicka member. Then there could be 2 possibilities: 1. Magical is derived from Character, so classes that need magic can derive from Magical and still have all the properties of Character; 2. All classes that need magic can inherit from Character and Magical - but that is multiple inheritance and could cause other problems.
I am going to say this yet again:
Write down in simple English which characters you are going have, and the things they can do, and how they interact. Only have 1 Player, 1 Enemy and 1 Weapon. Set up functions to implement how they interact. Keep it as simple as possible, get it working. Although
againtry provided an excellent example of working code, showing race and gender, these things are surplus from the POV of starting with the most simple example. Consider leaving them out for now, but nothing stopping you adding that in later.
I agree with
againtry you need to learn from a reputable source. Learn simple things first, then figure out how to combine them to do more complex things. You could be hampering your learning by taking on something like an RPG game, which sounds simple, but in reality it isn't, it becomes complex very quickly.
What I said before about how complex RPG games can be: Imagine you have only 2 players (on your side), and 2 Enemies against you, and your players have the same type of Weapon, and the enemies have the same method of attack. Already we have 8 interactions !! As soon as you increase the types of Weapons and types of Characters, this number of interactions grows quickly, never mind other complications such as magic.
One could get around this by only having 1 large Enemy, and lots of instances of a single type of friendly character (Bowmen say)which all have the same type of weapon (arrows). Introduce some randomness into the effectiveness of each shot, and see how long it takes for the enemy to die. That way, interactions are kept to a minimum, but it is still a little interesting, and reasonable first step in your gaming journey.