Quote Originally Posted by arthurprs
you can't do something with copymemory and instancesize?
Not that I am aware of. Personally, I don't think that it would be wise to try this. :?

Jarrod:

I see what you say, and that form of system is very beneficial in a game framework. However, I am uncertain as to how I should implement this. Firstly, as you can see, my unit is woefully small and very spartan in features. What I am working with is an attempt to design a framework for inventory items in a RPG.

To sidetrack, slightly, I must confess that at OOP my skills are below average. I am good at writing classes, that's not the point. My difficulty is in tying everything together well and not the classes themselves.

What I am trying to do is this:
An item can have up to two bonus attributes. If a sword is particularly stout then it would have an attribute derived from the base Visitor model, the IAttribute interface, and it would then visit its parent object. This is not the trouble, currently, as I find this to be simple enough to implement on my own. The trouble is in purchasing.

Lets say there's a blacksmith with that longsword you've been eying for a few hours. It's stout and is well balanced, making it tough and easy to hit with. However, the smith has three of these items. In the data these would derive from a "TStackableItem" class where, in memory, there is only one item with a count of three. If I aim to buy this I cannot strictly duplicate the item and its attributes as a pointer, as the visitor attributes could change -- what if a wizard cursed the sword? -- at any moment and so must be unique to an item. I could easily enough say fItem.ClassType (a pointer to the class of class type) and call Create, then Assign the properties from the store's sword to the player's inventory. The trouble are the attributes, because I could do this too -- and I highly doubt that it works.

Unfortunately, all my ideas on how to duplicate and assign properties are all hypothetical. Because I am working with FPC there are a few inconsistencies with Delphi, without compatibility turned on, but there are usually parallel traits or at least a work around.

Would you help me plan out this series of classes? I am struggling with this and can't seem to wrap my head about all the classes there will be and how to make them duplicable, yet stackable, and containing their own unique traits. It's a wee bit complicated for someone inexperienced in the finer arts of OOP.

Far simpler to botch this than it is to do it right, unfortunately.