dongzi1209 2016-06-03 14:02
浏览 25

Php级别和exp系统

How can i make a level system where i have 2 table, one for the level and another for amount of exp earned?

I want to be able to manage the different exp requierments myself, like level 2 will need 340exp and level 3 need 450exp. I dont want to set one exp amount and then multiply it. I want to manage the whole system.

I also want to set default level and max level, and give exp directly to the database column without too much problem (for forum posts etc).

I have seen a few questions here but i find them outdated or just not what im looking for.

PS: sorry for bad english and bad explenation.

  • 写回答

1条回答 默认 最新

  • dousi2553 2016-06-03 21:20
    关注

    I found a realy good solution and was able to rewrite it to work with my setup. if anyone is interested i will leave the original link and my edit of it bellow.

    my edit:

    <?php
    // Connect to your database like you normally do, then get any value into the $count variable
    
    $count = $exp;
    
    if($level == 0){
      $lvl = 1;
    }else{
      $lvl = $level;
    }
    
    if ($count >= 12800) { $lvl = 10; }
    else if ($count >= 6400) { $lvl = 9; }
    else if ($count >= 3200) { $lvl = 8; }
    else if ($count >= 1600) { $lvl = 7; }
    else if ($count >= 800) { $lvl = 6; }
    else if ($count >= 400) { $lvl = 5; }
    else if ($count >= 200) { $lvl = 4; }
    else if ($count >= 100) { $lvl = 3; }
    else if ($count >= 50) { $lvl = 2; }
    
    // Render stars or any graphics/images according to dynamic $lvl number
    $stars = "";
    $i = 1;
    while ($i <= $lvl) {
         $stars .= "&#9733;";
         $i++;
    }
    echo "level $lvl";
    ?> 
    

    Original link: https://www.developphp.com/video/PHP/Experience-Level-Evaluation-Programming-Tutorial

    评论

报告相同问题?

悬赏问题

  • ¥15 在获取boss直聘的聊天的时候只能获取到前40条聊天数据
  • ¥20 关于URL获取的参数,无法执行二选一查询
  • ¥15 液位控制,当液位超过高限时常开触点59闭合,直到液位低于低限时,断开
  • ¥15 marlin编译错误,如何解决?
  • ¥15 有偿四位数,节约算法和扫描算法
  • ¥15 VUE项目怎么运行,系统打不开
  • ¥50 pointpillars等目标检测算法怎么融合注意力机制
  • ¥20 Vs code Mac系统 PHP Debug调试环境配置
  • ¥60 大一项目课,微信小程序
  • ¥15 求视频摘要youtube和ovp数据集