What would be a quick and dirty way to store a bunch of items for a video game?

#1goldelitekingPosted 4/9/2013 6:29:05 PM
I'm making a strategy RPG similar to Fire Emblem in C#, and I was wondering what would be a good way to store the stats for a whole bunch of items? For example, you can have an Iron Sword with 8 attack, 6 Weight, C rank, etc.

Right now, I just have an Iron Sword class that inherits from a base Weapon Class, but I don't want to make a new class for every unique weapon I plan on having in the game.
---
When Alexander saw the breadth of his domain, he wept... for there were no more worlds to conquer.
#2OrangeWizardPosted 4/9/2013 7:31:20 PM
I normally have one Stat class, and a few enumerations to differentiate the instances.

In the enums I have all the different types a weapon can be. If it's a sword, or a spear, or an axe, or a dagger, etc.

Then I have an enum which holds the types of damage. Fire, lightning, slashing, smashing, throwing, etc.

My stat class has one of each enum, then the regular attack, strength, defense, agility, etc.

Every weapon, armor, enemy and playable character has this Stat class. I just switch the enums around.
---
Trolling and making valid arguments are not mutually exclusive things.
#3Skel1Posted 4/10/2013 5:49:27 AM
Nested arrays/maps. Easily traversed, easily serialized, and human readable.
---
http://patrickavella.com/ <> I'm on the intertubes
http://twitter.com/patrickavella <> http://facebook.com/patrick.avella.blog
#4ReconditePhreakPosted 4/10/2013 9:55:26 PM
First, create an XML document to describe the different weapons.

Then come up with a DTD that rapes your cat whenever it detects an error in the xml schema.

Then, after getting a new cat, write an XSL transform that converts the XML into C (for speed), then use C++/CLI to pull in the C interface and interface it with C#. Make sure you interop across the C++/CLI and the C# boundary as much as possible to speed up your program (since the C is so fast, the more times you cross that boundary to execute the C, the faster your program will be). And the more memory you pin before you interop, the better.

Once that's done, tada, you have a data driven, super simple, super fast way to describe weapons. The fact that your cat quit humping your leg is just a side benefit.
---
Believes the individuals who report to moderators wish they had more control than they do.
#5goldeliteking(Topic Creator)Posted 4/11/2013 8:36:47 AM
I can't do that. I'm not going to abandon my cat after it goes through such a traumatic experience.
---
When Alexander saw the breadth of his domain, he wept... for there were no more worlds to conquer.
#6Skel1Posted 4/11/2013 8:54:46 AM
Now it sounds like a parody of /r/programming
---
http://patrickavella.com/ <> I'm on the intertubes
http://twitter.com/patrickavella <> http://facebook.com/patrick.avella.blog
#7GoatJugSoupPosted 4/11/2013 5:38:53 PM
the dirtiest (and probably quickest) way you can store a bunch of items would be csv.
---
http://psnprofiles.com/goatjugsoup1278
GW2 Character Name: Ranger Goat of Yogi, Guild: Knights of Chicken
#8ReconditePhreakPosted 4/12/2013 8:14:46 AM
Now it sounds like a parody of /r/programming

20 y/o's can be experts too, they read the books!
---
Believes the individuals who report to moderators wish they had more control than they do.
#9ReconditePhreakPosted 4/12/2013 8:51:08 AM
Actually, related to that, I just came across the following on reddit: http://www.reddit.com/r/technology/comments/1c78vk/rumour_amd_to_unleash_a_5ghz_cpu/c9dqr43

As a Python developer having to live with a global interpreter lock making parallelization impractical, I welcome our higher clock speed overlords.

And further down, he also said this:

There are ways to mitigate the issue, like multiple processes, but that involves using some heavy handed IPC that isn't necessary in languages with native real threading. It adds to development time and makes debugging more difficult, but it is a viable option for those willing to take the time necessary to implement it.

Yes, he did just say a shared nothing approach to concurrency adds to development time and makes debugging more difficult.

What you're witnessing is a dumbass being given the ability to voice his opinion on the internet.
#10flussencePosted 4/12/2013 9:53:29 AM
goldeliteking posted...
I can't do that. I'm not going to abandon my cat after it goes through such a traumatic experience.


The clever part is once you implement it you can use this system to store your broken cats too.
---
rawr