C
C#3mo 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?)
4 Replies
oke
oke3mo ago
its a solid solution, as long as exploiting isnt a concern. "generating" game data on client side seems like a security risk. best to play it like a roblox game where data is shared with clients, but created and stored via the server otherwise, this seems like a good solution although, id recommend not using json and using something like bson or something else that doesnt waste disk space
Metalkon
Metalkon3mo ago
client side would only display the info in the bottom part of my post where important stuff is server side and db only
oke
oke3mo ago
then i think youre good to go $close
MODiX
MODiX3mo ago
Use the /close command to mark a forum thread as answered