Browse Source

补充逻辑

王刚 1 year ago
parent
commit
b48dd3aa71
2 changed files with 33 additions and 15 deletions
  1. 10 0
      Gameserver/App/base/ErrCode.php
  2. 23 15
      Gameserver/App/process/FightProc.php

+ 10 - 0
Gameserver/App/base/ErrCode.php

@@ -368,6 +368,16 @@ class ErrCode {
      */
     const tower_refreshNo = 3211;
 
+    /**
+     * 挑战关卡: 没有奖励
+     */
+    const tower_rewardNo = 3212;
+
+    /**
+     * 挑战关卡: 起始层id有误
+     */
+    const tower_layerNum = 3213;
+
 // </editor-fold>
 //
 //   // <editor-fold defaultstate="collapsed" desc="    store 3300    ">

+ 23 - 15
Gameserver/App/process/FightProc.php

@@ -348,10 +348,14 @@ class FightProc {
      * @return type
      */
     public static function ChallengeGateStartFight() {
-        if (ctx()->gates()->TowerGateInfo()->TodayChanNum > glc()->tower_daily_chanceNum) {
+        list($layerNum) = req()->paras;
+        if ($layerNum != ctx()->gates()->TowerGateInfo()->CurLayer) {           # 起始层数校验
+            return Resp::err(ErrCode::tower_layerNum);
+        }
+        if (ctx()->gates()->TowerGateInfo()->TodayChanNum > glc()->tower_daily_chanceNum) { # 剩余次数校验
             return Resp::err(ErrCode::tower_timeNo);
         }
-        ctx()->gates()->TowerGateInfo()->TodayChanNum++;
+        ctx()->gates()->TowerGateInfo()->TodayChanNum++;                        # 增加次数
         UserProc::updateUserInfo();
         return Resp::ok();
     }
@@ -361,21 +365,25 @@ class FightProc {
      * @return type
      */
     public static function GateChallengeRewards() {
-        $arr = req()->paras;                                                    # 关卡列表
+        list($finalLayer) = req()->paras;                                       # 战斗结束时的层数
 
-        foreach ($arr as $layerId) {
-            $layerMo = GameConfig::tower_gate_getItem($layerId);
-            my_Assert($layerMo != null, ErrCode::err_const_no);
-            StoreProc::AddMultiItemInStore($layerMo->rewards);                  # 发放奖励
-        }
+        $lastLayer = ctx()->gates()->TowerGateInfo()->CurLayer;
+        if ($finalLayer > $lastLayer) {
+            for ($layerId = $lastLayer; $layerId++; $layerId < $finalLayer) {
 
-        UserProc::updateUserInfo();
-        $ret = array(
-            'store' => ctx()->store,
-            'gold' => ctx()->base()->gold,
-            'cash' => ctx()->base()->cash
-        );
-        return Resp::ok($ret);
+                $layerMo = GameConfig::tower_gate_getItem($layerId);
+                my_Assert($layerMo != null, ErrCode::err_const_no);
+                StoreProc::AddMultiItemInStore($layerMo->rewards);              # 发放奖励
+            }
+            UserProc::updateUserInfo();
+            $ret = array(
+                'store' => ctx()->store,
+                'gold' => ctx()->base()->gold,
+                'cash' => ctx()->base()->cash
+            );
+            return Resp::ok($ret);
+        }
+        return Resp::err(ErrCode::tower_rewardNo);                              # 没有奖励
     }
 
     /**