Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Messages - ghost

Pages: [1]
1
Programming / Handling item properties
« on: July 29, 2009, 10:02:44 PM »
I'm trying to find a good generic way to implement item properties for my roguelike (using C#). Right now I have an Item class that contains the basic information shared by all Items (name, etc). I would like a way to store a list of properties, but I want to leave open the implementation of those properties.

I thought about creating an ItemProperties class, and having each Item contain a List<ItemProperties>. This would avoid a whole mess of flags in the item class. The problem I'm having is that I'm not sure how to go about designing the ItemProperties class itself. Lets say two Item Properties are IsWeapon and ProcsOnHit:

For IsWeapon, I probably want to store the weapon type, damage, # of hands to wield it, etc.
For ProcsOnHit, I probably want to store an % chance to proc, and maybe a reference to some type of effect.

How can I 'fit' both these into the ItemProperties class? Subclassing seems to defeat the purpose of having a generic ItemProperties class in the first place..

Pages: [1]