Sign in to follow this  

Design consideration: Implementing items

This topic is 2572 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 have an Item class mapped out, but I'm unsure of implementation from here on. It seems that using only a single class could be difficult to manage. However, writing a class for each item which would always have the same values seems a bit boilerplate. How have you implemented items? I won't be using xml, but it may be possible to use a service to create items (or simply use CRUD). Any opinions are welcome.

Share this post


Link to post
Share on other sites
Item is such a generic term that you'll to specify exactly what context you mean the work "item". It could refer to anything from an inventory item in an RPG to any entity that exists in a 3D engine.

Share this post


Link to post
Share on other sites
One good approach would be to associate a lua script to each item type. Since items can vary greatly in complexity and application a very general approach is the best. Writing a script for each item would make it easier to add, remove and alter items.

Share this post


Link to post
Share on other sites
Quote:
Original post by Net-Ninja
One good approach would be to associate a lua script to each item type. Since items can vary greatly in complexity and application a very general approach is the best. Writing a script for each item would make it easier to add, remove and alter items.


Well, I'm actually using Groovy/Grails for the game. Scripts are supported by Grails, but that'd basically be a waste of time compared to simple CRUD support which would basically cover the same actions. It's definitely not something I'm against considering, though. It's really a technology-related question, though. I'm not sure how many people have overlapped Grails and game design so far.

Share this post


Link to post
Share on other sites
A lot of it depends on how complicated your items are.

Do they just give bonus to basic stats and armor? If so you can pretty easily implement with just a single class. Location, weight, bonus, type and description and that would be it. Now for magic items it can get a little more complicated.

I would suggest a base item class for weight, location, images, and the likes.

I would them have classes for armor, weapons, special magic items, potions. Those are most of the basics.

That keeps it pretty simple without making a class for everything possible.

theTroll

Share this post


Link to post
Share on other sites
Yeah, that's pretty much how my item class is right now. For a first release, I think that should manage fairly well, creating an item upon very specific circumstances. Additional types can be added later, but right now I have a 'list' of types the item can be which must be assigned upon construction, so that should cover even more.

Share this post


Link to post
Share on other sites
You could also use some mixed solution - basically your items could be implemented as a simple class with parameters (stats modification and so on), but with possibility to attach some scripts. If some of your items would be more complicated, or you would have to add item that would modify other stats, or just do something unusual, you could then attach a script to it performing this unusual behaviour.

Share this post


Link to post
Share on other sites
you are right SiCrane

Quote:
Original post by SiCrane
Item is such a generic term that you'll to specify exactly what context you mean the work "item". It could refer to anything from an inventory item in an RPG to any entity that exists in a 3D engine.


Share this post


Link to post
Share on other sites

This topic is 2572 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.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this