Quote:
2) Instead of a direct type-query like GetItemType(), create capability queries, like isWieldable() which might return true for Weapons and false for all other Items. This gives you extra flexibility, because you could e.g. make Potions, Wands and Scrolls - but not Armor or Weapons - be isHoldable(). Sometimes, this points to a need to add a level to the inheritance hierarchy (i.e. HoldableItem), but sometimes it's not that clear-cut. But if you can avoid this approach (in favour of a better-designed inheritance scheme and/or the build-in RTTI with dynamic_cast), then you probably should avoid it. It often quickly degenerates into implementing your own RTTI instead of letting the language do it for you, and anyway you usually want member functions to do stuff(TM) when possible.
Note that the capability to use an item is perhaps the most generic method of all. A potion, when used, will apply its affect to the user. When you use armor, it typically means you are equiping it. When you use a weapon it has a dual meaning in that you can either be equiping it, or actually using it. In this case I think the former meaning is more appropriate. So now, instead of having "isHoldable" and such, you have simply an interface that has a Use method. Now, this method can be customized for the derived types to perform the action expected, and the default implementation would simply inform the user that the item is not usable (such as random treasure, quest items that have to purpose, etc.)
At the same time we must think about other interesting possibilities, such as dual weilding. In such a case, how does one determine which is the off hand weapon and which is the primary? This would require a change to the above design, perhaps.
Then there are monsters. How does one determine the stats of a monster? Can a monster not use items? I would hope that they would, since that certainly makes it much easier to implement some features, for instance:
"The goblins of Ar'Gathul typically are found in groups of 10 to 15 males, ruled over by a large female. The males typically carry wooden bucklers, and a short sword. The females are usually warrior and typically weild a long sword. Due to the small stature of the average goblin, the female weilds the long sword as though it were a great sword. The long sword usually been enchanted with a weak fire spell. Some females, though, do not have a particularily strong magical aptitude and thus weild regular short swords."
Now, would we really want to build two different types of Ar'Gathul goblin females? One with an enchanted fire sword and one without? Nah... probably not. Instead we would rather have a long sword with an enhancement and simply equip some with that long sword and others with a regular long sword.
Just a few thoughts.