Well, i'm writing a new base for myself at the moment, and it's in the stage where i'm about to start implementing interfaces and other stuff, but, i had an idea that popped up and im not sure if anyone thinks it'll be a good idea or not.
I'm assuming it is related to how RS does theirs.
Basically, what im thinking is having a class per item for example player items. This way, you can add states such as degraded state, different stats per different item etc etc.
I believe this is how RuneScape must do it, because for some things such as barrows different pieces degrade at different speeds when you wear them, so, if you bought 2 dharok platebodies and switched before the first one degraded, you'd still have the whole time for the second one to degrade.
My example would be like;
Code:
class Item {
int id;
int amount;
int state;
}
Then, you'd have declared for players;
Code:
Item[] playerItems = new Item[28];
It's an awkward idea, because you'd have to save the whole class instance and reload etc when the player logs in, but it's still feasable.
Anyone agree this would be a good idea to implement?
It'd also bring possible customisation to the game, such as being able to change stats based on item or something, like you could have an item where you can change the style that gives the most accuracy, such as switching stab with slash bonuses or something.
Servers like Hyperion already do this (the normal Hyperion doesn't store anything other than id/amount, but you could add additional attributes if required).
[Only registered and activated users can see links. ]
Originally Posted by veer
I think I know how to implement item tracking, and I think it's fairly easy.
Most items in game can be treated as what in the domain-driven mindset call value objects. These objects have attributes but no conceptual individual identity... you can see an example of this in the fact most private servers merely keep an item ID or some other reference to a definition (ItemDef).
It should be very clear items have been treated like this in private servers for some time now as it makes sense... an item ID or ItemDef reference are adequate because they are distinct from one another by their attributes, each item's definition.
When people exchange dollar bills, they generally do not distinguish between each unique bill; they only are concerned about the face value of the dollar bill. In this context, dollar bills are value objects.
The concept of value objects contrasts with that of entities, which are not defined merely by their attributes but yet by that very trait value objects lack, a sense of identity.
However, the Federal Reserve may be concerned about each unique bill; in this context each bill would be an entity.
What you can see here is that you are asking how to change items in game from value objects into entities... it is very much possible, but is it practical and worth it?
It'd require quite a change in the codebase. A simple item ID would not be adequate here as instead we would now need to track the identity of each item, distinct from their attributes. Something perhaps like:
Code:
public class Item {
private UUID id;
private ItemDefinition definition;
....
}
Each individual item in the game could be tracked now by their unique ID distinct from others with the same attributes.
Is it practical, though? Surprisingly so. Good luck.
For more on this stuff, [Only registered and activated users can see links. ]
As a side note, I'm a little surprised object didn't delve into this... I mean, he was the one who introduced me to DDD in the first place a couple odd years ago.
Servers like Hyperion already do this (the normal Hyperion doesn't store anything other than id/amount, but you could add additional attributes if required).
Originally Posted by super_
[Only registered and activated users can see links. ]
i think from his post he's merely interested in being able to retain state with instances of items (like the degradation of barrows items) versus the de facto canonical approach of treating items as value objects and merely keeping references to definitions e.g. using the item ID
i don't actually know how useful it would be, however... don't different states of items have their own respective ID?
Oh by the way the barrows degrading thing is based on your account not the item. If someone uses a "dharoks axe" down to the point where it's 1 point from degrading, and they give you it, it wont degrade until you use up your 'points for it to degrade'. They get around this by not letting you trade them (but that's how it would work).
You can try this by having multiple of the same barrows item at the same degradable state. Get one down to near degrading, put on the other one and it wll degrade instead.
Also @super_ how are you going to keep track of individual items, in things such as stacks? What if I had a stack of 2147M dharok's platebodies. Is the server really supposed to track each one is at what index of the stack? (This is another reason why jagex go the easier way).
[Only registered and activated users can see links. ]
Oh by the way the barrows degrading thing is based on your account not the item. If someone uses a "dharoks axe" down to the point where it's 1 point from degrading, and they give you it, it wont degrade until you use up your 'points for it to degrade'. They get around this by not letting you trade them (but that's how it would work).
You can try this by having multiple of the same barrows item at the same degradable state. Get one down to near degrading, put on the other one and it wll degrade instead.
Also @super_ how are you going to keep track of individual items, in things such as stacks? What if I had a stack of 2147M dharok's platebodies. Is the server really supposed to track each one is at what index of the stack? (This is another reason why jagex go the easier way).
So If I have two dharok axes and they're both at say the 75 mark I use one of the axes till it's one point from degrading to the 50 mark then I switch to the other axe and it will degrade as if it was the axe I used down to one point from being at the 50 mark?