Closed Larinitus closed 3 months ago
Right now the inventory is coded as a javascript object that contains functions, however, I set it up to save to local storage, which only stores string versions of objects and then reloads it from the string. Basically saving and loading the inventory breaks the object. We either need to decide on whether we're changing the data structure for the inventory or if I write more complex code for specifically saving the inventory
I see. I'm fine to go with whatever you all think is best, but intuitively I would think that we should store a combination of numbers and strings. Numbers would include your stats numbers, the # of every item you have, and info related to quests. Strings would include current equipment, your class, your name (if we want to give people the ability to name themselves).
Note: Regarding quests, I'm envisioning a system where each quest has a numerical variable that indicates how far along a player is in completing the quest, and every time someone advances a step, you can add 1 to that variable. So for example, if a certain quest variable is less than a certain number, then a certain button will display one text, but if it is equal or greater than a certain number, then that button will result in another piece of text. But feel free to implement other ideas--there might be other ways to do this that are better.
I think we can convert the Map to a plain javascript object. A map is a little more clear in terms of naming what the object actually is -- and it is a map from item name => quantity. But a plain js object functions the same in our case, and the other small differences are irrelevant for us:
https://stackoverflow.com/questions/18541940/map-vs-object-in-javascript
Converting map to json is more annoying
fixed
There's some sort of bug with items. The Inventory page produces a "e.items.entries is not a function" error, and Monster Item Drops produce a "j.items.get is not a function."