Jump to content
  • Advertisement
Sign in to follow this  

Data abstraction/Class Design

This topic is 1389 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts



I'm trying to tighten up my programming skills a bit. I usually end up with a module in programming wil different variables I need to keep track of... Not much, current step of cutscene (driven by select case counter in text game.) Small things like that. I also  have my main classes for room, hero, monster, text parser..


I'm just wondering about things like weapons, armour, items. Should these be objects to? I can figure out how to make things work, but I'd like them to be right, lol. I have a little trouble deciding weather something should be an objects or jut hard coded in the player...


like this in my player class:


   '' Skills
    Private _skillPoints As SByte
    Private _skillsLearned As List(Of String) = New List(Of String)
    Private _skillEffects As List(Of String) = New List(Of String)
    Private _skillMod As List(Of SByte)


Does it make sense for weapons to be objects stored as objects in inventory arrays?

Share this post

Link to post
Share on other sites

Consider objects, the less hardcoded it is the more you are able to extend the functionality of it (i.e. adding more items or adjusting items without touching code).


Item Object


Weapon Object derived from Item Object


Armor Object derived from Item Object


Inventory Object

  Item object container


Store weapons in Inventory Item container


Because you are setting the container to hold Item objects you are able to pass Weapons in there because it is derived from Item object. Now your character can have an Inventory object which keeps track of what he has on him.

Edited by wicked357

Share this post

Link to post
Share on other sites

Okay, so everything should have it's own class then, even skills? So basically put in oop if it's not a class it shouldn't be in your code?

Share this post

Link to post
Share on other sites

Then the question belongs to you... How in depth do you want your skills? Just a list of strings, I don't see why you would need that to have its own class. But if you want to get into skill levels, skill affects, how would you do that? It all really depends on how in depth your system is going to be. I would start out shallow till you have a firm grasp on it. Experience over time will tell you "Does this need to be its own object?" and how abstract do you need to make it.


For example of the items abstraction I pointed to you,


I load my items via a json file using boost json parser. The structure would look like this:



    "weapons": {

         "100": {

            "item_id": 100,

            "name": "Deathbringer",

            "damage": 10,

            "weight": 3,







Looks like an awful lot of information to try and store statically in non objects


I could easily go name, item_id and weight are going to be on every item, but damage however will only be on weapon. You could do something similar to Skills.


Like I said before it depends on how in depth you want to go. I am not saying it is always the right choice to make everything an object in cases like this I don't see why you wouldn't want it. Allows for easier extendability when adding something new you don't have to fly all over your code making changes every where you created a new item. Especially if you are iterating through an above like example of a weapons json file.

Edited by wicked357

Share this post

Link to post
Share on other sites
Sign in to follow this  

  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!