Diapolo10 / RPGenie

A set of tools to help you develop RPG games in Python
MIT License
29 stars 9 forks source link

Separating Player to Character and Player (extends Character) #36

Open Diapolo10 opened 7 years ago

Diapolo10 commented 7 years ago

I'm not sure why I didn't do this originally, but the Player class should be divided to a more general Character class and have the Player class simply extend it. I'm still thinking if a separate Enemy class is necessary, although one could potentially be used as a shorthand for a Character with aggression enabled.

sbordeyne commented 7 years ago

The general way to do it is having an Entity class, that defines health, inventory, stats etc, have an EntityPlayer class that defines every player-related attributes and have every enemy inherit the Entity class.

j9ac9k commented 7 years ago

@Dogeek would the entity class be effectively a metaclass?

Diapolo10 commented 7 years ago

That is actually a valid point. 🤔

j9ac9k commented 7 years ago

@Diapolo10 can I ask why you want to break up the two classes? I mean, do you see see the Player class inheriting from one of multiple Character classes (or vice versa?).

What do you envision to be class attributes of a Player object vs. what do you think would be a class attribute of a Character object?

Diapolo10 commented 7 years ago

Well, what I'm thinking right now is basically that Character refers to any entity that a developer might want to give their own stats, whereas Player is a more specialised Character that is only controlled by the player and has access to, say, a quest list or a personal item storage (bank?).

The reason Character still has access to Inventory would be that it'd be easier to develop a "realistic" looting mechanic, in which an NPC wearing armour or weapons would drop them (or randomly some of them) on death. In fact, incorporating the LevelMixin into the Character class is another idea of mine, in which NPCs could potentially level-up during battle as well. Of course, this would be an optional feature, and I may end up creating a new class just for that.

j9ac9k commented 7 years ago

@Diapolo10 correct me if I'm mistaken, but you envision something like

Character

a Player, is a Character, but in addition to having everything the character has, t also has

So would it be fair to say that the difference between a Character and a Player is that a Character can be a NPC, where-as a player is the object that has everything a character has, plus whatever attributes would be needed for that Character to be controlled by a human?

Diapolo10 commented 7 years ago

@j9ac9k More or less, yes.