I'm developing a game where I will be storing all actions the user makes with their character as a statistic. If the player chooses to have his character attack with with a melee weapon. We increment a counter th开发者_StackOverflowat counts the number of times that character has performed a melee attack. We also increment a counter that counts the number of times they have attacked with that particular weapon. Further, the character is capable of increasing in level and these statistics should all be recorded per level for the character. The character will also have attributes. Such as speed, fortitude, etc. Whenever one of these attribute's values is accessed I will increment a counter for that per level as well.
I am on a low budget so I am using SQL Server Express for this project. I know how I can accomplish this task with just my experience in databases but, admittedly, I have never recorded this type of data and to this degree. Can anyone offer any tips or advice that might seem out of the ordinary for someone with business application database experience?
When done, the data should be easily aggregated and selectable to use in various necessary calculations both in-game and as part of a statistics dashboard that will be part of the game.
If anyone has any specific schema suggestions as well that would be helful.
Thanks
It is really as easy as tying some code down to the action to update the stats.
The absolute fastest way is with a trigger, because it cuts down on round trips to the server, and is actually darn nice "encapsulation" of code and data. But SQL Server's triggers are a little funky, being only statement-level, so you can also do it in code.
In code you have the same idea, presumably some class code is responsible for the action with the item. When any action is taken that must be recorded, call a stat updater routine that names player, item, and other parameters, enough so the stat updater can figure out which table/column/row to go to and which stat to update.
Hope this helps.
精彩评论