I'm working on implementing an RPG engine, and I'm trying to figure out the best way to implement equipment. The really tricky part is the hand slots.
It would be easy to give a character one hand slot for a weapon, and one off-hand slot for a shield. But defining it that way would make it impossible to dual-wield, or to wield two-handed weapons. Giving the character two generic "hand slots" would allow for dual wielding, two-handed weapons is where things get tricky.
The obvious way to equip a two-handed weapon is by filling both slots with the same object. But then I need special-case code for calculating stat bonuses (you can't simply sum all bonuses from all slots, because the weapon's values will get added twice) and for removal (you can't just clear the item from one slot). If I only put the object in one slot, then calculating bonuses becomes easy again, but there needs to be special-case code to check whether the "empty" offhand slot is really empty or not.
Obviously I'm not the first person to face something like this. Two-handed weapons have been around in RPGs for decades. Is there any elegant way to handle the logic involved?