As I mentioned last week, I have tried to put some effort in re-factoring my achievement/medals/upgrades system. No problems there, the functionality for it is somewhat more centralized now and not spread out in different classes. I have just one rub with it, my implementation seems too complex for the purposes right now. I’ve built it to accommodate more complex needs. My system at the moment is as follows:
- Theres the Achievement class, which e.g. holds the name of the Achievement but also a list of boolean values that describe the requirements for the Achievement.
- Then you have a list of boolean values that hold the state (relevant for Achievements) of the game world at the moment.
- And lastly you have the code that does the needed changes to the game world once an achievement is achieved.
Now, for my current Achievements a list of boolean values is a bit of an overkill. I’ve also been dissatisfied for not finding a practical way to create interfaces for those three elements, almost everything requires custom code. Of course once I have more Achievements built in, those interfaces might be more easier to see and build.
Now isn’t that interesting? Isn’t it?!