Browse Source

fix: 挑战结算报错.

王刚 1 year ago
parent
commit
3d0a188ea4
1 changed files with 48 additions and 42 deletions
  1. 48 42
      Gameserver/App/process/FightProc.php

+ 48 - 42
Gameserver/App/process/FightProc.php

@@ -441,6 +441,14 @@ class FightProc {
                 'task' => ctx()->task,
             );
             return Resp::ok($ret);
+        } else if ($finalLayer == $lastLayer) {
+            $ret = array(
+                'store' => ctx()->store,
+                'gold' => ctx()->base()->gold,
+                'cash' => ctx()->base()->cash,
+                'task' => ctx()->task,
+            );
+            return Resp::ok($ret);
         }
         return Resp::err(ErrCode::tower_rewardNo);                              # 没有奖励
     }
@@ -705,22 +713,22 @@ class FightProc {
     public static function Ranking_MainGateIndex($maxGateIndex) {
         $memKey = MemKey_GameRun::Rank_MainGateIndex_Zone_zset(req()->zoneid);
         $mem = gMem();
-        
-        $index = 9999999999- now();        
-        $uid = $index."-".req()->uid;
+
+        $index = 9999999999 - now();
+        $uid = $index . "-" . req()->uid;
         $arr = self::GetRankUid(req()->uid, 1);
         $gateId = 0;
-        if(count($arr) > 0){
+        if (count($arr) > 0) {
             $uid = $arr[0];
             $gateId = $arr[1];
-        }     
-        
-        if($maxGateIndex > $gateId){
+        }
+
+        if ($maxGateIndex > $gateId) {
             $arr2 = array();
             $arr2["$uid"] = $maxGateIndex;
             $mem->zadd($memKey, $arr2);
         }
-             
+
         $length = $mem->zlen($memKey);
         if ($length > glc()->Rank_MainGateIndex_OnListRank) {
             $num = $length - glc()->Rank_MainGateIndex_OnListRank;
@@ -735,17 +743,17 @@ class FightProc {
     public static function Ranking_FightPower() {
         $memKey = MemKey_GameRun::Rank_FightPower_Zone_zset(req()->zoneid);
         $mem = gMem();
-        
-        $index = 9999999999- now();
-        $uid = $index."-".req()->uid;       
+
+        $index = 9999999999 - now();
+        $uid = $index . "-" . req()->uid;
         $lastPower = 0;
-        $arr = self::GetRankUid(req()->uid,2);
-        if(count($arr) > 0){
+        $arr = self::GetRankUid(req()->uid, 2);
+        if (count($arr) > 0) {
             $uid = $arr[0];
             $lastPower = $arr[1];
-        } 
-        
-        $power = self::countUserFightPower();        
+        }
+
+        $power = self::countUserFightPower();
         if ($power > $lastPower) {
             $arr2["$uid"] = $power;
             $mem->zadd($memKey, $arr2);
@@ -758,25 +766,24 @@ class FightProc {
             $mem->zremrangebyrank($memKey, 0, $num - 1);
         }
     }
-    
-    public static function GetRankUid($uid_rank,$type) {
-        if($type == 1){
-            $dic = gMem()->zrevrangebyscore(MemKey_GameRun::Rank_MainGateIndex_Zone_zset(req()->zoneid), 0, glc()->Rank_MainGateIndex_OnListRank,true);
+
+    public static function GetRankUid($uid_rank, $type) {
+        if ($type == 1) {
+            $dic = gMem()->zrevrangebyscore(MemKey_GameRun::Rank_MainGateIndex_Zone_zset(req()->zoneid), 0, glc()->Rank_MainGateIndex_OnListRank, true);
         } else {
-            $dic = gMem()->zrevrangebyscore(MemKey_GameRun::Rank_FightPower_Zone_zset(req()->zoneid), 0, glc()->Rank_FightPower_OnListRank,true);
+            $dic = gMem()->zrevrangebyscore(MemKey_GameRun::Rank_FightPower_Zone_zset(req()->zoneid), 0, glc()->Rank_FightPower_OnListRank, true);
         }
-        
+
         $arr = array();
         foreach ($dic as $uid => $score) {
             $strUid = explode('-', $uid);
-            if($strUid[1] == $uid_rank){
+            if ($strUid[1] == $uid_rank) {
                 $arr[] = $uid;
                 $arr[] = $score;
                 break;
             }
         }
         return $arr;
-        
     }
 
     /**
@@ -814,11 +821,11 @@ class FightProc {
                 }
             }
         }
-        
+
         $selfRank = null;
         $retArr = array();
         if (count($list) > 0) {
-            foreach ($list as $uid => $score) {          
+            foreach ($list as $uid => $score) {
                 $rankInfo = self::initOtherUidRankInfo($uid, $score, $type);
                 if ($rankInfo->uid == req()->uid) {
                     $selfIsHasRank = 1;
@@ -828,10 +835,10 @@ class FightProc {
                 $retArr[] = $rankInfo;
             }
         }
-        
-        if($selfRank == null){
-            $index = 9999999999- now();
-            $uid = $index."-".req()->uid;
+
+        if ($selfRank == null) {
+            $index = 9999999999 - now();
+            $uid = $index . "-" . req()->uid;
             $selfRank = self::initOtherUidRankInfo($uid, $selfExtraInfo, $type);
         }
 
@@ -857,13 +864,13 @@ class FightProc {
         if ($type == 1) {
             $lv = gMem()->zrevrank(MemKey_GameRun::Rank_MainGateIndex_Zone_zset(req()->zoneid), $uid);
         } else {
-            $lv = gMem()->zrevrank(MemKey_GameRun::Rank_FightPower_Zone_zset(req()->zoneid),$uid);
+            $lv = gMem()->zrevrank(MemKey_GameRun::Rank_FightPower_Zone_zset(req()->zoneid), $uid);
         }
 
         if ($lv == null) {
             $lv = 0;
         }
-        
+
         $strUid = explode('-', $uid);
         $ins_rank->rank = $lv + 1;
         $ins_rank->uid = $strUid[1];
@@ -1019,33 +1026,32 @@ class FightProc {
      * 删除排行榜内注销账号的玩家
      */
 
-    public static function DeleteRankInvalidUser($uid2) {     
-        $dic1 = gMem()->zrevrangebyscore(MemKey_GameRun::Rank_MainGateIndex_Zone_zset(req()->zoneid), 0, glc()->Rank_MainGateIndex_OnListRank,true);
+    public static function DeleteRankInvalidUser($uid2) {
+        $dic1 = gMem()->zrevrangebyscore(MemKey_GameRun::Rank_MainGateIndex_Zone_zset(req()->zoneid), 0, glc()->Rank_MainGateIndex_OnListRank, true);
         $key1 = "";
         foreach ($dic1 as $uid => $score) {
             $strUid = explode('-', $uid);
-            if($strUid[1] == $uid2){
+            if ($strUid[1] == $uid2) {
                 $key1 = $uid;
                 break;
             }
         }
-    
-        $dic2 = gMem()->zrevrangebyscore(MemKey_GameRun::Rank_FightPower_Zone_zset(req()->zoneid), 0, glc()->Rank_FightPower_OnListRank,true);
+
+        $dic2 = gMem()->zrevrangebyscore(MemKey_GameRun::Rank_FightPower_Zone_zset(req()->zoneid), 0, glc()->Rank_FightPower_OnListRank, true);
         $key2 = "";
         foreach ($dic2 as $uid => $score) {
             $strUid = explode('-', $uid);
-            if($strUid[1] == $uid2){
+            if ($strUid[1] == $uid2) {
                 $key2 = $uid;
                 break;
             }
         }
-        if($key1 != ""){
-            gMem()->zrem(MemKey_GameRun::Rank_MainGateIndex_Zone_zset(req()->zoneid),$key1);
+        if ($key1 != "") {
+            gMem()->zrem(MemKey_GameRun::Rank_MainGateIndex_Zone_zset(req()->zoneid), $key1);
         }
-        if($key1 != ""){
+        if ($key1 != "") {
             gMem()->zrem(MemKey_GameRun::Rank_FightPower_Zone_zset(req()->zoneid), $key2);
         }
-              
     }
 
     /*