Browse Source

fixed: 排行榜反馈,修改战力榜统计时机.

gwang 5 years ago
parent
commit
f169b80dcb

+ 3 - 10
Gameserver/Amfphp/process/FightProc/PVPProc.php

@@ -16,16 +16,13 @@ class PVPProc {
      * @param req $req
      */
     public static function GetChallengeAdversaryInfo($req) {
-        // 参数: 无
-        $targetUID = $req->paras[0];                                            # 对手的UID
-//        var_dump($targetUID);
-        $uinfo = UserProc::getUserInfo($req->mem, $req->zoneid, $targetUID);    # 读取玩家信息
-//        var_dump($uinfo);
+        $targetUID = $req->paras[0];                                            # 参数: 对手的UID
+        $uinfo = UserProc::getUserInfo($req->mem, $req->zoneid, $targetUID);    # 读取玩家信息 
         if (null == $uinfo) {
             Err(ErrCode::user_no_err);
         }
         $team = JsonUtil::decode($uinfo->game->heroTeamConfig);
-        var_dump($team);
+
         $heros = new \stdClass();
         $curTeamId = $team->curUseTeamID;
         foreach ($team->teamDic->$curTeamId->heros as $hid) {
@@ -34,10 +31,6 @@ class PVPProc {
                 $heros->$n_hid = $uinfo->game->heros->collectHeros->$hid;
             }
         }
-//        $eqps = array();
-//        $yanls = array()
-//        foreach ($uinfo->game->store->equipment->)
-
 
         $adversary = array(#                                                    # 拼装玩家信息
             'uid' => $targetUID,

+ 33 - 7
Gameserver/Amfphp/process/HeroProc.php

@@ -188,6 +188,7 @@ class HeroProc {
         $resp = Resp::ok($upHero);
         SystemProc::insertHero_StageUp($req->zoneid, $req->uid, $user->name, #  # 插入系统广播
                 GameConfig::hero_getItem($upHero->typeId)->name, $upHero->grade);
+        self::CalcUserFightPower($req->zoneid, $req->uid, $req->userInfo->game); # 跟新战力统计
         return $resp;
     }
 
@@ -225,7 +226,7 @@ class HeroProc {
         }
         $req->userInfo->game->store->items = $myPacketItems;                    # 更新背包数据
         UserProc::updateUserInfo();                                             # 回写玩家数据
-        self::CalcTeamFightPower($req->zoneid, $req->uid, $req->userInfo->game); # 跟新战力统计
+        self::CalcUserFightPower($req->zoneid, $req->uid, $req->userInfo->game); # 跟新战力统计
         return Resp::ok($targetHero);
     }
 
@@ -1163,12 +1164,37 @@ class HeroProc {
                     }
                 }
             }
-            gMem()->zadd(MemKey_GameRun::Game_FightPowerRank_zset($zoneid), array($uid => $fp));
-            $key_log = MemKey_GameRun::Game_Rank_FPowerBreakLog_hash($zoneid);  # 突破记录
-            foreach (GameConfig::rankreward_fpower() as $condition => $reward) {
-                if ($fp >= $condition && !gMem()->hexists($key_log, $condition)) {# 达成突破奖励标准
-                    gMem()->hset($key_log, $condition, $uid);                   # 添加突破记录
-                }
+            //todo: 这里的战斗力榜被总战力榜征用了key, 重启PVP机制时再
+//            gMem()->zadd(MemKey_GameRun::Game_FightPowerRank_zset($zoneid), array($uid => $fp));
+//            $key_log = MemKey_GameRun::Game_Rank_FPowerBreakLog_hash($zoneid);  # 突破记录
+//            foreach (GameConfig::rankreward_fpower() as $condition => $reward) {
+//                if ($fp >= $condition && !gMem()->hexists($key_log, $condition)) {# 达成突破奖励标准
+//                    gMem()->hset($key_log, $condition, $uid);                   # 添加突破记录
+//                }
+//            }
+        }
+        return $fp;
+    }
+
+    /**
+     * 计算玩家总战斗力, 添加到战斗力榜单中
+     * @version 1.0.0 改造自原来的队伍战斗力统计方法 --gwang 2020.4.23
+     * @param type $zoneid
+     * @param type $uid
+     * @param UserGameModel $user
+     * @return type
+     */
+    static function CalcUserFightPower($zoneid, $uid, $user) {
+        $fp = 0;                                                                # 总战力:返回值
+        foreach ($user->heros->collectHeros as $hid => $hero) {
+            $fp += self::calcHeroFightPower($hero);
+        }
+        $key_fp = MemKey_GameRun::Game_FightPowerRank_zset($zoneid);            # 战力榜
+        $key_log = MemKey_GameRun::Game_Rank_FPowerBreakLog_hash($zoneid);      # 突破记录
+        gMem()->zadd($key_fp, array($uid => $fp));                              # 更新战力记录
+        foreach (GameConfig::rankreward_fpower() as $condition => $reward) {    # 遍历突破奖励数据
+            if ($fp >= $condition && !gMem()->hexists($key_log, $condition)) {  # 判断是否达成突破奖励标准
+                gMem()->hset($key_log, $condition, $uid);                       # 添加突破记录
             }
         }
         return $fp;

+ 5 - 2
Gameserver/Amfphp/process/StoreProc.php

@@ -651,10 +651,10 @@ class StoreProc {
         }
         $collectHeros->$herouid->yanling->$itemtype->itemuid = $yanling_uid;    # 英雄身上添加言灵记录
 
-        UserProc::updateUserInfo();                                         # 5.回写数据
+        UserProc::updateUserInfo();                                             # 5.回写数据
         $ret = array('resp' => "succeed!");
         $resp = Resp::ok($ret);                                                 // 返回 
-//        StoreProc::CheckItemNum($req);
+        HeroProc::CalcUserFightPower($req->zoneid, $req->uid, $user);           # 更新总战力榜
         return $resp;
     }
 
@@ -662,6 +662,7 @@ class StoreProc {
      * [6416] 给英雄卸下言灵
      * @param req $req
      * @return type
+     * @deprecated since version 无法卸下,只能更换
      */
     static function UnWieldYanling($req) {
         $user = $req->userInfo->game;                                           # user引用
@@ -732,11 +733,13 @@ class StoreProc {
         }
         UserProc::updateUserInfo();                                             // 5.回写数据
 //        StoreProc::CheckItemNum($req);
+        HeroProc::CalcUserFightPower($req->zoneid, $req->uid, $user);           # 更新总战力榜
         return Resp::ok(array('resp' => "succeed!"));                           // 返回 
     }
 
     /**
      * [6411] 给英雄脱装备
+     * @deprecated since version 不能卸下装备, 只能更换.
      * @param req $req
      * @return type
      */