I'am building a small RPG. A character has multiple stats, like: strength, magic, archery and defense. Also a player can wear equipment, like a helmet, torso, legs, boots, gloves and a weapon. Each piece of equipment has it own stats. For example, a silver torso has 10 defense.
When the character has, say 15 defense, and he wears a silver torso, his defense will now be 25. Anyway, in order to wear equipment, it needs to be produced. At the moment I designed it with a Abstract Factory Pattern (see image).
The design has a lot of classes, with most of them are basically useless, like Bronze Helmet, Silver Torso et cetera, because they only have an instance of the class Stats.
Therefore, my question is: What is the best way to produce equipment, with less classes which are more useful. Since it is for a school project, I preferably want to make use of Design Patterns.
Aucun commentaire:
Enregistrer un commentaire