Arcanorum/rogueworld

Hotbar item order persistence

Arcanorum opened this issue · 5 comments

Task description

As per #180 the client inventory state needs to be modified to allow saving the current hotbar state to local storage when changed, and for the hotbar to then be populated with those stored item configs when the game is loaded.

References/notes

When the game is loaded, the client is sent the current state of the player's inventory from the server, which it then uses to populate the hotbar automatically from the first items in the inventory.

The inventory is a list of itemConfig objects, which detail the item type code, quantity/durability, and a unique id for that specific item (i.e. "81338fd5-bc1c-4da4-8b58-0fa8607015cb").

The ids of the items in the hotbar can be saved to local storage in the same order, and then used to identify the items in the inventory to add to the hotbar on game load.

Current hotbar population logic: https://github.com/Arcanorum/dungeonz/blob/master/client/src/shared/state/Inventory.js#L50

Acceptance criteria

  • When the state of the hotbar changes, the new state should be saved to local storage with each item being saved in the same order as they appear in the hotbar.
  • Should only store the id property of each itemConfig object in the hotbar.
  • When the inventory state is loaded when the game client loads, the hotbar should be populated by finding the corresponding items by the stored hotbar item ids.

Hi! I'm new to open-source and am interested in game development and I'd like to work on this issue!

Hi. Sure. If you have the development setup working this one should be straightforward enough. Any questions ask them here (there are also development chat sections in the Discord server).

Hi @Arcanorum, we had a bit of a switcharoo: @rushab101 will be submitting a PR for this guy and I'll be submitting one for #161 instead. We should have both PRs ready to take a look at sometime between today and next week.

Ok.
To change the assignee on GH they need to have left a comment on the issue, so it won't let me swap them atm, so I'll leave them as they are for now.

Hey, we are sorry about that, I will submit the PR for this feature. Thanks.