I'm designing a game where there is a relatively small set of items. A single player holds an inventory of item slots. Each item slot contains a single item. The inventory allows you to use the item directly, move item around the slots (to organize), equip the item (weapon), and lastly, to combine compatible items together.
I've come up with the diagram below:
Where I'm having trouble is combining. To simplify the game, the game will only do Health+Health, Ammo+Ammo, Weapon+Ammo, Prop+Prop.
Where should I check if the above is permitted? Should Inventory check, or should I delegate the checking to the items themselves?
If I have a green health item and a red health item, it would double the strength of the green potion (increases HP) due to the red health item. But what if the player tries to do: G+G+G+G+G or G+R+R?
I can see that with this design, I run into the problem of having a health item as an (subtype).
For Props, they're simply items used in the game, like keys, cranks, etc. Sometimes two props can be combined as one.
All combinations are designed. As in, the player wouldn't come up with a unique item combination.
Edit 1: The example, with health items, G+G+G+G+G implies that there's a limit as to how many green health items can be combined together. For example, the green health item has a HealthItem.health_sum=.40
(40% of your HP). After the third combination, it becomes meaningless.