I'm making a small text-based adventure in Objective-C. I have a
Player class with four properties which represent the player's attributes (
intelligence). I also have a
Weapon class. My goal is to put a weapon in the game that will increase the player's stats as long as it is equipped. How can I achieve this in an object-oriented fashion?
I could add a method to the
Weapon class that will increase the player's attributes, and call the method only when a flag is set to true (which I would set to true when initiating this particular weapon, and leave false for all other weapons I create), but that seems a bit messy and not particularly object-oriented. I recently learned about the decorator design pattern. Would I be able to accomplish my goal using decorators?