Recently I started developing my tiny html5 multiplayer game made in Node.js, Express.js, MongoDB(Mongoose), Socket.io and using Phaser.js.
I am quite new to these frameworks and especially new to database structuring/management.
My struggle comes when I think about how can I structure the database to store things as player username, password and general preferences (basic user info); and then things as player equipment such as items and currency.
I can figure out how to do the code part but what I do not know how to handle is the process I should follow.
I thought of the structure like so:
//Users Document
{
"_id": "randId",
"username": "ArthurConan",
"password": "aquamarine12345",
"credits": 20,
"equipment": [
{
"name": "Sword of the Forsaken",
"equiped": true,
"slot": "weapon",
"id": "itemId",
},
{
"name": "Meteor Katana",
"equiped": false,
"id": "itemId"
}
]
}
//Items Document
{
"_id": "itemId",
"name": "Sword of the Forsaken",
"atk": 1400,
"value": 500
},
{
"_id": "itemId",
"name": "Meteor Katana",
"atk": 200,
"value": 50
}
As I am using MongoDB the structure would be more or less similar to that.
With the code above then I would do the following: - Player Registers and his basic info(username, password, ...) is added to the database and he will also get one weapon to start with. - Player adventures into my world and gathers credits and equipment. Those items are stored in his inventory. - Player can equip/use/sell/destroy/upgrade some of those items. Upgraded items will have its stats upgraded based on preset stats.
As a side-note I would like you to know I am not the best at explaining myself, I hope you understand what I am trying to achieve. Also any suggestions are appreciated, have a good day :)