Reputation: 415
I am in the process of building a user experience/level system on my site. The effect I am trying to achieve is similar to that of the popular game site, Kongregate, whereby when a user completes particular actions on the site they are awarded points. Once the points reach a certain amount the user will level up. This has the effect of giving the site a game like feel, while also grabbing the user's attention.
The problem I'm having is figuring out if it's best to... 1. Store each level in a database table and then match the user up to that level via an ID? 2. OR store the user's experience for the actions completed and then summing that number up everytime I need to call on the level?
It should also be noted that the level will be used to figure out other aspects of this system. i.e. A user at level 10 will gain additional schwag for their profile, added functionality on the site, etc... A LA Stack O.
Any pointers on the proper direction to take?
Upvotes: 0
Views: 249
Reputation: 5974
I think it's best to determine the "level" everytime the user gets more points. So when he / she does something to get more points, do the calculation then and there. If the point warrants a level increase, then change the level_id within the user's profile. That way you minimize calculations on the server side.
Upvotes: 0
Reputation: 10508
When they add points from your site (by commenting, or playing a game or whatever), calculate it on the fly, but once it's definitely done adding up, store it in the database (in the actions table) and update their total points (in the user table or whatever) so it's available to other parts of the site.
This makes everything easier:
Upvotes: 3