I'm making a video game and and I would like to know if my OO Inventory System has any flaws or oversightes.
Here is the the item system anything that can be stored in an inventory system is an item. The composition of the item class is a shield,a weapon, an engine, and a ship.
Item:
- Ship ship
- Engine engine
- Weapon weapon
- Shield shield
The ships class contains information on its stats(speed,armor,name,description) an is composed of weapons,a shield, an inventory, and one engine.
Ship:
- Engine engine
- Weapon weapon
- String name
- string shipDescription
- float speed
- float armor
- Shield shield
The Weapons class contains info on stats of the weapon it is Weapon:
- float rateOfFire
- int maxAmmoCapacity
- int currentAmmoAmount
- int rating
- float damage
- string name
- string description
The shield class Shield:
- int rating
- int shieldType
- float damageAbsorpotionRate
- float regenerationRate
- string name
- string description
- int rating
The Inventory class contains an array to limit the amount of Items it can store and two functions for removing and adding items into/out of the inventory list.
Inventory:
- Items[] items
- AddItem(Item item)
- RemoveItem(Item item
Item
contain a list ofIFeature
. Each feature, such as engine, weapon etc is then implementsIfeature
as well asIEngine
,IWeapon
etc respectively. If you then later decide you want a shield with weapon abilities, you create a feature class that implements bothIShield
andIWeapon
. Then, for example, to test whether an item behaves as an engine, you check if anIEngine
exists in its features.