Browse Source

代码清理

gwang 4 years ago
parent
commit
1bd7d31d51

+ 22 - 28
Gameserver/Amfphp/Services/AppServer.php

@@ -12,32 +12,29 @@ class AppServer {
 
 
     /**
     /**
      * The Main Entrance of App
      * The Main Entrance of App
-     * @param Req $req
      * @return Resp
      * @return Resp
      */
      */
-    public function api($req) {
+    public function api() {
         $uniq = uniqid();                                                       # 自己生成一个唯一串,作为此次处理过程的标记。
         $uniq = uniqid();                                                       # 自己生成一个唯一串,作为此次处理过程的标记。
         $GLOBALS['deal-uid'] = $uniq;                                           # 写入日志的时候带上,方便辨认同一个处理过程.
         $GLOBALS['deal-uid'] = $uniq;                                           # 写入日志的时候带上,方便辨认同一个处理过程.
-        $GLOBALS['zoneid'] = $req->zoneid;                                      # 暂时未想到更好的方案
-//        $req->mem = gMem();                                                     # 初始化并挂载CRedisUtil
-        $err = self::BeforeProc($req);                                          # 预处理
+        $GLOBALS['zoneid'] = req()->zoneid;                                     # 暂时未想到更好的方案 
+        $err = self::BeforeProc();                                              # 预处理
         my_Assert(ErrCode::ok == $err, $err);                                   # 如果tk校验未通过
         my_Assert(ErrCode::ok == $err, $err);                                   # 如果tk校验未通过
-        $resp = self::Route($req);                                              # 分发逻辑
-        self::AfterProc($req, $resp);                                           # 执行后处理逻辑
-//        $req->mem->close();                                                     # 销毁已申请的资源
+        $resp = self::Route();                                                  # 分发逻辑
+        self::AfterProc($resp);                                                 # 执行后处理逻辑 
         return $resp;
         return $resp;
     }
     }
 
 
     /**
     /**
      * 预处理逻辑
      * 预处理逻辑
      */
      */
-    private static function BeforeProc($req) {
+    private static function BeforeProc() {
         if (!GAME_ONLINE) {
         if (!GAME_ONLINE) {
             return ErrCode::ok;                                                 # 直接返回 0:成功
             return ErrCode::ok;                                                 # 直接返回 0:成功
         }
         }
-        my_Assert(!config::Inst()->isBaned($req->uid), ErrCode::err_server_updating); # 检查封号 
+        my_Assert(!config::Inst()->isBaned(req()->uid), ErrCode::err_server_updating); # 检查封号 
         if (self::isUpdating()                                                  # 检查是否处于更新阶段,暂停对玩家请求的响应。
         if (self::isUpdating()                                                  # 检查是否处于更新阶段,暂停对玩家请求的响应。
-                && !config::Inst()->isTester($req->uid)) {                      # 排除测试号
+                && !config::Inst()->isTester(req()->uid)) {                     # 排除测试号
             return ErrCode::err_server_updating;
             return ErrCode::err_server_updating;
         }
         }
         $ssd = GameConfig::service_schedule_getItem(1);                         # 服务计划(固定只有1条)
         $ssd = GameConfig::service_schedule_getItem(1);                         # 服务计划(固定只有1条)
@@ -45,7 +42,7 @@ class AppServer {
             Err(ErrCode::err_server_maintaining, $ssd->reason);
             Err(ErrCode::err_server_maintaining, $ssd->reason);
         }
         }
         // todo: 检查clientVersion 判断是否应该强制升级  
         // todo: 检查clientVersion 判断是否应该强制升级  
-        if (!Index::$isDebugging && now() - $req->ts > OFFSET_MSGTIME) {        # 如果服务端客户端时间戳超过规定误差,则消息非法
+        if (!Index::$isDebugging && now() - req()->ts > OFFSET_MSGTIME) {       # 如果服务端客户端时间戳超过规定误差,则消息非法
             return ErrCode::err_outtime;
             return ErrCode::err_outtime;
         }
         }
         return ErrCode::ok;                                                     # 所有检查通过
         return ErrCode::ok;                                                     # 所有检查通过
@@ -53,47 +50,44 @@ class AppServer {
 
 
     /**
     /**
      * 后处理逻辑
      * 后处理逻辑
-     * @param Req $req
      * @param Resp $resp
      * @param Resp $resp
      */
      */
-    private static function AfterProc($req, &$resp) {
-        if ($req->userInfoChanged) {                                            # 回写玩家数据
-            if (!UserProc::setUserInfo($req->userInfo)) {                       # 失败, 改写返回值
+    private static function AfterProc(&$resp) {
+        if (req()->userInfoChanged) {                                           # 回写玩家数据
+            if (!UserProc::setUserInfo(req()->userInfo)) {                      # 失败, 改写返回值
                 Err(ErrCode::err_innerfault, "回写玩家数据");
                 Err(ErrCode::err_innerfault, "回写玩家数据");
             }
             }
         }
         }
         $resp->AfterProc();
         $resp->AfterProc();
-        GAME_ONLINE and self::LogCmd($req, $resp);                                              # 记录操作日志
+        GAME_ONLINE and self::LogCmd(req(), $resp);                             # 记录操作日志
         CLog::flush();                                                          # flush日志
         CLog::flush();                                                          # flush日志
     }
     }
 
 
     /**
     /**
-     * 新版: 使用pdo_mysql+dao版本
-     * @param type $req
+     * 新版: 使用pdo_mysql+dao版本 
      * @param type $resp
      * @param type $resp
      */
      */
-    private static function LogCmd($req, $resp) {
+    private static function LogCmd($resp) {
         $tablename = 'tab_op_log' . date('Ymd');                                # 今天的表名
         $tablename = 'tab_op_log' . date('Ymd');                                # 今天的表名
         $old_tablename = 'tab_op_log' . date('Ymd', now(-86400 * 21));          # 待删除的表名 日志保留21天 
         $old_tablename = 'tab_op_log' . date('Ymd', now(-86400 * 21));          # 待删除的表名 日志保留21天 
         $sql = sprintf('create table if not exists %s like `tpl_op_log_tab`;', $tablename); # 创建今天的表
         $sql = sprintf('create table if not exists %s like `tpl_op_log_tab`;', $tablename); # 创建今天的表
         $sql .= sprintf('drop table if exists %s;', $old_tablename);            # 循环删除以前的表
         $sql .= sprintf('drop table if exists %s;', $old_tablename);            # 循环删除以前的表
         $sql .= sprintf("insert into %s (`uid`,`zoneid`,`cmd`,`days`,`param`,`ret`) values ('%s', %d, %d, %d, '%s', '%s');", #
         $sql .= sprintf("insert into %s (`uid`,`zoneid`,`cmd`,`days`,`param`,`ret`) values ('%s', %d, %d, %d, '%s', '%s');", #
-                $tablename, $req->uid, $req->zoneid, $req->cmd, #               # Uid, zoneid, cmd
-                (isset($req->userInfo) ? (tsDay() - tsDay($req->userInfo->game->baseInfo->firstLogin)) : 0), #  # ps.留存天数
-                JsonUtil::encode($req->paras), #                                # req->paras
+                $tablename, req()->uid, req()->zoneid, req()->cmd, #            # Uid, zoneid, cmd
+                (isset(req()->userInfo) ? (tsDay() - tsDay(req()->userInfo->game->baseInfo->firstLogin)) : 0), #  # ps.留存天数
+                JsonUtil::encode(req()->paras), #                               # req->paras
                 JsonUtil::encode($resp->result)); #                             # resp->result
                 JsonUtil::encode($resp->result)); #                             # resp->result
         daoInst()->exec($sql);                                                  # 执行sql
         daoInst()->exec($sql);                                                  # 执行sql
     }
     }
 
 
     /**
     /**
-     * 路由方法
-     * @param Req $req
+     * 路由方法 
      */
      */
-    private static function Route($req) {
-        $proc = OpeCode::getProc($req->ope);                                    # 映射处理模块.
+    private static function Route() {
+        $proc = OpeCode::getProc(req()->ope);                                   # 映射处理模块.
         my_Assert($proc != "err", ErrCode::ope_err);                            # 未能找到对应的处理模块
         my_Assert($proc != "err", ErrCode::ope_err);                            # 未能找到对应的处理模块
         try {
         try {
-            $resp = call_user_func(array($proc, 'procMain'), $req);             # 调用对应的处理逻辑
+            $resp = call_user_func(array($proc, 'procMain'), req());            # 调用对应的处理逻辑
             if (!($resp instanceof Resp)) {                                     # 异常返回值
             if (!($resp instanceof Resp)) {                                     # 异常返回值
                 Err(ErrCode::err_innerfault, JsonUtil::encode($resp));
                 Err(ErrCode::err_innerfault, JsonUtil::encode($resp));
             }
             }

+ 2 - 1
Gameserver/Amfphp/Services/TestServer.php

@@ -19,7 +19,8 @@ class TestServer {
     static public function testApi($req) {
     static public function testApi($req) {
         DebugHelper::debug($req);
         DebugHelper::debug($req);
         $app = new AppServer();
         $app = new AppServer();
-        $ret = $app->api(new Req($req));
+        new Req($req);
+        $ret = $app->api();
         DebugHelper::debug($ret);
         DebugHelper::debug($ret);
     }
     }
 
 

+ 2 - 3
Gameserver/Amfphp/index.php

@@ -69,7 +69,7 @@ class Index {
             self::$debugMsg .= '<br/>解压耗时:' . $rt->getRenderTime();          # 解码耗时
             self::$debugMsg .= '<br/>解压耗时:' . $rt->getRenderTime();          # 解码耗时
             # 计时器开始
             # 计时器开始
         }
         }
-        new Req($req);
+        new Req($req);                                                          # 初始化req()
     }
     }
 
 
     static function Run() {
     static function Run() {
@@ -78,8 +78,7 @@ class Index {
             $rt->start();
             $rt->start();
         }
         }
         $app = new AppServer();                                                 # 初始化业务框架
         $app = new AppServer();                                                 # 初始化业务框架
-
-        $resp = $app->api(req());                                               # 分发处理逻辑
+        $resp = $app->api();                                                    # 分发处理逻辑
         if (self::$isDebugging) {                                               # 组织调试信息
         if (self::$isDebugging) {                                               # 组织调试信息
             $rt->end();                                                         # 计时器结束
             $rt->end();                                                         # 计时器结束
             $ms = round($rt->getRenderTime(false) / 1000, 2);                   # 耗时换算成毫秒
             $ms = round($rt->getRenderTime(false) / 1000, 2);                   # 耗时换算成毫秒

+ 1 - 0
Gameserver/Amfphp/model/Const/GameConfig.php

@@ -3,6 +3,7 @@
  // 由CodeGenerator创建。
  // 由CodeGenerator创建。
  // Copyright (C) gwang (wanggangzero@qq.com), Loyalsoft@sjz Inc
  // Copyright (C) gwang (wanggangzero@qq.com), Loyalsoft@sjz Inc
  // author: gwang 
  // author: gwang 
+ // 日期: 2021-04-30 08:39:16
 ////////////////////
 ////////////////////
 
 
 /**
 /**

+ 1 - 1
Gameserver/Amfphp/model/Const/sm_drop.php

@@ -3,7 +3,7 @@
  // 由CodeGenerator创建。
  // 由CodeGenerator创建。
  // Copyright (C) gwang (wanggangzero@qq.com), Loyalsoft@sjz Inc
  // Copyright (C) gwang (wanggangzero@qq.com), Loyalsoft@sjz Inc
  // author: gwang 
  // author: gwang 
- // 日期: 2021-03-24 15:35:06
+ // 日期: 2021-04-28 11:54:57
 ////////////////////
 ////////////////////
 
 
 
 

+ 1 - 1
Gameserver/Amfphp/model/Const/sm_eventAction.php

@@ -3,7 +3,7 @@
  // 由CodeGenerator创建。
  // 由CodeGenerator创建。
  // Copyright (C) gwang (wanggangzero@qq.com), Loyalsoft@sjz Inc
  // Copyright (C) gwang (wanggangzero@qq.com), Loyalsoft@sjz Inc
  // author: gwang 
  // author: gwang 
- // 日期: 2021-04-21 16:17:13
+ // 日期: 2021-04-23 16:57:10
 ////////////////////
 ////////////////////
 
 
 
 

+ 1 - 1
Gameserver/Amfphp/model/Const/sm_gate.php

@@ -3,7 +3,7 @@
  // 由CodeGenerator创建。
  // 由CodeGenerator创建。
  // Copyright (C) gwang (wanggangzero@qq.com), Loyalsoft@sjz Inc
  // Copyright (C) gwang (wanggangzero@qq.com), Loyalsoft@sjz Inc
  // author: gwang 
  // author: gwang 
- // 日期: 2021-04-20 14:18:50
+ // 日期: 2021-04-28 15:54:11
 ////////////////////
 ////////////////////
 
 
 
 

+ 1 - 1
Gameserver/Amfphp/model/Const/sm_item_base.php

@@ -3,7 +3,7 @@
  // 由CodeGenerator创建。
  // 由CodeGenerator创建。
  // Copyright (C) gwang (wanggangzero@qq.com), Loyalsoft@sjz Inc
  // Copyright (C) gwang (wanggangzero@qq.com), Loyalsoft@sjz Inc
  // author: gwang 
  // author: gwang 
- // 日期: 2021-04-16 12:21:10
+ // 日期: 2021-04-28 11:43:23
 ////////////////////
 ////////////////////
 
 
 
 

+ 1 - 1
Gameserver/Amfphp/model/Const/sm_item_package.php

@@ -3,7 +3,7 @@
  // 由CodeGenerator创建。
  // 由CodeGenerator创建。
  // Copyright (C) gwang (wanggangzero@qq.com), Loyalsoft@sjz Inc
  // Copyright (C) gwang (wanggangzero@qq.com), Loyalsoft@sjz Inc
  // author: gwang 
  // author: gwang 
- // 日期: 2021-02-04 15:29:40
+ // 日期: 2021-04-28 11:34:55
 ////////////////////
 ////////////////////
 
 
 
 

+ 1 - 1
Gameserver/Amfphp/model/Const/sm_item_taskcard.php

@@ -3,7 +3,7 @@
  // 由CodeGenerator创建。
  // 由CodeGenerator创建。
  // Copyright (C) gwang (wanggangzero@qq.com), Loyalsoft@sjz Inc
  // Copyright (C) gwang (wanggangzero@qq.com), Loyalsoft@sjz Inc
  // author: gwang 
  // author: gwang 
- // 日期: 2021-04-20 14:22:32
+ // 日期: 2021-04-28 11:55:42
 ////////////////////
 ////////////////////
 
 
 
 

+ 1 - 1
Gameserver/Amfphp/model/Const/sm_item_weapon.php

@@ -3,7 +3,7 @@
  // 由CodeGenerator创建。
  // 由CodeGenerator创建。
  // Copyright (C) gwang (wanggangzero@qq.com), Loyalsoft@sjz Inc
  // Copyright (C) gwang (wanggangzero@qq.com), Loyalsoft@sjz Inc
  // author: gwang 
  // author: gwang 
- // 日期: 2021-04-20 16:56:32
+ // 日期: 2021-04-23 16:23:01
 ////////////////////
 ////////////////////
 
 
 
 

+ 1 - 1
Gameserver/Amfphp/model/Const/sm_item_yanling.php

@@ -3,7 +3,7 @@
  // 由CodeGenerator创建。
  // 由CodeGenerator创建。
  // Copyright (C) gwang (wanggangzero@qq.com), Loyalsoft@sjz Inc
  // Copyright (C) gwang (wanggangzero@qq.com), Loyalsoft@sjz Inc
  // author: gwang 
  // author: gwang 
- // 日期: 2021-04-20 16:57:00
+ // 日期: 2021-04-23 14:23:33
 ////////////////////
 ////////////////////
 
 
 
 

+ 1 - 1
Gameserver/Amfphp/model/Const/sm_plot.php

@@ -3,7 +3,7 @@
  // 由CodeGenerator创建。
  // 由CodeGenerator创建。
  // Copyright (C) gwang (wanggangzero@qq.com), Loyalsoft@sjz Inc
  // Copyright (C) gwang (wanggangzero@qq.com), Loyalsoft@sjz Inc
  // author: gwang 
  // author: gwang 
- // 日期: 2021-04-22 15:13:49
+ // 日期: 2021-04-30 08:37:50
 ////////////////////
 ////////////////////
 
 
 
 

+ 1 - 1
Gameserver/Amfphp/model/Const/sm_sysmail.php

@@ -3,7 +3,7 @@
  // 由CodeGenerator创建。
  // 由CodeGenerator创建。
  // Copyright (C) gwang (wanggangzero@qq.com), Loyalsoft@sjz Inc
  // Copyright (C) gwang (wanggangzero@qq.com), Loyalsoft@sjz Inc
  // author: gwang 
  // author: gwang 
- // 日期: 2021-03-25 15:55:41
+ // 日期: 2021-04-25 11:32:13
 ////////////////////
 ////////////////////
 
 
 
 

+ 26 - 26
Gameserver/Amfphp/process/FightProc.php

@@ -14,53 +14,53 @@ class FightProc {
     /**
     /**
      * 战斗逻辑分发
      * 战斗逻辑分发
      * 所有的Proc中必须有这样一个方法
      * 所有的Proc中必须有这样一个方法
-     * @param Req $req
      */
      */
-    static function procMain($req) {
-        switch ($req->cmd) {
+    static function procMain() {
+        switch (req()->cmd) {
             # 关卡-征战
             # 关卡-征战
             case CmdCode::cmd_fight_arenas_preFight:                            # 6800 关卡挑战 - 预先计算掉落
             case CmdCode::cmd_fight_arenas_preFight:                            # 6800 关卡挑战 - 预先计算掉落
-                return SweepGatesProc::Arenas_preFight($req);
+                return SweepGatesProc::Arenas_preFight();
             case CmdCode::cmd_fight_arenasfight:                                # 6801 挑战关卡
             case CmdCode::cmd_fight_arenasfight:                                # 6801 挑战关卡
-                return SweepGatesProc::Arenas_Fight($req);
+                return SweepGatesProc::Arenas_Fight();
             case CmdCode::cmd_fight_arenassweep:                                # [6802] 扫荡
             case CmdCode::cmd_fight_arenassweep:                                # [6802] 扫荡
                 Err(ErrCode::function_notopen_msg);                             # 暂未开放扫荡功能. -gwang 2020.4.20
                 Err(ErrCode::function_notopen_msg);                             # 暂未开放扫荡功能. -gwang 2020.4.20
-                return SweepGatesProc::Arenas_NewSweepFight($req);
+                return SweepGatesProc::Arenas_NewSweepFight(req());
 
 
             case CmdCode::cmd_fight_GetArenasActiveReward:                      # 6806 领取章节星级奖励
             case CmdCode::cmd_fight_GetArenasActiveReward:                      # 6806 领取章节星级奖励
-                return SweepGatesProc::DrawChapterStarsReward($req);
+                return SweepGatesProc::DrawChapterStarsReward();
+
             // <editor-fold defaultstate="collapsed" desc="    玩家挑战    "> 
             // <editor-fold defaultstate="collapsed" desc="    玩家挑战    "> 
             case CmdCode::cmd_fight_GetChallengeAdversaryInfo:                  # 6803 获取挑战对手的信息
             case CmdCode::cmd_fight_GetChallengeAdversaryInfo:                  # 6803 获取挑战对手的信息
-                return PVPProc::GetChallengeAdversaryInfo($req);
+                return PVPProc::GetChallengeAdversaryInfo();
             case CmdCode::cmd_fight_LogChallengeResult:                         # 6804 记录挑战结果
             case CmdCode::cmd_fight_LogChallengeResult:                         # 6804 记录挑战结果
-                return PVPProc::LogChallengeInfo($req);
+                return PVPProc::LogChallengeInfo();
             case CmdCode::cmd_fight_GetChallengeLog:                            # 6805 拉取挑战记录
             case CmdCode::cmd_fight_GetChallengeLog:                            # 6805 拉取挑战记录
-                return PVPProc::GetChagllengeLog($req);
+                return PVPProc::GetChagllengeLog();
 
 
 // </editor-fold>
 // </editor-fold>
             //  <editor-fold defaultstate="collapsed" desc="   PVP 模块 681x ">
             //  <editor-fold defaultstate="collapsed" desc="   PVP 模块 681x ">
             case CmdCode::cmd_fight_pvp_maininfo:                               # [6810] 竞技场 主界面拉取信息
             case CmdCode::cmd_fight_pvp_maininfo:                               # [6810] 竞技场 主界面拉取信息
-                return PVPProc::pvpMainInfo($req);
+                return PVPProc::pvpMainInfo();
             case CmdCode::cmd_fight_pvp_refresh:                                # [6811] 竞技场 刷新对手列表
             case CmdCode::cmd_fight_pvp_refresh:                                # [6811] 竞技场 刷新对手列表
-                return PVPProc::pvp_Refresh($req);
+                return PVPProc::pvp_Refresh();
             case CmdCode::cmd_fight_pvp_pk:                                     # [6812] 竞技场 挑战对手
             case CmdCode::cmd_fight_pvp_pk:                                     # [6812] 竞技场 挑战对手
-                return PVPProc::pvp_PK($req);
+                return PVPProc::pvp_PK();
             case CmdCode::cmd_fight_pvp_setTeam:                                # [6813] 竞技场 设定防守队伍
             case CmdCode::cmd_fight_pvp_setTeam:                                # [6813] 竞技场 设定防守队伍
-                return PVPProc::pvp_setTeam($req);
+                return PVPProc::pvp_setTeam();
             case CmdCode::cmd_fight_pvp_buyTicket:                              # [6814] 竞技场 购买挑战票
             case CmdCode::cmd_fight_pvp_buyTicket:                              # [6814] 竞技场 购买挑战票
-                return PVPProc::pvp_buyticket($req);
+                return PVPProc::pvp_buyticket();
             case CmdCode::cmd_fight_pvp_getrank:                                # [6815] 竞技场 查看排行榜
             case CmdCode::cmd_fight_pvp_getrank:                                # [6815] 竞技场 查看排行榜
-                return PVPProc::pvp_getRank($req);
+                return PVPProc::pvp_getRank();
             case CmdCode::cmd_fight_pvp_getLog:                                 # [6816] 竞技场 查看挑战记录
             case CmdCode::cmd_fight_pvp_getLog:                                 # [6816] 竞技场 查看挑战记录
-                return PVPProc::pvp_getFightLogs($req);
+                return PVPProc::pvp_getFightLogs();
 // </editor-fold>
 // </editor-fold>
             // <editor-fold defaultstate="collapsed" desc="   竞技商店 682x  ">
             // <editor-fold defaultstate="collapsed" desc="   竞技商店 682x  ">
             case CmdCode::cmd_fight_pvpShop_getMainInfo:                        # [6820] 竞技场 竞技商店主界面
             case CmdCode::cmd_fight_pvpShop_getMainInfo:                        # [6820] 竞技场 竞技商店主界面
-                return PVPProc::pvpShopMain($req);
+                return PVPProc::pvpShopMain();
             case CmdCode::cmd_fight_pvpShop_buy:                                # [6821] 竞技场 竞技商店购买道具
             case CmdCode::cmd_fight_pvpShop_buy:                                # [6821] 竞技场 竞技商店购买道具
-                return PVPProc::pvpShopBuy($req);
+                return PVPProc::pvpShopBuy();
             case CmdCode::cmd_fight_pvpShop_refresh:                            # [6822] 竞技场 竞技商店刷新道具(扣钻)
             case CmdCode::cmd_fight_pvpShop_refresh:                            # [6822] 竞技场 竞技商店刷新道具(扣钻)
-                return PVPProc::pvpShopRefresh($req);
+                return PVPProc::pvpShopRefresh();
             // </editor-fold>
             // </editor-fold>
             default:
             default:
                 return Resp::err(ErrCode::cmd_err);
                 return Resp::err(ErrCode::cmd_err);
@@ -68,14 +68,14 @@ class FightProc {
     }
     }
 
 
     /**
     /**
-     * @param Req $req
+     * 清理每日字段
      */
      */
-    static function ClearByDay($req) {
-        SweepGatesProc::ClearGateTimes($req);                                   # 清理每个难度副本的每日战斗次数 
-        $pvp = new Info_UserPVP($req->userInfo->game->pvp);
+    static function ClearByDay() {
+        SweepGatesProc::ClearGateTimes(req());                                   # 清理每个难度副本的每日战斗次数 
+        $pvp = new Info_UserPVP(req()->userInfo->game->pvp);
         $pvp->refreshDailyData();
         $pvp->refreshDailyData();
-        $pvp->sendRewardEmail($req->zoneid, $req->uid, PVPProc::GetCurSeasonID());
-        $req->userInfo->game->pvp = $pvp;
+        $pvp->sendRewardEmail(req()->zoneid, req()->uid, PVPProc::GetCurSeasonID());
+        req()->userInfo->game->pvp = $pvp;
     }
     }
 
 
 }
 }

+ 75 - 101
Gameserver/Amfphp/process/FightProc/PVPProc.php

@@ -47,11 +47,10 @@ class PVPProc {
 
 
     /**
     /**
      * [6803] 挑战 - 查询对手信息 等级、头像、昵称、战队信息(言灵师,等级,星级,武器,技能,言灵)
      * [6803] 挑战 - 查询对手信息 等级、头像、昵称、战队信息(言灵师,等级,星级,武器,技能,言灵)
-     * @param req $req
      */
      */
-    public static function GetChallengeAdversaryInfo($req) {
-        $targetUID = $req->paras[0];                                            # 参数: 对手的UID
-        $uinfo = UserProc::getUserInfo($req->zoneid, $targetUID);    # 读取玩家信息 
+    public static function GetChallengeAdversaryInfo() {
+        $targetUID = req()->paras[0];                                           # 参数: 对手的UID
+        $uinfo = UserProc::getUserInfo(req()->zoneid, $targetUID);              # 读取玩家信息 
         if (null == $uinfo) {
         if (null == $uinfo) {
             Err(ErrCode::user_no_err);
             Err(ErrCode::user_no_err);
         }
         }
@@ -59,7 +58,6 @@ class PVPProc {
 
 
         $heros = new \stdClass();
         $heros = new \stdClass();
         $curTeamId = $team->curUseTeamID;
         $curTeamId = $team->curUseTeamID;
-        $arr_nil = array();
         foreach ($team->teamDic->$curTeamId->heros as $i => $hid) {
         foreach ($team->teamDic->$curTeamId->heros as $i => $hid) {
             if ($hid > 0) {
             if ($hid > 0) {
                 $n_hid = $hid - 10000;
                 $n_hid = $hid - 10000;
@@ -86,13 +84,11 @@ class PVPProc {
 
 
     /**
     /**
      * [6804] 挑战 - 记录挑战结果
      * [6804] 挑战 - 记录挑战结果
-     * @param req $req
      */
      */
-    static function LogChallengeInfo($req) {
-        // 参数: 对手uid,对手昵称,对手头像, 对战结果, 胜利者的留言(失败时无法留言"")
-        list($targetUID, $name, $headImg, $win, $msg) = $req->paras;
-        $key_mine = MemKey_User::OffensiveLog_zset($req->zoneid, $req->uid);
-        $key_target = MemKey_User::DefensiveLog_zset($req->zoneid, $targetUID);
+    static function LogChallengeInfo() {
+        list($targetUID, $name, $headImg, $win, $msg) = req()->paras;     // 参数: 对手uid,对手昵称,对手头像, 对战结果, 胜利者的留言(失败时无法留言"")
+        $key_mine = MemKey_User::OffensiveLog_zset(req()->zoneid, req()->uid);
+        $key_target = MemKey_User::DefensiveLog_zset(req()->zoneid, $targetUID);
         $ts = now();                                                            # 记录时间戳
         $ts = now();                                                            # 记录时间戳
         gMem()->zadd($key_mine, array(#                                         # 组装被挑战对手信息
         gMem()->zadd($key_mine, array(#                                         # 组装被挑战对手信息
             JsonUtil::encode(array(
             JsonUtil::encode(array(
@@ -106,36 +102,33 @@ class PVPProc {
         gMem()->zremrangebyrank($key_mine, self::maxLogCount, -1);              # 保留50条数据
         gMem()->zremrangebyrank($key_mine, self::maxLogCount, -1);              # 保留50条数据
         gMem()->zadd($key_target, array(#                                       # 组装挑战者信息
         gMem()->zadd($key_target, array(#                                       # 组装挑战者信息
             JsonUtil::encode(array(
             JsonUtil::encode(array(
-                'uid' => $req->uid,
-                'name' => $req->userInfo->game->baseInfo->name,
-                'headImg' => $req->userInfo->game->baseInfo->headImg,
+                'uid' => req()->uid,
+                'name' => req()->userInfo->game->baseInfo->name,
+                'headImg' => req()->userInfo->game->baseInfo->headImg,
                 'win' => !my_null_default($win, false),
                 'win' => !my_null_default($win, false),
                 'msg' => my_null_default($msg, ""),
                 'msg' => my_null_default($msg, ""),
                 'ts' => $ts
                 'ts' => $ts
             )) => $ts));
             )) => $ts));
-        gMem()->zremrangebyrank($key_target, self::maxLogCount, -1);         # 保留50条数据
+        gMem()->zremrangebyrank($key_target, self::maxLogCount, -1);            # 保留50条数据
         // 暂无发放奖励流程
         // 暂无发放奖励流程
-        // 更新每日任务
-        TaskProc::OnRankChalenge();
+        TaskProc::OnRankChalenge();                                             // 更新每日任务
         UserProc::updateUserInfo();
         UserProc::updateUserInfo();
-        // 返回
         return Resp::ok();                                                      # 返回成功
         return Resp::ok();                                                      # 返回成功
     }
     }
 
 
     /**
     /**
      * [6805] 挑战 - 拉取挑战记录
      * [6805] 挑战 - 拉取挑战记录
-     * @param req $req
      */
      */
-    static function GetChagllengeLog($req) {
+    static function GetChagllengeLog() {
         // 参数:无
         // 参数:无
-        $key_off = MemKey_User::OffensiveLog_zset($req->zoneid, $req->uid);
-        $key_def = MemKey_User::DefensiveLog_zset($req->zoneid, $req->uid);
+        $key_off = MemKey_User::OffensiveLog_zset(req()->zoneid, req()->uid);
+        $key_def = MemKey_User::DefensiveLog_zset(req()->zoneid, req()->uid);
         // 拉取自己的挑战记录
         // 拉取自己的挑战记录
         $offLog = gMem()->zrange($key_off, 0, self::maxLogCount);
         $offLog = gMem()->zrange($key_off, 0, self::maxLogCount);
         $defLog = gMem()->zrange($key_def, 0, self::maxLogCount);
         $defLog = gMem()->zrange($key_def, 0, self::maxLogCount);
         // Ps. 挑战记录分为2个榜, 且按照时间戳记录,晚于指定时间戳的判定为未读消息,挑战记录最多记录50条
         // Ps. 挑战记录分为2个榜, 且按照时间戳记录,晚于指定时间戳的判定为未读消息,挑战记录最多记录50条
 //        if (!CommUtil::isPropertyExists($req->userInfo->game->privateState, "lastCheckDefLog")) {
 //        if (!CommUtil::isPropertyExists($req->userInfo->game->privateState, "lastCheckDefLog")) {
-        $req->userInfo->game->privateState->lastCheckDefLog_ts = now();         # 记录时间戳
+        req()->userInfo->game->privateState->lastCheckDefLog_ts = now();         # 记录时间戳
 //        }
 //        }
         UserProc::updateUserInfo();                                             # 回写数据
         UserProc::updateUserInfo();                                             # 回写数据
         // 记录拉取时间戳(在主界面有个未读消息条数显示, 需要靠最后拉取时间戳对比, 时间戳之后的消息是未读消息)
         // 记录拉取时间戳(在主界面有个未读消息条数显示, 需要靠最后拉取时间戳对比, 时间戳之后的消息是未读消息)
@@ -162,27 +155,25 @@ class PVPProc {
      */
      */
 
 
     /**
     /**
-     * [6820] 竞技商店 主界面
-     * @param req $req
+     * [6820] 竞技商店 主界面 
      */
      */
-    public static function pvpShopMain($req) {
-        $pvp = new Info_UserPVP($req->userInfo->game->pvp);                     # PVP信息
+    public static function pvpShopMain() {
+        $pvp = new Info_UserPVP(req()->userInfo->game->pvp);                     # PVP信息
         if ($pvp->shopRefreshTs < now()) {                                      # 检查刷新时间<now => 刷新商品列表
         if ($pvp->shopRefreshTs < now()) {                                      # 检查刷新时间<now => 刷新商品列表
             $pvp->shopRefreshTs = now() + glc()->PVP_shop_refresh_interval;     # 更新刷新时间
             $pvp->shopRefreshTs = now() + glc()->PVP_shop_refresh_interval;     # 更新刷新时间
             $pvp->curShopItems = GameConfig::pvp_shop();                        # 重刷道具
             $pvp->curShopItems = GameConfig::pvp_shop();                        # 重刷道具
-            $req->userInfo->game->pvp = $pvp;                                   # 回写
+            req()->userInfo->game->pvp = $pvp;                                   # 回写
             UserProc::updateUserInfo();
             UserProc::updateUserInfo();
         }
         }
         return Resp::ok($pvp);                                                  // 返回
         return Resp::ok($pvp);                                                  // 返回
     }
     }
 
 
     /**
     /**
-     * [6821] 竞技 商店 购买道具
-     * @param req $req
+     * [6821] 竞技 商店 购买道具 
      */
      */
-    public static function pvpShopBuy($req) {
-        $index = $req->paras[0];                                                # 参数:道具索引(typeId)
-        $pvp = new Info_UserPVP($req->userInfo->game->pvp);                     # PVP 数据
+    public static function pvpShopBuy() {
+        $index = req()->paras[0];                                                # 参数:道具索引(typeId)
+        $pvp = new Info_UserPVP(req()->userInfo->game->pvp);                     # PVP 数据
         my_Assert(CommUtil::isPropertyExists($pvp->curShopItems, $index), ErrCode::err_innerfault); # 没有找到改商品
         my_Assert(CommUtil::isPropertyExists($pvp->curShopItems, $index), ErrCode::err_innerfault); # 没有找到改商品
 //        isEditor() && $citem = new \sm_pvp_shop();
 //        isEditor() && $citem = new \sm_pvp_shop();
         $citem = $pvp->curShopItems->$index;                                    # 查询物品数据
         $citem = $pvp->curShopItems->$index;                                    # 查询物品数据
@@ -192,24 +183,23 @@ class PVPProc {
         my_Assert($pvp->pvpCoins > $citem->price, ErrCode::pvp_coinnotenough);  # pvp币不足 
         my_Assert($pvp->pvpCoins > $citem->price, ErrCode::pvp_coinnotenough);  # pvp币不足 
         $citem->sold += 1;                                                      # 设置已售罄/已购买标志
         $citem->sold += 1;                                                      # 设置已售罄/已购买标志
         $pvp->pvpCoins -= $citem->price;                                        # 扣除竞技币 
         $pvp->pvpCoins -= $citem->price;                                        # 扣除竞技币 
-        StoreProc::AddMultiItemInStore($req, $citem->goods);                    // 发放道具
-        $req->userInfo->game->pvp = $pvp;                                       // 回写数据
+        StoreProc::AddMultiItemInStore(req(), $citem->goods);                    // 发放道具
+        req()->userInfo->game->pvp = $pvp;                                       // 回写数据
         UserProc::updateUserInfo();
         UserProc::updateUserInfo();
-        return Resp::ok(array('pvp' => $pvp, 'store' => $req->userInfo->game->store)); # 返回
+        return Resp::ok(array('pvp' => $pvp, 'store' => req()->userInfo->game->store)); # 返回
     }
     }
 
 
     /**
     /**
-     * [6822] 竞技 商店 刷新道具
-     * @param req $req
+     * [6822] 竞技 商店 刷新道具 
      */
      */
-    public static function pvpShopRefresh($req) {
+    public static function pvpShopRefresh() {
         // 扣除刷新消耗
         // 扣除刷新消耗
-        $pvp = new Info_UserPVP($req->userInfo->game->pvp);
+        $pvp = new Info_UserPVP(req()->userInfo->game->pvp);
         $costCash = glc()->PVP_shop_refresh_cash;
         $costCash = glc()->PVP_shop_refresh_cash;
-        my_Assert(Data_UserGame::Consume_Cash($req->userInfo->game->baseInfo, $costCash), ErrCode::notenough_cash_msg);
+        my_Assert(Data_UserGame::Consume_Cash(req()->userInfo->game->baseInfo, $costCash), ErrCode::notenough_cash_msg);
 //        $pvp->shopRefreshTs = now() + glc()->PVP_shop_refresh_interval;         # 更新刷新时间
 //        $pvp->shopRefreshTs = now() + glc()->PVP_shop_refresh_interval;         # 更新刷新时间
         $pvp->curShopItems = GameConfig::pvp_shop();                            # 重刷道具
         $pvp->curShopItems = GameConfig::pvp_shop();                            # 重刷道具
-        $req->userInfo->game->pvp = $pvp;                                       # 回写
+        req()->userInfo->game->pvp = $pvp;                                       # 回写
         UserProc::updateUserInfo();                                             # 回写玩家数据
         UserProc::updateUserInfo();                                             # 回写玩家数据
         return Resp::ok($pvp);                                                  # 返回
         return Resp::ok($pvp);                                                  # 返回
     }
     }
@@ -240,23 +230,22 @@ class PVPProc {
 
 
     /**
     /**
      * [6810] 竞技场 拉取主界面信息
      * [6810] 竞技场 拉取主界面信息
-     * @param Req $req
      */
      */
-    static function pvpMainInfo($req) {
-        $uid = $req->uid;                                                       # 快速访问UID
-        $zoneid = $req->zoneid;                                                 # 快速访问zoneid
-        $pvp = new Info_UserPVP($req->userInfo->game->pvp);                     # 设计玩家pvp数据结构
+    static function pvpMainInfo() {
+        $uid = req()->uid;                                                       # 快速访问UID
+        $zoneid = req()->zoneid;                                                 # 快速访问zoneid
+        $pvp = new Info_UserPVP(req()->userInfo->game->pvp);                     # 设计玩家pvp数据结构
         $pvp->refreshDailyData();                                               # 刷新免费挑战次数
         $pvp->refreshDailyData();                                               # 刷新免费挑战次数
         $seasonId = self::GetCurSeasonID();                                     # 当前赛季ID
         $seasonId = self::GetCurSeasonID();                                     # 当前赛季ID
         $key = MemKey_GameRun::Game_PVPScoreByZoneSeason_zset($zoneid, $seasonId); # 积分总榜
         $key = MemKey_GameRun::Game_PVPScoreByZoneSeason_zset($zoneid, $seasonId); # 积分总榜
 
 
         $score = self::_getScore_by_uid($uid, $key);                            # 玩家积分
         $score = self::_getScore_by_uid($uid, $key);                            # 玩家积分
         $rank = self::_getRank_by_uid($uid, $key);                              # 玩家排名
         $rank = self::_getRank_by_uid($uid, $key);                              # 玩家排名
-        $fPower = HeroProc::CalcUserFightPower($zoneid, $uid, $req->userInfo->game); # 玩家总战力?还是当前防守队伍的战斗力?
+        $fPower = HeroProc::CalcUserFightPower($zoneid, $uid, req()->userInfo->game); # 玩家总战力?还是当前防守队伍的战斗力?
         $numNewLog = 0; // todo: 真正查询是否有新战报
         $numNewLog = 0; // todo: 真正查询是否有新战报
         $matches = self::getNewMatches($pvp, $uid, $zoneid);                    # 获得新的匹配对手
         $matches = self::getNewMatches($pvp, $uid, $zoneid);                    # 获得新的匹配对手
         $pvp->sendRewardEmail($zoneid, $uid, $seasonId);                        # 发奖励邮件 
         $pvp->sendRewardEmail($zoneid, $uid, $seasonId);                        # 发奖励邮件 
-        $req->userInfo->game->pvp = $pvp;
+        req()->userInfo->game->pvp = $pvp;
         UserProc::updateUserInfo();
         UserProc::updateUserInfo();
         $ret = array(#                                                          # 组装 返回值结构
         $ret = array(#                                                          # 组装 返回值结构
             'score' => $score, #                                                # 自己的积分
             'score' => $score, #                                                # 自己的积分
@@ -272,17 +261,16 @@ class PVPProc {
     }
     }
 
 
     /**
     /**
-     * [6811] 竞技场 刷新对手
-     * @param Req $req
+     * [6811] 竞技场 刷新对手 
      */
      */
-    static function pvp_Refresh($req) {
+    static function pvp_Refresh() {
         // 刷新无花费, 间隔时间3秒(客户端控制得了)
         // 刷新无花费, 间隔时间3秒(客户端控制得了)
-        $pvp = new Info_UserPVP($req->userInfo->game->pvp);
+        $pvp = new Info_UserPVP(req()->userInfo->game->pvp);
         $ts = now();
         $ts = now();
         my_Assert($pvp->nextRefreshTs < $ts, ErrCode::pvp_refresh_time);        # 验证时间间隔
         my_Assert($pvp->nextRefreshTs < $ts, ErrCode::pvp_refresh_time);        # 验证时间间隔
-        $pvp->curMatches = self::getNewMatches($pvp, $req->uid, $req->zoneid);
+        $pvp->curMatches = self::getNewMatches($pvp, req()->uid, req()->zoneid);
         $pvp->nextRefreshTs = now(3);
         $pvp->nextRefreshTs = now(3);
-        $req->userInfo->game->pvp = $pvp;
+        req()->userInfo->game->pvp = $pvp;
         UserProc::updateUserInfo();                                             # 回写数据 
         UserProc::updateUserInfo();                                             # 回写数据 
         $ret = array(
         $ret = array(
             'curMatches' => my_null_default($pvp->curMatches, array()), #       # 当前对手清单
             'curMatches' => my_null_default($pvp->curMatches, array()), #       # 当前对手清单
@@ -292,15 +280,14 @@ class PVPProc {
 
 
     /**
     /**
      * [6812] 竞技场 挑战对手xx
      * [6812] 竞技场 挑战对手xx
-     * @param Req $req
      */
      */
-    static function pvp_PK($req) {
-        $uid = $req->uid;
-        $zoneid = $req->zoneid;
-        $baseInfo = $req->userInfo->game->baseInfo;
-        list($target_uid, $result, $target_name, $target_HeadImg) = $req->paras; # 对手id,胜负结果 0负,1胜
+    static function pvp_PK() {
+        $uid = req()->uid;
+        $zoneid = req()->zoneid;
+        $baseInfo = req()->userInfo->game->baseInfo;
+        list($target_uid, $result, $target_name, $target_HeadImg) = req()->paras; # 对手id,胜负结果 0负,1胜
 
 
-        $pvp = $req->userInfo->game->pvp;
+        $pvp = req()->userInfo->game->pvp;
 
 
         if ($pvp->freeFightTickets > 0) {                                       # 有免费挑战票,先扣除免费的
         if ($pvp->freeFightTickets > 0) {                                       # 有免费挑战票,先扣除免费的
             $pvp->freeFightTickets -= 1;
             $pvp->freeFightTickets -= 1;
@@ -333,7 +320,7 @@ class PVPProc {
             TaskProc::OnPvPWinN($pvp->totalWin);
             TaskProc::OnPvPWinN($pvp->totalWin);
             TaskProc::OnPvPScoreN($R_A);
             TaskProc::OnPvPScoreN($R_A);
         }
         }
-        $req->userInfo->game->pvp = $pvp;
+        req()->userInfo->game->pvp = $pvp;
         TaskProc::OnPvp();                                                      # 每日PVP挑战即可
         TaskProc::OnPvp();                                                      # 每日PVP挑战即可
         UserProc::updateUserInfo();                                             # 回写数据
         UserProc::updateUserInfo();                                             # 回写数据
         // 写挑战记录
         // 写挑战记录
@@ -357,76 +344,64 @@ class PVPProc {
 
 
     /**
     /**
      * [6813] 竞技场 设置防守队伍
      * [6813] 竞技场 设置防守队伍
-     * @param req $req
      */
      */
-    public static function pvp_setTeam($req) {
-        $heros = $req->paras[0];                                                # para: 新阵容
-        $pvp = new Info_UserPVP($req->userInfo->game->pvp);
+    public static function pvp_setTeam() {
+        $heros = req()->paras[0];                                                # para: 新阵容
+        $pvp = new Info_UserPVP(req()->userInfo->game->pvp);
         my_Assert(is_array($heros), ErrCode::paras_err);                        # 参数检查
         my_Assert(is_array($heros), ErrCode::paras_err);                        # 参数检查
         $pvp->defTeam = $heros;                                                 # 更新阵容
         $pvp->defTeam = $heros;                                                 # 更新阵容
-        $req->userInfo->game->pvp = $pvp;
+        req()->userInfo->game->pvp = $pvp;
         UserProc::updateUserInfo();                                             # 回存数据
         UserProc::updateUserInfo();                                             # 回存数据
         return Resp::ok($pvp);                                                  # 返回
         return Resp::ok($pvp);                                                  # 返回
     }
     }
 
 
     /**
     /**
-     * [6814] 购买挑战票
-     * @param Req $req
-     * @return type
+     * [6814] 购买挑战票 
+     * @return Resp
      */
      */
-    static function pvp_buyticket($req) {
-        $amt = $req->paras[0];                                                  # 购买数量
-        # 检查并扣除消耗
-        # 增加挑战票
-        # 回存数据
-        # 返回
+    static function pvp_buyticket() {
+        $amt = req()->paras[0];                                                 # 购买数量
         my_Assert($amt > 0, ErrCode::paras_err);                                # 数量>0
         my_Assert($amt > 0, ErrCode::paras_err);                                # 数量>0
-        $pvp = new Info_UserPVP($req->userInfo->game->pvp);
+        $pvp = new Info_UserPVP(req()->userInfo->game->pvp);
         $g = glc();
         $g = glc();
         $costCash = $g->PVP_pk_ticket_price * $amt;                             # 计算消耗钻石
         $costCash = $g->PVP_pk_ticket_price * $amt;                             # 计算消耗钻石
         my_Assert($costCash > 0, ErrCode::pvp_ticket_cost_ilegal);              # 定价数据异常
         my_Assert($costCash > 0, ErrCode::pvp_ticket_cost_ilegal);              # 定价数据异常
+        my_Assert(Data_UserGame::Consume_Cash(req()->userInfo->game->baseInfo, $costCash), ErrCode::notenough_cash_msg);    # 扣除钻石失败
 
 
-        if (!Data_UserGame::Consume_Cash($req->userInfo->game->baseInfo, $costCash)) {    # 扣除钻石失败
-            return Resp::err(ErrCode::notenough_cash_msg);
-        }
         $pvp->fightTicket += $amt;                                              # 发放挑战票
         $pvp->fightTicket += $amt;                                              # 发放挑战票
-        $req->userInfo->game->pvp = $pvp;
+        req()->userInfo->game->pvp = $pvp;
         UserProc::updateUserInfo();                                             # 回写玩家数据
         UserProc::updateUserInfo();                                             # 回写玩家数据
         $ret = array(
         $ret = array(
             'fightTicket' => $pvp->fightTicket,
             'fightTicket' => $pvp->fightTicket,
             'costCash' => $costCash,
             'costCash' => $costCash,
-            'userCash' => $req->userInfo->game->baseInfo->cash
+            'userCash' => req()->userInfo->game->baseInfo->cash
         );
         );
         return Resp::ok($ret);                                                  # 返回
         return Resp::ok($ret);                                                  # 返回
     }
     }
 
 
     /**
     /**
-     * [6815] 竞技场 拉取榜单数据
-     * @param Req $req
+     * [6815] 竞技场 拉取榜单数据 
      */
      */
-    static function pvp_getRank($req) {
+    static function pvp_getRank() {
         $maxAmt = 10;                                                           # 一次最多取10个玩家信息
         $maxAmt = 10;                                                           # 一次最多取10个玩家信息
-        $zoneid = $req->zoneid;
-        $index = $req->paras[0];                                                # 起始(0)
-        $n = $req->paras[1];                                                    # 数量, (n<=max)
-        #
+        $zoneid = req()->zoneid;
+        list($index, $n) = req()->paras;                                        # 起始(0), 数量(n<=max)
         if ($n < 1 || $n > $maxAmt) {                                           # 防御非法情况
         if ($n < 1 || $n > $maxAmt) {                                           # 防御非法情况
             $n = $maxAmt;
             $n = $maxAmt;
         }
         }
-        $arr = self::getRankPlayers($zoneid, $index - 1, ($index + $n) - 1);
-//
+        $arr = self::getRankPlayers($zoneid, $index - 1, ($index + $n) - 1);    // 上榜玩家
         $rankId = $index;
         $rankId = $index;
         $result = ObjectInit();
         $result = ObjectInit();
         if (count($arr)) {
         if (count($arr)) {
-            foreach ($arr as $key => $value) {//  $value 的数据类型是array
+            foreach ($arr as $key => $value) {                                  //  $value 的数据类型是array
                 $value["uid"] = $key;
                 $value["uid"] = $key;
                 $result->$rankId = $value;
                 $result->$rankId = $value;
                 $rankId += 1;
                 $rankId += 1;
             }
             }
         }
         }
         $key_rank = MemKey_GameRun::Game_PVPScoreByZoneSeason_zset($zoneid, self::GetCurSeasonID());
         $key_rank = MemKey_GameRun::Game_PVPScoreByZoneSeason_zset($zoneid, self::GetCurSeasonID());
-        $myRank = self::_getRank_by_uid($req->uid, $key_rank);
-        $myScore = self::_getScore_by_uid($uid, $key_rank);
+        $myRank = self::_getRank_by_uid(req()->uid, $key_rank);
+        $myScore = self::_getScore_by_uid(req()->uid, $key_rank);
         $ret = array(
         $ret = array(
             'dic' => $result,
             'dic' => $result,
             'myRank' => $myRank,
             'myRank' => $myRank,
@@ -436,21 +411,20 @@ class PVPProc {
     }
     }
 
 
     /**
     /**
-     * [6816] 竞技场 查看战报
-     * @param Req $req
+     * [6816] 竞技场 查看战报 
      */
      */
-    static function pvp_getFightLogs($req) {
+    static function pvp_getFightLogs() {
         // 提取主动挑战+被挑战记录
         // 提取主动挑战+被挑战记录
         // 更新下刷新时间
         // 更新下刷新时间
         // 返回
         // 返回
         // 参数:无
         // 参数:无
-        $key_off = MemKey_User::PVP_OffensiveLog_zset($req->zoneid, $req->uid);
-        $key_def = MemKey_User::PVP_DefensiveLog_zset($req->zoneid, $req->uid);
+        $key_off = MemKey_User::PVP_OffensiveLog_zset(req()->zoneid, req()->uid);
+        $key_def = MemKey_User::PVP_DefensiveLog_zset(req()->zoneid, req()->uid);
         // 拉取自己的挑战记录
         // 拉取自己的挑战记录
         $offLog = gMem()->zrange($key_off, 0, self::maxLogCount);               # 主动挑战数据
         $offLog = gMem()->zrange($key_off, 0, self::maxLogCount);               # 主动挑战数据
         $defLog = gMem()->zrange($key_def, 0, self::maxLogCount);               # 防守数据
         $defLog = gMem()->zrange($key_def, 0, self::maxLogCount);               # 防守数据
         // Ps. 挑战记录分为2个榜, 且按照时间戳记录,晚于指定时间戳的判定为未读消息,挑战记录最多记录50条
         // Ps. 挑战记录分为2个榜, 且按照时间戳记录,晚于指定时间戳的判定为未读消息,挑战记录最多记录50条
-        $pvp = new Info_UserPVP($req->userInfo->game->pvp);                     # 玩家竞技场数据
+        $pvp = new Info_UserPVP(req()->userInfo->game->pvp);                    # 玩家竞技场数据
         $pvp->lastCheckDefLog_ts = now();                                       # 记录时间戳 
         $pvp->lastCheckDefLog_ts = now();                                       # 记录时间戳 
         UserProc::updateUserInfo();                                             # 回写数据 
         UserProc::updateUserInfo();                                             # 回写数据 
         array_walk($offLog, function (&$i) {                                    # 解码一下
         array_walk($offLog, function (&$i) {                                    # 解码一下

+ 65 - 76
Gameserver/Amfphp/process/FightProc/SweepGatesProc.php

@@ -26,13 +26,12 @@ class SweepGatesProc {
     }
     }
 
 
     /**
     /**
-     * [6800] 关卡战斗 - 预计算掉落
-     * @param req $req
+     * [6800] 关卡战斗 - 预计算掉落 
      */
      */
-    public static function Arenas_preFight($req) {
-        list($gateId, $difficulty) = $req->paras;                               # 提取参数 
+    public static function Arenas_preFight() {
+        list($gateId, $difficulty) = req()->paras;                               # 提取参数 
         my_Assert($gateId > 0, "关卡id非法");
         my_Assert($gateId > 0, "关卡id非法");
-        $isFirst = self::isFirstChallenge($req, $gateId, $difficulty);          # 是否首次通关 
+        $isFirst = self::isFirstChallenge(req(), $gateId, $difficulty);          # 是否首次通关 
         $smGate = GameConfig::gate_getItem($gateId);                            # 关卡配置数据
         $smGate = GameConfig::gate_getItem($gateId);                            # 关卡配置数据
         $i = $difficulty + 1;                                                   # 按三个难度取不同的值.
         $i = $difficulty + 1;                                                   # 按三个难度取不同的值.
 //        $tili = self::getProperty_n($smGate, "tili", $i);                     # 体力暂时未用上
 //        $tili = self::getProperty_n($smGate, "tili", $i);                     # 体力暂时未用上
@@ -60,7 +59,7 @@ class SweepGatesProc {
             }
             }
         }
         }
         $_rewards = implode(";", $arr);                                         # 最终奖励字符串
         $_rewards = implode(";", $arr);                                         # 最终奖励字符串
-        $redis_key = MemKey_User::temp_arenas_pre_reward_md5_str($req->zoneid, $req->uid);
+        $redis_key = MemKey_User::temp_arenas_pre_reward_md5_str(req()->zoneid, req()->uid);
         $md5 = md5($gateId . $difficulty . $_rewards);
         $md5 = md5($gateId . $difficulty . $_rewards);
         gMem()->set($redis_key, $md5, 86400);                                   # 有效期一天,有新的就覆盖
         gMem()->set($redis_key, $md5, 86400);                                   # 有效期一天,有新的就覆盖
         return Resp::ok(array("r" => $_rewards));                               # 返回奖励字符串
         return Resp::ok(array("r" => $_rewards));                               # 返回奖励字符串
@@ -73,12 +72,11 @@ class SweepGatesProc {
 
 
     /**
     /**
      * [6806] 领取章节星数奖励
      * [6806] 领取章节星数奖励
-     * @param req $req
      */
      */
-    public static function DrawChapterStarsReward($req) {
-        list($chapterId, $hard, $stars) = $req->paras;                          # 参数: 章节id, 难度, 分数
+    public static function DrawChapterStarsReward() {
+        list($chapterId, $hard, $stars) = req()->paras;                         # 参数: 章节id, 难度, 分数
         $hard = $hard + 1;
         $hard = $hard + 1;
-        $userGates = new Info_UserGateDifficulty($req->userInfo->game->gates);
+        $userGates = new Info_UserGateDifficulty(req()->userInfo->game->gates);
         if (!property_exists($userGates->chapterStarsRwd, $chapterId)) {        # 防御第一次读取本章节数据
         if (!property_exists($userGates->chapterStarsRwd, $chapterId)) {        # 防御第一次读取本章节数据
             $userGates->chapterStarsRwd->$chapterId = ObjectInit();
             $userGates->chapterStarsRwd->$chapterId = ObjectInit();
         }
         }
@@ -108,38 +106,35 @@ class SweepGatesProc {
             default:
             default:
                 break;
                 break;
         }
         }
-        my_Assert(null != $userGateL, ErrCode::err_innerfault);                 # 玩家数据有问题
-//        var_dump($userGateL);
-        array_walk($userGateL->gates, function ($v, $k)use (&$sumOfStars) {       # 累加星数
+        my_Assert(null != $userGateL, ErrCode::err_innerfault);                 # 玩家数据有问题 
+        array_walk($userGateL->gates, function ($v, $k)use (&$sumOfStars) {     # 累加星数
             $sinfo = new GateStar($v->star);
             $sinfo = new GateStar($v->star);
             $sumOfStars += $sinfo->Stars();
             $sumOfStars += $sinfo->Stars();
         });
         });
-//        var_dump($sumOfStars);
         my_Assert($stars <= $sumOfStars, ErrCode::err_arenas_starreward_starNotEnough); # 星数未达标
         my_Assert($stars <= $sumOfStars, ErrCode::err_arenas_starreward_starNotEnough); # 星数未达标
-        StoreProc::AddMultiItemInStore($req, $starCfg->reward);                 # 发放奖励
+        StoreProc::AddMultiItemInStore(req(), $starCfg->reward);                # 发放奖励
         $starsArr[] = $stars;                                                   # 领奖记录
         $starsArr[] = $stars;                                                   # 领奖记录
         $userGates->chapterStarsRwd->$chapterId->$hard = $starsArr;             # 回写数据
         $userGates->chapterStarsRwd->$chapterId->$hard = $starsArr;             # 回写数据
-        $req->userInfo->game->gates = $userGates;
-//        var_dump($userGates);
+        req()->userInfo->game->gates = $userGates;
+
         UserProc::updateUserInfo();
         UserProc::updateUserInfo();
-        return Resp::ok(array("store" => $req->userInfo->game->store,
+        return Resp::ok(array("store" => req()->userInfo->game->store,
                     'gold' => req()->userInfo->game->baseInfo->gold,
                     'gold' => req()->userInfo->game->baseInfo->gold,
                     'cash' => req()->userInfo->game->baseInfo->cash
                     'cash' => req()->userInfo->game->baseInfo->cash
         ));         # 返回值  
         ));         # 返回值  
     }
     }
 
 
     /**
     /**
-     * [6801] 关卡挑战1次
-     * @param Req $req 
+     * [6801] 关卡挑战1次 
      */
      */
-    public static function Arenas_Fight($req) {
-        list($gateId, $difficulty, $star, $TeamObj, $rewardStr, $_killedbossId) = $req->paras;  # 提取参数: 挑战的关卡Id, 关卡难度(0,1,2), 几星, 队伍, 奖励字符串
+    public static function Arenas_Fight() {
+        list($gateId, $difficulty, $star, $TeamObj, $rewardStr, $_killedbossId) = req()->paras;  # 提取参数: 挑战的关卡Id, 关卡难度(0,1,2), 几星, 队伍, 奖励字符串
         my_Assert($gateId > 0, ErrCode::err_arenasgate_indexillegal);           # 关卡id非法
         my_Assert($gateId > 0, ErrCode::err_arenasgate_indexillegal);           # 关卡id非法
 //        $md5 = gMem()->get(MemKey_User::temp_arenas_pre_reward_md5_str($req->zoneid, $req->uid));
 //        $md5 = gMem()->get(MemKey_User::temp_arenas_pre_reward_md5_str($req->zoneid, $req->uid));
 //        $_md5 = md5($gateId . $difficulty . $rewardStr);
 //        $_md5 = md5($gateId . $difficulty . $rewardStr);
 //        my_Assert($md5 == $_md5, ErrCode::err_arenas_rewardIllegal);            # 奖励不匹配
 //        my_Assert($md5 == $_md5, ErrCode::err_arenas_rewardIllegal);            # 奖励不匹配
         $isFirst = false;                                                       # 是否首次通关
         $isFirst = false;                                                       # 是否首次通关
-        self::recordFight($req, $gateId, $difficulty, $star, $isFirst);         # 更新挑战记录 
+        self::recordFight(req(), $gateId, $difficulty, $star, $isFirst);         # 更新挑战记录 
         $smGate = GameConfig::gate_getItem($gateId);                            # 关卡配置数据
         $smGate = GameConfig::gate_getItem($gateId);                            # 关卡配置数据
         $i = $difficulty + 1;                                                   # 按三个难度取不同的值. 
         $i = $difficulty + 1;                                                   # 按三个难度取不同的值. 
 //        $gold = self::getProperty_n($smGate, "gold", $i);
 //        $gold = self::getProperty_n($smGate, "gold", $i);
@@ -150,13 +145,13 @@ class SweepGatesProc {
         if ($isFirst) {                                                         # 是否首次通关切换奖励内容
         if ($isFirst) {                                                         # 是否首次通关切换奖励内容
             $exp = $firstExp;
             $exp = $firstExp;
             if ($firstHero > 0) {                                               # 首次通关解锁英雄
             if ($firstHero > 0) {                                               # 首次通关解锁英雄
-                HeroProc::AddHeroWithStar($req, $firstHero, 0);                 # 添加英雄
+                HeroProc::AddHeroWithStar(req(), $firstHero, 0);                 # 添加英雄
             }
             }
         }
         }
 
 
 //        $rewardArr = self::SetRewards($req, $rewardStr);                        # 发通关奖励 
 //        $rewardArr = self::SetRewards($req, $rewardStr);                        # 发通关奖励 
 //        Data_UserGame::Add_Gold($req->userInfo->game->baseInfo, $gold);         # 发金币
 //        Data_UserGame::Add_Gold($req->userInfo->game->baseInfo, $gold);         # 发金币
-        Data_UserGame::Add_Exp($req->userInfo->game->baseInfo, $exp);           # 给玩家(指挥官)增加经验
+        Data_UserGame::Add_Exp(req()->userInfo->game->baseInfo, $exp);           # 给玩家(指挥官)增加经验
         foreach ($TeamObj as $heroUID) {
         foreach ($TeamObj as $heroUID) {
             if ($heroUID > 0) {
             if ($heroUID > 0) {
                 echoLine("$heroUID");
                 echoLine("$heroUID");
@@ -167,14 +162,14 @@ class SweepGatesProc {
 #
 #
         TaskProc::OnPassGateN($gateId, $difficulty + 1);
         TaskProc::OnPassGateN($gateId, $difficulty + 1);
         $result = array(
         $result = array(
-            'store' => $req->userInfo->game->store,
-            'heros' => $req->userInfo->game->heros,
-            'gates' => $req->userInfo->game->gates,
-            'tili' => $req->userInfo->game->baseInfo->tili,
-            'time' => $req->userInfo->game->privateState->TiliTime,
-            'gold' => $req->userInfo->game->baseInfo->gold,
-            'resPoint' => $req->userInfo->game->baseInfo->resPoint,
-            'cash' => $req->userInfo->game->baseInfo->cash,
+            'store' => req()->userInfo->game->store,
+            'heros' => req()->userInfo->game->heros,
+            'gates' => req()->userInfo->game->gates,
+            'tili' => req()->userInfo->game->baseInfo->tili,
+            'time' => req()->userInfo->game->privateState->TiliTime,
+            'gold' => req()->userInfo->game->baseInfo->gold,
+            'resPoint' => req()->userInfo->game->baseInfo->resPoint,
+            'cash' => req()->userInfo->game->baseInfo->cash,
             'exp' => $exp,
             'exp' => $exp,
 //            'rewardstr' => implode(';', $rewardArr),
 //            'rewardstr' => implode(';', $rewardArr),
             'isFirst' => $isFirst,
             'isFirst' => $isFirst,
@@ -262,6 +257,7 @@ class SweepGatesProc {
         if ($typeId != '503') {
         if ($typeId != '503') {
             $diffCult->highest = 503000;                                        # 设置为关卡第一关
             $diffCult->highest = 503000;                                        # 设置为关卡第一关
         }
         }
+
         if ($gateId > $diffCult->highest + 1) {                                 # 不能跳关
         if ($gateId > $diffCult->highest + 1) {                                 # 不能跳关
             Err(ErrCode::err_arenasgate_indexillegal);
             Err(ErrCode::err_arenasgate_indexillegal);
         }
         }
@@ -272,7 +268,7 @@ class SweepGatesProc {
         }
         }
         $diffCult->latest = $gateId;                                            # 记录上次挑战关卡id
         $diffCult->latest = $gateId;                                            # 记录上次挑战关卡id
 
 
-        $uGate = new Ins_UGate();                                              # 当前关卡的记录数据
+        $uGate = new Ins_UGate();                                               # 当前关卡的记录数据
         if (isset($diffCult->gates->$gateId)) {
         if (isset($diffCult->gates->$gateId)) {
             $uGate = $diffCult->gates->$gateId;
             $uGate = $diffCult->gates->$gateId;
         }
         }
@@ -281,7 +277,6 @@ class SweepGatesProc {
         if (!$uGate->cleared) {
         if (!$uGate->cleared) {
             $uGate->cleared = 1;                                                # 当前关卡是否已通关     
             $uGate->cleared = 1;                                                # 当前关卡是否已通关     
             $isFirst = true;
             $isFirst = true;
-//            CLog::err($uGate);
         }
         }
         $diffCult->gates->$gateId = $uGate;                                     # 回写关卡记录
         $diffCult->gates->$gateId = $uGate;                                     # 回写关卡记录
 
 
@@ -306,10 +301,10 @@ class SweepGatesProc {
      * @param req $req 
      * @param req $req 
      */
      */
     public static function Arenas_NewSweepFight($req) {
     public static function Arenas_NewSweepFight($req) {
-
+        Err(ErrCode::err_method_obsoleted);                                     # 没开扫荡功能
         $gateId = $req->paras[0];
         $gateId = $req->paras[0];
         $difficulty = $req->paras[1];                                           # 关卡难度 difficulty
         $difficulty = $req->paras[1];                                           # 关卡难度 difficulty
-        $costItemId = $req->paras[2];                                             #扫荡券id
+        $costItemId = $req->paras[2];                                           # 扫荡券id
 
 
         $smGate = GameConfig::gate_getItem($gateId);
         $smGate = GameConfig::gate_getItem($gateId);
 
 
@@ -321,31 +316,26 @@ class SweepGatesProc {
             $gatesRecord->record = ObjectInit();                                # 防御未初始化的变量
             $gatesRecord->record = ObjectInit();                                # 防御未初始化的变量
         }
         }
 
 
-///按   三个难度取不同的值.
-        $i = $difficulty + 1;
+
+        $i = $difficulty + 1;                                                   // 按三个难度取不同的值.
         $tili = self::getProperty_n($smGate, "tili", $i);
         $tili = self::getProperty_n($smGate, "tili", $i);
         $reward = self::getProperty_n($smGate, "reward", $i);
         $reward = self::getProperty_n($smGate, "reward", $i);
         $gold = self::getProperty_n($smGate, "gold", $i);
         $gold = self::getProperty_n($smGate, "gold", $i);
         $exp = self::getProperty_n($smGate, "exp", $i);
         $exp = self::getProperty_n($smGate, "exp", $i);
         $err = StoreProc::removeItemFromStore($req->userInfo->game->store, $costItemId, 1);
         $err = StoreProc::removeItemFromStore($req->userInfo->game->store, $costItemId, 1);
-        if ($err) { # 扣除失败
-            return Resp::err($err);
-        }
-#补充战斗记录
-        $canfighterr = SweepGatesProc::CanFight($req, $gateId, $difficulty);
+        my_Assert(ErrCode::ok == $err, $err);                                   # 扣除失败
+        $canfighterr = SweepGatesProc::CanFight($req, $gateId, $difficulty);    # 补充战斗记录
         if ($canfighterr) {#不能符合战斗要求
         if ($canfighterr) {#不能符合战斗要求
             return $canfighterr;
             return $canfighterr;
         }
         }
-//
         $req->userInfo->game->gates->newGateRecord = $gatesRecord;              # 回写数据
         $req->userInfo->game->gates->newGateRecord = $gatesRecord;              # 回写数据
         ActiveProc::ChangeTili(- $tili);                                        # 扣减体力
         ActiveProc::ChangeTili(- $tili);                                        # 扣减体力
         $req->userInfo->game->gates->TotalNum++;                                # 更新战斗次数统计
         $req->userInfo->game->gates->TotalNum++;                                # 更新战斗次数统计
         $req->userInfo->game->gates->Times++;
         $req->userInfo->game->gates->Times++;
 
 
-// 按照概率规则发放奖品
         $rewardsArr = explode(";", $reward);
         $rewardsArr = explode(";", $reward);
         $rwds = array();
         $rwds = array();
-        foreach ($rewardsArr as $r) {
+        foreach ($rewardsArr as $r) {                                          // 按照概率规则发放奖品
             $arr = explode(',', $r);
             $arr = explode(',', $r);
             $itemid = intval($arr[0]);
             $itemid = intval($arr[0]);
             $num = intval($arr[1]);
             $num = intval($arr[1]);
@@ -359,12 +349,10 @@ class SweepGatesProc {
             }
             }
         }
         }
 
 
-        Data_UserGame::Add_Gold($req->userInfo->game->baseInfo, $gold);        # 发放金币奖励
-        if ($err) {
-            return Resp::err($err);
-        }
-        Data_UserGame::Add_Exp($req->userInfo->game->baseInfo, $exp);                     # 发放经验奖励
-        UserProc::updateUserInfo();                                         # 在获取战利品哪里已经update了.
+        Data_UserGame::Add_Gold($req->userInfo->game->baseInfo, $gold);         # 发放金币奖励
+        my_Assert(ErrCode::ok == $err, $err);                                   # 失败
+        Data_UserGame::Add_Exp($req->userInfo->game->baseInfo, $exp);           # 发放经验奖励
+        UserProc::updateUserInfo();                                             # 在获取战利品哪里已经update了.
         $result = array(
         $result = array(
             'store' => $req->userInfo->game->store,
             'store' => $req->userInfo->game->store,
             'heros' => $req->userInfo->game->heros,
             'heros' => $req->userInfo->game->heros,
@@ -386,7 +374,6 @@ class SweepGatesProc {
      * @return type
      * @return type
      */
      */
     static function CanFight($req, $gateId, $difficulty) {
     static function CanFight($req, $gateId, $difficulty) {
-
         $gatesRecord = $req->userInfo->game->gates->newGateRecord;
         $gatesRecord = $req->userInfo->game->gates->newGateRecord;
         $smGate = GameConfig::gate_getItem($gateId);
         $smGate = GameConfig::gate_getItem($gateId);
         if (!CommUtil::isPropertyExists($gatesRecord->record, $gateId)) {
         if (!CommUtil::isPropertyExists($gatesRecord->record, $gateId)) {
@@ -436,8 +423,7 @@ class SweepGatesProc {
         return null;   // false
         return null;   // false
     }
     }
 
 
-// </editor-fold>
-//
+// </editor-fold> 
 //
 //
 // <editor-fold defaultstate="collapsed" desc="    好友租借   ">
 // <editor-fold defaultstate="collapsed" desc="    好友租借   ">
 //    /**
 //    /**
@@ -924,38 +910,41 @@ class SweepGatesProc {
 //
 //
 }
 }
 
 
-/// <summary>
-/// 任务/挑战目标达成记录(三星评价)
-/// </summary>
-/// <author>gwang</author>
+/**
+ * 任务/挑战目标达成记录(三星评价)
+ * @author gwang
+ */
 class GateStar {
 class GateStar {
 
 
-/// <summary>
-/// 根据后台记录的数值构造(反向提供给前端显示层)
-/// </summary>
-/// <param name="i"></param>
+    /**
+     * 根据后台记录的数值构造(反向提供给前端显示层)
+     * @param int $i
+     */
     public function __construct($i) {
     public function __construct($i) {
         $this->S1 = ($i & 1) > 0;
         $this->S1 = ($i & 1) > 0;
         $this->S2 = ($i & 2) > 0;
         $this->S2 = ($i & 2) > 0;
         $this->S3 = ($i & 4) > 0;
         $this->S3 = ($i & 4) > 0;
     }
     }
 
 
-/// <summary>
-/// 第一个目标达成
-/// </summary>
+    /**
+     * @var bool 第一个目标达成
+     */
     public $S1;
     public $S1;
-/// <summary>
-/// 第二个目标达成
-/// </summary>
+
+    /**
+     * @var bool 第二个目标达成
+     */
     public $S2;
     public $S2;
-/// <summary>
-/// 第三个目标达成
-/// </summary>
+
+    /**
+     * @var bool 第三个目标达成
+     */
     public $S3;
     public $S3;
 
 
-/// <summary>
-/// 统计总星数
-/// </summary>
+    /**
+     * 统计总星数
+     * @return int
+     */
     public function Stars() {
     public function Stars() {
         return ($this->S3 ? 1 : 0) + ($this->S2 ? 1 : 0) + ($this->S1 ? 1 : 0);
         return ($this->S3 ? 1 : 0) + ($this->S2 ? 1 : 0) + ($this->S1 ? 1 : 0);
     }
     }