I am planning an achievement system for an ASP.NET mvc site. I want the achievement "rules" to be stored in a database - it is easy to add new achievements and a central place to manage existing achievements. Users will have no access to change the rules.
When a user performs an action which can potentially earn an achievement, then the rules of the DB will be checked and if they are in matches, then they will be awarded achievements (a lookup table, , Achievement ID, DateAwards).
At the moment, I am planning to "trigger" some functions in the controller, but the code that works will be in the model.
Standard DB Schema for Achievement System If it is not necessary then there is no need to change the wheel again. If not, what kinds of issues do you pop up, what should be seen
You may find helpful.
From the experience of speaking, to respond to user's actions For the creation of a database-based rules engine is a very time consuming, error-prone, painful exercise. Instead of being able, you can write individual classes in any number, each one responsible for knowing how to award a special achievement to a common contract to use them with a base class or interface:
Public Essentials Achievement Agreed {// Special Badge Logic Public Summary Override to award zero; } You can do foreach on each code, and achievement leading and reward () call on a recurring schedule can do. For example, you may have a "100 Visit" Achievements:
Public Class 100VisitsAwarder: AchievementAwarder {Public Override Zero Award () {// Number of visits from DB to all users Get // // Award Achievements}} This fixes two problems:
-
This magnitude order is easy, but database-based rules Compared to the engine is more flexible. As you can see, large units have a very small and easy change without affecting the large system.
-
It can run in asynchronous form, so for those achievements who need some heavy lifting to determine if they should be honored, then the user's normal Activities are not affected by the achievement engine.
Comments
Post a Comment