Hello,
I am creating very simple hobby project - browser based multiplayer game. I am stuck at designing tables for storing information abou
Regarding your basic structure, you may (depending on the nature of your game) want to consider driving toward convergence of representation between player character and non-player characters, so that code that would naturally operate the same on either doesn't have to worry about the distinction. This would suggest, instead of having user
and monster
tables, having a character
table that represents everything PCs and NPCs have in common, and then a user
table for information unique to PCs and/or user accounts. The user
table would have a character_id
foreign key, and you could tell a player character row by the fact that a user
row exists corresponding to it.
For representing quests in a model like yours, the way I would do it would look like:
quest_model
===============
id
name ['Quest for the Holy Grail', 'You Killed My Father', etc.]
etc.
quest_model_req_type
===============
id
name ['Minimum Level', 'Skill', 'Equipment', etc.]
etc.
quest_model_req
===============
id
quest_id
quest_model_req_type_id
value [10 (for Minimum Level), 'Horseback Riding' (for Skill), etc.]
quest
===============
id
quest_model_id
user_id
status
etc.
So a quest_model
is the core definition of the quest structure; each quest_model
can have 0..n associated quest_model_req
rows, which are requirements specific to that quest model. Every quest_model_req
is associated with a quest_model_req_type
, which defines the general type of requirement: achieving a Minimum Level, having a Skill, possessing a piece of Equipment, and so on. The quest_model_req
also has a value
, which configures the requirement for this specific quest; for example, a Minimum Level type requirement might have a value
of 20, meaning you must be at least level 20.
The quest
table, then, is individual instances of quests that players are undertaking or have undertaken. The quest
is associated with a quest_model
and a user
(or perhaps character
, if you ever want NPCs to be able to do quests!), and has a status
indicating where the progress of the quest stands, and whatever other tracking turns out useful.
This is a bare-bones structure that would, of course, have to be built out to accomodate the needs of particular games, but it should illustrate the direction I'd recommend.
Oh, and since someone else threw around their credentials, mine are that I've been a hobbyist game developer on live, public-facing projects for 16 years now.