cyzhao 1 жил өмнө
parent
commit
9b23a93d91

+ 14 - 0
Gameserver/App/base/CmdCode.php

@@ -324,6 +324,20 @@ class CmdCode {
      */
     const fight_tower_updatelocklist = 6810;
 
+    /**
+     * 获取主线关卡排行榜
+     */
+    const fight_rank_mainGateIndex = 6811;
+    
+    /*
+     * 获取榜单内玩家的装备信息
+     */
+    const fight_rankInfo = 6812;
+    
+    /**
+     * 获取玩家的装备信息
+     */
+    const fight_rank_uidEquipInfo = 6813;
     // </editor-fold>
     // <editor-fold defaultstate="collapsed" desc="    反射方法    ">
 

+ 19 - 0
Gameserver/App/base/MemKey_GameRun.php

@@ -10,6 +10,25 @@ namespace loyalsoft;
  * @copyright ? 2017-4-6, SJZ LoyalSoft Corporation & gwang. All rights reserved.
  */
 class MemKey_GameRun {
+    
+    /**
+     * 主线关卡榜
+     * @param int $zoneid
+     * @return string
+     */
+    public static function Rank_MainGateIndex_Zone_zset($zoneid) {
+        return "Rank_MainGateIndex_Zone$zoneid";
+    }
+    
+    /**
+     * 关卡战力榜
+     * @param int $zoneid
+     * @return string
+     */
+    public static function Rank_FightPower_Zone_zset($zoneid) {
+        return "Rank_FightPower_Zone$zoneid";
+    }
+    
     //
 // <editor-fold defaultstate="collapsed" desc="英雄">
 

+ 1 - 1
Gameserver/App/model/Const/GameConfig.php

@@ -3,7 +3,7 @@
  // 由CodeGenerator创建。
  // Copyright (C) gwang (wanggangzero@qq.com), Loyalsoft@sjz Inc
  // author: gwang 
- // 日期: 2024-05-28 10:40:54
+ // 日期: 2024-05-28 14:39:48
 ////////////////////
 
 /**

+ 21 - 1
Gameserver/App/model/Const/sm_globalsettings.php

@@ -3,7 +3,7 @@
  // 由CodeGenerator创建。
  // Copyright (C) gwang (wanggangzero@qq.com), Loyalsoft@sjz Inc
  // author: gwang 
- // 日期: 2024-05-27 09:13:37
+ // 日期: 2024-05-28 14:38:55
 ////////////////////
 
 
@@ -183,5 +183,25 @@ class sm_globalsettings
     */
     public $FirstGateId;
 
+    /**
+    * @var int 主线排行榜前端展示的前X名排名  
+    */
+    public $Rank_MainGateIndex_ShowRank;
+
+    /**
+    * @var int 主线排行榜上榜排名数,之外的不在统计  
+    */
+    public $Rank_MainGateIndex_OnListRank;
+
+    /**
+    * @var int 战力排行榜前端展示的前X名排名  
+    */
+    public $Rank_FightPower_ShowRank;
+
+    /**
+    * @var int 战力排行榜上榜排名,之外不在统计  
+    */
+    public $Rank_FightPower_OnListRank;
+
 }
 

+ 1 - 1
Gameserver/App/model/Const/sm_waves.php

@@ -3,7 +3,7 @@
  // 由CodeGenerator创建。
  // Copyright (C) gwang (wanggangzero@qq.com), Loyalsoft@sjz Inc
  // author: gwang 
- // 日期: 2024-05-27 14:43:17
+ // 日期: 2024-05-28 14:37:43
 ////////////////////
 
 

+ 1 - 1
Gameserver/App/model/User/Info_UserBase.php

@@ -113,7 +113,7 @@ class Info_UserBase extends Object_ext {
      * @var type
      */
     public $xilianStone = 0;
-
+    
     public function initialize() {
 //        my_Assert(GameConfig::primordial_data(), "找不到账号初始化数据");         # 防御
         $this->gold = 1000000;

+ 46 - 0
Gameserver/App/model/User/Ins_rank.php

@@ -0,0 +1,46 @@
+<?php
+
+/*
+ * To change this license header, choose License Headers in Project Properties.
+ * To change this template file, choose Tools | Templates
+ * and open the template in the editor.
+ */
+
+namespace loyalsoft;
+
+/**
+ * Description of Ins_rank
+ *
+ * @author c'y'zhao
+ */
+class Ins_rank extends Object_ext{
+    /*
+     * 排名
+     */
+    public $rank = 0;
+
+    /*
+     * 玩家uid
+     */
+    public $uid = "";
+    
+    /*
+     * 玩家名称
+     */
+    public $name = "";
+
+    /*
+     * 通关进度
+     */
+    public $score = 0;
+    
+    /**
+     * 构造函数
+     * @param type $args
+     */
+    public function __construct($args) {
+        if ($args != null) {
+            parent::__construct($args);      
+        }
+    }
+}

+ 104 - 0
Gameserver/App/process/FightProc.php

@@ -37,6 +37,10 @@ class FightProc {
                 return self::TowerRefreshSkills();
             case CmdCode::fight_tower_updatelocklist:                           # 6810 挑战关卡: 更新技能锁定列表
                 return self::TowerUpdateLockskillList();
+            case CmdCode::fight_rankInfo:                                       # 6811 获取主线关卡排行榜信息    
+                return self::GetRankInfo();
+            case CmdCode::fight_rank_uidEquipInfo:                              # 6812 获取主线关卡榜内玩家的装备信息    
+                return self::GetUidEquipInfo_Rank();
             default:
                 Err(ErrCode::cmd_err);
         }
@@ -575,4 +579,104 @@ class FightProc {
         );
         return Resp::ok($ret);
     }
+         
+    /**
+     * 参与主线关卡排行榜
+     * @param type $uid
+     * @param type $gateIndex
+     */
+    public static function Ranking_MainGateIndex($uid,$maxGateIndex) {
+        $memKey = MemKey_GameRun::Rank_MainGateIndex_Zone_zset(req()->zoneid);
+        $mem = gMem();
+        $arr = array();
+        $arr["$uid"] = $maxGateIndex;    
+        $mem->zadd($memKey,$arr);
+        
+        $length = $mem->zlen($memKey);
+        if($length > glc()->Rank_MainGateIndex_OnListRank){
+            $num = $length - glc()->Rank_MainGateIndex_ShowRank;
+            $mem->zremrangebyrank($memKey,0, $num-1);
+        }      
+    }
+    
+    /**
+     * 6811 获取主线关卡排行榜信息    
+     * @return type
+     */
+    public static function GetRankInfo() {
+        list($type) = req()->paras;
+        $selfRank = 0;
+        $selfIsHasRank = 0; //本人是否上榜 0未上榜没有排名 1上榜则selfRank就是排名
+        $selfExtraInfo = 0;
+                      
+        if($type == 1){
+            $list = gMem()->zrevrange(MemKey_GameRun::Rank_MainGateIndex_Zone_zset(req()->zoneid),0, glc()->Rank_MainGateIndex_OnListRank, true);
+            $selfExtraInfo = ctx()->gates->UnlockedGatesMaxId;
+        } else {
+            $list = gMem()->zrevrange(MemKey_GameRun::Rank_FightPower_Zone_zset(req()->zoneid),0, glc()->Rank_FightPower_OnListRank, true);
+            $selfExtraInfo = 0;//战力还没有
+        }
+        
+        $retArr = array();
+        if(count($list)>0){
+            foreach ($list as $uid => $score) {
+                $rankInfo = self::initOtherUidRankInfo($uid, $score);
+                if($rankInfo->uid == req()->uid){
+                    $selfIsHasRank = 1;
+                    $selfRank = $rankInfo->rank;
+                }
+                
+                $retArr[] = $rankInfo;
+            }                     
+        }
+        
+        UserProc::updateUserInfo();
+        $ret = array(
+            'rankInfo' => $retArr,
+            'selfRank' =>$selfRank,
+            'selfIsHasRank' => $selfIsHasRank,
+            'selfExtraInfo'=> $selfExtraInfo,
+        );
+        return Resp::ok($ret);
+    }
+    
+    /**
+     * 初始化玩家rank
+     * @param type $uid
+     * @param type $score
+     * @return \loyalsoft\Ins_rank
+     */
+    static function initOtherUidRankInfo($uid,$score) {       
+        $ins_rank = new Ins_rank();
+        $ins_rank->rank = gMem()->zrank(MemKey_GameRun::Rank_MainGateIndex_Zone_zset(req()->zoneid), $uid)+1;
+        $ins_rank->uid = $uid;
+        $ins_rank->name = UserProc::getUserGame(req()->zoneid, $uid)->baseInfo->name;
+        $ins_rank->score = $score;
+        return $ins_rank;
+    }
+    
+    /**
+     * 6812 获取排行榜内玩家的装备信息   
+     * @return type
+     */
+    public static function GetUidEquipInfo_Rank() {
+        list($uid) = req()->paras;
+        $userInfo = UserProc::getUserGame(req()->zoneid, $uid);    
+        $attackNum = 0;
+        $hp = 0;
+        $equip = $userInfo->store->equip;
+        $gem = $userInfo->store->gemEquip;
+        $equipPag = $userInfo->store->equipPag;
+        
+        UserProc::updateUserInfo();
+        $ret = array(
+            'attackNum' => $attackNum,
+            'hp' =>$hp,
+            'equip' => $equip,
+            'gem'=>$gem,
+            'equipPag'=>$equipPag,
+        );
+        return Resp::ok($ret);
+    }    
+     
 }

+ 2 - 3
Gameserver/App/process/StoreProc.php

@@ -178,7 +178,7 @@ class StoreProc {
                 }
             }
         }
-
+        $upLevelArr = array();
         if (count($arr) > 0) {
             //进行排序
             $len = count($arr);
@@ -199,8 +199,7 @@ class StoreProc {
                     }
                 }
             }
-
-            $upLevelArr = array();
+            
             //升级,扣除金币和图纸      
             while (true) {
                 $tag = 9999;