C#C
C#2y ago
Metalkon

Storing Item Information?

Question:

I'm making a crafting game with blazor and asp.net as a portfolio project and i'm struggling with deciding how to do something.

If I want to save item quantities and such in the users inventory on the database, but general item information (name/description/price/etc) elsewhere for easy changes down the road, what would be the best way to go about this?

The saved item information elsewhere would mostly be for display purposes when inspecting an item but also used for a shop for them to buy new materials (price and such). I assume saving to a json/xml may be the way to go, but how to effectively access that information both client and server side is making me wonder without being super inefficient.

---

Would this be the way to go here?

In a shop controller where a user wishes to buy an iron ingot for 6 gold or something... Create a user object (with the gamedata object which holds inventory/gold/lv/exp/etc), create a iteminfo object from a json, check if user has enough gold for the item id given to the controller, make changes for purchase, save info, update things on client side.

On client generate the iteminfo object (json also saved on client) on a page along with an inventory object from the server, page lists the quantities that the user has, and attaches iteminfo information on the items.

(And what about dependency injection for iteminfo?)
Was this page helpful?