So I'm creating a rather generic strategy game similar to Warcraft or League of Legends, which needs to have:
- a
Player
class for representing the users playing the game - a
Character
class for the character the user is controlling (champions in LoL, heroes in Warcraft) - a
Spell
class for the spells each character has
Also, each player can own multiple characters, but only one can be active at a time (for now at least...)
So the design issue I'm having is with defining the characters and spells:
I want there to be "presets", similar to how Warcraft and LoL have predefined sets of heroes/champions + spells, i.e. you don't get to choose which spells you want for your character, but you choose a character and it has its own unique spells. And multiple people can pick the same character, in which case they have the same spells too, just on different levels.
First I thought to just create Character
and Spell
classes, but it's not that simple, since I want it to be easy to define new characters, and defining a character isn't as simple as just creating a new object like this:
char = Character(name='Warrior', spells=[...])
Since I want every player who wants to play "Warrior" to have the same set of spells (every warrior should have FireBall
spell while mages have FrostBolt
, for example) and same name (Warrior), but different instances.
How should I define something like this? I'm using Python 3.5, but any generic design pattern to solve this is more than welcome.