Me and a friend are trying to make an RPG in Java, while we are learning the language, and we have been discussing the character implementation. We would like to know which is the best solution in computational and expanding criteria s.
The game will be something like Final Fantasy 6. We would have a lot of different characters, each having their own stats and 3 different abilities. The stats would change frequently, and be saved for future reference. It's not supposed to have two identical characters.
Option 1: My idea defends that there would be a class "Hero", and a class to every character that would extend Hero. For example, if I have 10 characters, there would be 10 classes that extend "Hero". This character class would contain all variables concerning stats and a method for each ability. We would implement a singleton pattern, to assure there is only ever one instance.
Option 2: For my friends idea, the object "Hero" would have several attributes, the more important ones being for name, stats and character class. While name and stats can be summarized as simple variables, a character class is manifested as an object of its own tied to a specific hero. In short, an instance of a character class is bound only to one "Hero", but many heroes can have a common character class. For example, Josh and John can both be "Fighters", but they don't share the same instance of the character class object; they're just similar in functionality.
A "Hero" must have a character class in order to work properly, therefore his creaion would demand his own name and the name of a character class.
This method guarantees much higher flexibility when it comes to creating heroes, since the use of generic character classes (having many "Fighters" in a party, for example) becomes possible; in fact, this idea of character classes can be expanded for use with enemy units. However, it will require a bit more processing power.