Thursday, 2 February 2017

Creating the item database

Inventory Object Constructor Classes:

Firstly, I need to create a constructor class that will define the properties shared by all objects. A weapon would require stored data determining it's attack however potions would have no such requirement. A potion would require stored data to determine it's quantity; as would the weapon.

There are four data types I believe all objects would require; a name, icon, description and quantity. You may question that items require a value to transact with merchants however quest items wouldn't function in this fashion.

I start by creating an empty class that doesn't inherit from mono-develop. I add in the four data types and then add a public constructor method. This method contains the values required to define the class. It's called while creating a new class instance. I finish by adding multiple virtual methods, known as 'getter' methods, to allow other classes to read the class variables.


I need to create multiple sub-classes that inherit and expand from it to create unique inventory objects. I have created 'armour', 'consumable', 'merchant', 'quest', 'ring' and 'weapon' sub-classes. As all classes operate in the same manner I will explain one of these sub-classes which will provide insight towards how they all operate. I will used the 'consumable' class as the example.

A 'consumable' object is something which can be expended for personal gain. This encapsulates items such as potions, cuisine and drinkable liquids. In order to account for all the multiple usage of these items I need to implement multiple class constructor methods. 

Each constructor will inherit and expand upon the original constructor outlined within the base class. This means a consumable item will contain, minimum, a name, icon, quantity and description. 

If an item is consumed for instant player gains it would require a stat increase value. If an item is consumed for small gains over a period of time it would require a stat increase values and duration time. An item such as an antidote would require neither. It's for this reason I need to implement multiple class constructor methods.


Constructing a database:

This is actually fairly straight-forward therefore I won't explain in too much detail. The short explanation is that as all my methods extend from a base object class therefore I am able to add all sub-class items into the same list. 

This list will be loaded upon start up to store the in-game objects values eliminating the requirement to create items during run-time. I will be able to match the interacted item to an object within the database and store a copy of it to a localised list.


No comments:

Post a Comment