samedi 18 septembre 2021

OOP: How to "know" the object's type in this game design

Let's image for a game, I have this scheme

Item is what all the game's Item based off

Some Item like Sword implements IEquipable

Some Item like Potion implements IConsumable

When I am giving out a quest reward, I add an Item to the character. When I am listing out the character's inventory, I go through their List of Item. At this time, I only know I have some Item but no longer know that the Item is Equipable or Consumable . Basically, the Interface is no longer known to me. What design can I do in this circumstance?

Aucun commentaire:

Enregistrer un commentaire