Преглед изворни кода

add 主线挑战后台接口

wanggangzero пре 10 месеци
родитељ
комит
eadc8bc477

+ 47 - 42
Gameserver/App/base/CmdCode.php

@@ -8,16 +8,16 @@ namespace loyalsoft;
  * @author jgao,gwang,cyzhao
  */
 class CmdCode {
-    //
-    // <editor-fold defaultstate="collapsed" desc="支付操作码 - 88xx">
+//
+// <editor-fold defaultstate="collapsed" desc="支付操作码 - 88xx">
 
     /**
      * 领取首付礼包
      */
     const cmd_pay_getfirstpaygift = 8802;
 
-    // <editor-fold defaultstate="collapsed" desc="移动支付">
-    //---------- 移动端 支付API 操作码 ----
+// <editor-fold defaultstate="collapsed" desc="移动支付">
+//---------- 移动端 支付API 操作码 ----
 
     /**
      * 【移动端】购买物品
@@ -69,8 +69,8 @@ class CmdCode {
 // </editor-fold>
 //
 // </editor-fold>
-    //
-    // <editor-fold defaultstate="collapsed" desc="用户操作码 - 60xx">
+//
+// <editor-fold defaultstate="collapsed" desc="用户操作码 - 60xx">
 
     /**
      * 获取分区列表
@@ -101,37 +101,37 @@ class CmdCode {
      * 删除账号
      */
     const cmd_user_delUserUid = 6006;
-    
+
     /**
      * 移除新头像标志
      */
     const cmd_user_removeNewHeadImgTip = 6007;
-    
+
     /**
      * 读公告
      */
     const cmd_user_readAnnouncement = 6008;
-    
+
     /**
      * 重置功能解锁记录信息
      */
     const cmd_user_clearFunUnlockInfo = 6009;
 
-    // </editor-fold>
-    // <editor-fold defaultstate="collapsed" desc="活动操作码 - 61xx">
+// </editor-fold>
+// <editor-fold defaultstate="collapsed" desc="活动操作码 - 61xx">
 
     /**
      * 7日奖励领取
      */
     const cmd_active_day7_drawreward = 6101;
-    
+
     /**
-     * 
+     *
      */
     const cmd_active_drawPackageByCode = 6102;
 
-    // </editor-fold>
-    // <editor-fold defaultstate="collapsed" desc="任务操作码 - 62xx">
+// </editor-fold>
+// <editor-fold defaultstate="collapsed" desc="任务操作码 - 62xx">
 
     /**
      * [6201] 任务 - 拉取最新任务信息
@@ -157,9 +157,9 @@ class CmdCode {
      * 领取活跃点宝箱奖励
      */
     const cmd_task_receiveActivePointBoxReward = 6205;
-    // </editor-fold>
-    //
-    // <editor-fold defaultstate="collapsed" desc="背包操作码 - 64xx">
+// </editor-fold>
+//
+// <editor-fold defaultstate="collapsed" desc="背包操作码 - 64xx">
 
     const cmd_store_put = 6401;
 
@@ -167,13 +167,13 @@ class CmdCode {
      * 装备
      */
     const cmd_store_gemSet = 6402;
-    //const cmd_store_equip = 6402;
+//const cmd_store_equip = 6402;
 
     /**
      * 卸下装备
      */
     const cmd_store_gemRemove = 6403;
-    //const cmd_store_RemoveEquip = 6403;
+//const cmd_store_RemoveEquip = 6403;
 
     /**
      * 装备升级
@@ -224,8 +224,8 @@ class CmdCode {
      * 洗练
      */
     const store_gemXiLian = 6413;
-    // </editor-fold>
-    // <editor-fold defaultstate="collapsed" desc="商城操作码 - 65xx">
+// </editor-fold>
+// <editor-fold defaultstate="collapsed" desc="商城操作码 - 65xx">
 
     /**
      * 商城购买东西
@@ -236,9 +236,9 @@ class CmdCode {
      * 购买体力
      */
     const cmd_shop_BuyTili = 6502;
-    // </editor-fold>
-    // <editor-fold defaultstate="collapsed" desc="英雄模块操作码 - 66xx">
-    //
+// </editor-fold>
+// <editor-fold defaultstate="collapsed" desc="英雄模块操作码 - 66xx">
+//
 
     /**
      * 切换英雄
@@ -254,9 +254,9 @@ class CmdCode {
      * 角色升星
      */
     const hero_strengthenStar = 6603;
-    //
+//
 // </editor-fold>
-    // <editor-fold defaultstate="collapsed" desc="邮件操作码 - 67xx">
+// <editor-fold defaultstate="collapsed" desc="邮件操作码 - 67xx">
 
     const cmd_email_questEmailList = 6701;
 
@@ -289,9 +289,9 @@ class CmdCode {
      * [6707] 发送测试用道具
      */
     const cmd_mail_sendTestItems = 6707;
-    // </editor-fold>
-    //
-    // <editor-fold defaultstate="collapsed" desc="战斗操作码 - 68xx">
+// </editor-fold>
+//
+// <editor-fold defaultstate="collapsed" desc="战斗操作码 - 68xx">
 
     /**
      * 主线剧情: 奖励结算
@@ -377,32 +377,37 @@ class CmdCode {
      * 是否存在未领取的荣誉榜奖励
      */
     const fight_rank_IsExistRankReward = 6817;
-    
+
     /**
      * 启灵进化解锁新的能力点
      */
     const fight_evolveUnlock = 6818;
 
-    // </editor-fold>
-    
-    // <editor-fold defaultstate="collapsed" desc="系统操作码 - 69xx">
-    
+    /**
+     * 主线挑战--通关
+     */
+    const fight_MainTZPass = 6819;
+
+    /**
+     * 主线挑战--领取奖励
+     */
+    const fight_MainTZGetReward = 6820;
+
+// </editor-fold>
+// <editor-fold defaultstate="collapsed" desc="系统操作码 - 69xx">
+
     /**
      * 6901 心跳
      */
     const cmd_system_clienttick = 6901;
 
-
     /**
      * 拉取系统广播消息
      */
     const cmd_system_getsysmessage = 6902;
-    
-    
-    
-    // </editor-fold>
-    
-    // <editor-fold defaultstate="collapsed" desc="    反射方法    ">
+
+// </editor-fold>
+// <editor-fold defaultstate="collapsed" desc="    反射方法    ">
 
     /**
      * 辅助方法, 将所有错误码信息转换到CSV文本中.

+ 2 - 3
Gameserver/App/model/User/Data_UserGame.php

@@ -37,7 +37,7 @@ class Data_UserGame extends HashSaver {
      * @var Info_PrivateState
      */
     public $privateState;
-    
+
     /**
      * 任务
      * @var Info_Task
@@ -99,7 +99,7 @@ class Data_UserGame extends HashSaver {
     /**
      * 关卡数据
      * @param bool $save 是否需要回存
-     * @return Info_UserGateDifficulty
+     * @return Info_Gates
      */
     public function gates($save = true) {
         $this->gates = new Info_Gates($this->gates);
@@ -200,7 +200,6 @@ class Data_UserGame extends HashSaver {
         return $this->task;
     }
 
- 
     /**
      * 角色画像数据
      * @param bool $save 是否需要回存

+ 65 - 31
Gameserver/App/process/FightProc.php

@@ -53,11 +53,45 @@ class FightProc {
                 return self::IsExistRankReward();
             case CmdCode::fight_evolveUnlock:                                   # 6818 启灵解锁
                 return self::EvolveUnlock();
+
+            case CmdCode::fight_MainTZPass:                                     # 6819 主线挑战--通关
+                return self::MainTZPass();
+            case CmdCode::fight_MainTZGetReward:                                # 6820 主线挑战--领取奖励
+                return self::MainTZGetReward();
             default:
                 Err(ErrCode::cmd_err);
         }
     }
 
+    /**
+     * 6819 主线挑战 -- 通关
+     */
+    static function MainTZPass() {
+        list($gateId, $index) = req()->paras;                                   # 关卡id, 通关难度索引(1/2/3)
+        my_Assert(ctx()->gates()->maxPassGateId >= $gateId, ErrCode::gate_GateNoUnlock); # 通关后解锁难度1
+//        isEditor() && $gateInfo = new Ins_GateInfo();
+        $gateInfo = ctx()->gates()->GateList->$gateId;
+        my_Assert($gateInfo->tz_state + 1 >= $index, ErrCode::gate_GateNoUnlock); # 通关上一难度解锁当前难度
+        $gateInfo->tz_state = $index;
+        UserProc::updateUserInfo();
+        return Resp::ok();
+    }
+
+    /**
+     * 6820 主线挑战 -- 领取奖励
+     */
+    static function MainTZGetReward() {
+        list($gateId, $index) = req()->paras;                                   # 关卡id, 通关难度索引(1/2/3)
+        my_Assert(ctx()->gates()->maxPassGateId >= $gateId, ErrCode::gate_GateNoUnlock); # 通关后解锁难度1
+//        isEditor() && $gateInfo = new Ins_GateInfo();
+        $gateInfo = ctx()->gates()->GateList->$gateId;
+        my_Assert($gateInfo->tz_state >= $index, ErrCode::gate_GateNoUnlock);   # 已解锁当前难度
+        my_Assert(Bits::GetBitValue($gateInfo->tz_rewards, $index) == false, ErrCode::gate_GatePriceHasReceive);
+        $gateInfo->tz_rewards = Bits::SetBitValue($gateInfo->tz_rewards, $index, true); # 更新领取记录
+        UserProc::updateUserInfo();
+        return Resp::ok();
+    }
+
     /**
      * 6805 进化解锁
      * @return type
@@ -269,7 +303,7 @@ class FightProc {
                 Err(ErrCode::tower_timeNo);
             }
             ctx()->gates()->TowerGateInfo()->TodayChanNum--;                    # 增加次数
-        } else {                                                                # 主线剧情                       
+        } else {                                                                # 主线剧情
             my_Assert(ctx()->base()->Consume_tili($mo->cost_tili), ErrCode::notenough_tili);
         }
         UserProc::updateUserInfo();
@@ -510,8 +544,8 @@ class FightProc {
 
         self::funUnlock($resultType, $gateId); //备注:这个接口的位置不能动 里面有关卡第一次胜利解锁的功能提示校验
         if ($resultType) {                                                      # 胜利
-            self::skillUnlock_gate($resultType, $gateId);//备注 这个接口位置不能动
-            
+            self::skillUnlock_gate($resultType, $gateId); //备注 这个接口位置不能动
+
             if (ctx()->gates->GateList->$gateId->pass == 0) {
                 ctx()->gates->GateList->$gateId->pass = 1;
                 TaskProc::Day7TaskReset($gateId);                               # 刷新七日任务
@@ -533,7 +567,7 @@ class FightProc {
 //            StoreProc::AddMultiItemInStore($gateMo->reward_win);                # 发放胜利奖励(2024.5.30 过期)
         } else {
             ctx()->gates->GateList->$gateId->fightNum_fail += 1;
-            self::skillUnlock_fightNum($resultType);//这个接口位置不能动
+            self::skillUnlock_fightNum($resultType); //这个接口位置不能动
         }
 //        else {                                                                # 失败
 ////            StoreProc::AddMultiItemInStore($gateMo->reward_fail);               # 发放失败奖励(2024.5.30 过期)
@@ -545,14 +579,14 @@ class FightProc {
         $waveMo = GameConfig::waveItem_getItem($gateId, $finalLayer);
         my_Assert(null != $waveMo, ErrCode::err_const_no);
         $oldLevel = ctx()->baseInfo->level;
-        StoreProc::AddMultiItemInStore('4,'.$waveMo->rewardExp);
+        StoreProc::AddMultiItemInStore('4,' . $waveMo->rewardExp);
         //ctx()->base()->Add_Exp($waveMo->rewardExp);                             # 指挥官经验
         $newLevel = ctx()->baseInfo->level;
-        if($oldLevel != $newLevel){
+        if ($oldLevel != $newLevel) {
             ctx()->privateState->oldLevel = $oldLevel;
             ctx()->privateState->upLevel = $newLevel;
         }
-        
+
         //ctx()->base()->Add_Gold($waveMo->rewardGold);                           # 金币奖励
         //$pickups .= ";1," . $gold + $waveMo->rewardGold;
 
@@ -672,17 +706,17 @@ class FightProc {
         foreach ($dic as $id => $mo) {
             if ($mo->unlock_acc_id_new == null) {
                 continue;
-            }          
+            }
             $strList = explode(':', $mo->unlock_acc_id_new);
             $unlockType = $strList[0];
             $unlockId = $strList[1];
-                        
-            if($unlockType == 1 && $unlockId == $gateId && $resultType == true && ctx()->gates->GateList->$gateId->pass == 0 && !in_array($mo->typeId, ctx()->privateState->skillUnlockRecord)){
+
+            if ($unlockType == 1 && $unlockId == $gateId && $resultType == true && ctx()->gates->GateList->$gateId->pass == 0 && !in_array($mo->typeId, ctx()->privateState->skillUnlockRecord)) {
                 ctx()->privateState->skillUnlockRecord[] = $mo->typeId;
             }
         }
     }
-    
+
     /**
      * 检测技能解锁的 2://皮肤解锁,获取到人物解锁后对应皮肤技能
      * @param type $resultType
@@ -694,58 +728,58 @@ class FightProc {
         foreach ($dic as $id => $mo) {
             if ($mo->unlock_acc_id_new == null) {
                 continue;
-            }           
-                        
+            }
+
             $strList = explode(':', $mo->unlock_acc_id_new);
             $unlockType = $strList[0];
-            $unlockId = $strList[1];               
-            
-            if($unlockType != 2){
+            $unlockId = $strList[1];
+
+            if ($unlockType != 2) {
                 continue;
             }
-            
+
             $heroMo = GameConfig::hero_getItem($heroId);
             $heroTypeId = $heroMo->typeID;
-            $isUnlock =  ctx()->heros->Dic->$heroId->isUnlock;
-            
-            if($unlockId == $heroTypeId && $isUnlock == 0 && !in_array($mo->typeId, ctx()->privateState->skillUnlockRecord)){
+            $isUnlock = ctx()->heros->Dic->$heroId->isUnlock;
+
+            if ($unlockId == $heroTypeId && $isUnlock == 0 && !in_array($mo->typeId, ctx()->privateState->skillUnlockRecord)) {
                 ctx()->privateState->skillUnlockRecord[] = $mo->typeId;
             }
         }
     }
-    
+
     /**
-     * 检测技能解锁的  3://玩家失败X次后解锁   
+     * 检测技能解锁的  3://玩家失败X次后解锁
      * @param type $resultType
      * @param type $gateId
      * @return type
      */
     static function skillUnlock_fightNum($resultType) {
-        if(!$resultType){
+        if (!$resultType) {
             return;
         }
-        
+
         $GateList = ctx()->gates->GateList;
         $num = 0;
         foreach ($GateList as $gateId => $Ins_GateInfo) {
             $num += $Ins_GateInfo->fightNum_fail;
         }
-        
-        $dic = GameConfig::skills();        
+
+        $dic = GameConfig::skills();
         foreach ($dic as $id => $mo) {
             if ($mo->unlock_acc_id_new == null) {
                 continue;
             }
-            
+
             $strList = explode(':', $mo->unlock_acc_id_new);
             $unlockType = $strList[0];
             $unlockId = $strList[1];
-            
-            if($unlockType != 3){
+
+            if ($unlockType != 3) {
                 continue;
             }
-                        
-            if($num == $unlockId && !in_array($mo->typeId, ctx()->privateState->skillUnlockRecord)){
+
+            if ($num == $unlockId && !in_array($mo->typeId, ctx()->privateState->skillUnlockRecord)) {
                 ctx()->privateState->skillUnlockRecord[] = $mo->typeId;
             }
         }