Hi,
I'm trying to build a console text based rpg as a learning experience, and need some advice on designing classes.
What I had in mind is having a basic character class for describing all "actors" in the game, like the player, as well as monsters and other npc's.
The character has attributes that are used to determine the success of all actions. The character should also have a set of skills, which all have a governing attribute and improves the rate of success on corresponding actions. For example melee(physical) for fighting, persuasion(social) for npc dialouges, investigation(mental) for finding hidden things.
Now, I'm not really sure how to design the classes. For example, I want to be able to create a character object, and then assign skills to it that it can use. Right now I'm thinking I'll create a Skill class, and then store it as a vector in a Character.
1 2 3 4 5 6 7 8 9 10 11
|
class Skill {
public:
Skill();
void action();
private:
string skillName;
int skillLevel;
string attribute; //governing attribute
}
|
1 2 3 4 5 6 7 8 9 10
|
class Character {
public:
Character();
void getInfo();
private:
int mental, social, physical; // character attributes
vector<Skill> skillSet;
}
|
My problem with this is, how to get the character to use the skills? Should I have an Action class to contain all actions? And maybe make Skill a subclass? Or should I make one class for each individual skill that contain functions for its actions? Or should actions be included as functions in character?
If I have an Action class separate from the Character, let's say a moveTo action, how would I get the Character to use it?