I'm building a game similar to Mafia Wars where a player can do tasks for his gang and gain experience and thus advancing his level.

The game is built using PHP and a Mysql database.

In the game I want to limit the resources allowed to player based on his level.

For example:

________| (Max gold) | (Max army size) | (Max moves)  | ...      
Level 1 |    1000    |       100       |      10      | ...  
Level 2 |    1500    |       200       |      20      | ...  
Level 3 |    3000    |       300       |      25      | ...

In addition certain features of the game won't be allowed until a certain level is reached such as players under Level 10 can't trade in the game market, players under Level 20 can't create alliances,...etc.

The way I have modeled it is by implementing a very loooong ACL (Access Control List) with about 100 entries (an entry for each level).

However, I think there may be a simpler approach to this seeing that this feature have been implemented in many games before.


I would recommend using some type of algorithm rather than an ACL:

Algorithm for dynamically calculating a level based on experience points?


These aren't specific to your question, but the general principle is that there are formulas you can use to determine the requirements rather than hardcoding every possible outcome

| improve this answer | |
  • \$\begingroup\$ well my problem starts after calculating the Level itself from the experience points. Think about it this way, if I know that a player is Level 4 how should I handle the privileges for that level? \$\endgroup\$ – Songo Apr 30 '13 at 12:09
  • 1
    \$\begingroup\$ I updated the answer to give another example. the main point is that you can use an algorithm to determine the access levels rather than hardcoding everything based on user levels \$\endgroup\$ – wes Apr 30 '13 at 12:38

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.