Chimera Posted October 1, 2014 Share Posted October 1, 2014 I am just curious how other are referencing and storing data for things like items, skills, etc. I have created a base class for my items, a different class for weapons, armours, and accessories, but I am wondering if it just makes more sense to store them in a json file or large array? I have to instantiate all of the items which is just as or more work than if I just created a table and used that instead. Then I can also query the table more effectively, I am not sure how I would query multiple objects using one of their properties? Use this snippet of item data as an example.Index# Armor Defense Weight Resist Spell Price Equippable By01 Cloth 1 2 --- ---- 10 FI TH BB RM WM BM02 Wooden[A] 4 8 --- ---- 50 FI TH BB RM03 Chain [A] 15 15 --- ---- 80 FI NI RM04 Iron [A] 24 23 --- ---- 800 FI NI05 Steel [A] 34 33 --- ---- 45000 FI06 Silver[A] 18 8 --- ---- 7500 FI NI RM07 Flame [A] 34 10 Ice ---- 30000 FI NI08 Ice [A] 34 10 Fire ---- 30000 FI NI09 Opal [A] 42 10 Lit ---- 60000 KN10 Dragon[A] 42 10 F/I/L ---- 60000 KN Link to comment Share on other sites More sharing options...
xerver Posted October 1, 2014 Share Posted October 1, 2014 In the past I've done a couple things, if there are more complex objects I have put them into JSON files that I import into IndexedDB and can run more complex queries on. Other times I just embed the data in the app memory if there isn't a ton of it (e.g. lttp item data). Really depends on the browser support you are targeting, what kind of querying you need, etc. Link to comment Share on other sites More sharing options...
SuperMarco Posted October 1, 2014 Share Posted October 1, 2014 You have the choice, either use IndexedDB as xerver said, or you can use the localStorage of the browser. If you are looking to support most of the browser version I might advise you to go for localStorage (of course, if the user is cleaning his cache, he's fucked ^^').It really depend, but for you to have an idea, you can see which one is supported on which browser : IndexedDB : http://caniuse.com/#feat=indexeddbLocalStorage : http://caniuse.com/#search=localstorage In july I had to develop a website using IndexedDB but at this time, Safari was using the version 7 and it wasn't supported -_-', but now from the 7.1 it is. Or if you feel like it, you can use the socket to save it online ^^. Link to comment Share on other sites More sharing options...
Chimera Posted October 1, 2014 Author Share Posted October 1, 2014 I don't this game should be so large that I can't utilize the memory to store everything, so with that in mind I was thinking either a large array, or JSON should be the way to go. I don't necessarily need to query the item table, I am just trying to think of how you split the items available in shops across different towns. One method is to display them based on the relative level from the player, or have a field for each item like an item tier or something and then I pull all items in that tier, or have a different object responsible for it like where they are in the story or something. Not sure which to go with, but I am trying to keep things as simple as possible. Link to comment Share on other sites More sharing options...
Chimera Posted October 1, 2014 Author Share Posted October 1, 2014 Been perusing the repo you linked, really snooping is what I was doing, and it is helping me understand a bit better how I should be structuring and storing my data. I do have a question, how does the 'Define' tie into the dependencies? Is this something build into javascript similar to an import, or does this use a 3rd party library like requireJS or something? Link to comment Share on other sites More sharing options...
xerver Posted October 2, 2014 Share Posted October 2, 2014 Been perusing the repo you linked, really snooping is what I was doing, and it is helping me understand a bit better how I should be structuring and storing my data. I do have a question, how does the 'Define' tie into the dependencies? Is this something build into javascript similar to an import, or does this use a 3rd party library like requireJS or something? That repository is using require.js to organize code, that is what the define you are seeing is. Link to comment Share on other sites More sharing options...
Recommended Posts