cyzhao vor 1 Jahr
Ursprung
Commit
596129b35d

+ 6 - 1
Gameserver/App/base/CmdCode.php

@@ -116,7 +116,12 @@ class CmdCode {
      * [6202] 任务 - 领取任务奖励
      */
     const cmd_task_getReward = 6202;
-    // </editor-fold>const active_day7_drawreward = 6101;
+   
+    /**
+     * 领取成就奖励
+     */
+    const cmd_task_getAchieveReward = 6203;
+    
     // <editor-fold defaultstate="collapsed" desc="邮件操作码 - 63xx">
 
     const cmd_email_questEmailList = 6301;

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

@@ -3,7 +3,7 @@
  // 由CodeGenerator创建。
  // Copyright (C) gwang (wanggangzero@qq.com), Loyalsoft@sjz Inc
  // author: gwang 
- // 日期: 2023-10-12 15:15:03
+ // 日期: 2023-10-13 15:54:41
 ////////////////////
 
 /**

+ 6 - 1
Gameserver/App/model/Const/sm_achieve.php

@@ -29,10 +29,15 @@ class sm_achieve
     public $name;
 
     /**
-    * @var String 条件参数信息 例:1,5,10,20  
+    * @var String 条件参数  
     */
     public $paras;
 
+    /**
+    * @var String 条件参数信息 例:1,5,10,20  
+    */
+    public $condition;
+
     /**
     * @var Int32 成就信息的类型  
     */

+ 9 - 0
Gameserver/App/model/User/Enum_TaskCmdType.php

@@ -23,4 +23,13 @@ const DailyShopBuyNum = 104; //每日商店购买物品1次          103 每日
 //任意充值1次                  109 任意充值1次  num 1
 //参与每日挑战1次              110  参与每日挑战1次 num 1
     
+}
+
+class Enum_AchieveType extends Enum { 
+
+
+const equiplevel_one = 101;       //单件装备等级达到X级               101 
+const accumulateCostCash = 102;  //
+
+    
 }

+ 10 - 1
Gameserver/App/model/User/Info_Task.php

@@ -52,13 +52,22 @@ class Info_Task extends Object_ext{
     #[ArrayType]
     public $weekTaskAccumulateDrawed = array();
     
+    /**
+     * 成就信息
+     * @var type
+     */
+    public $achieveDic = null;
+
+
     public function initialize() {
       $this->taskcards = new \stdClass();
+      $this->achieveDic = new \stdClass(); 
     }
 
     public function __construct($arg = null) {
         if ($arg == null) {
-            $this->taskcards = new \stdClass();           
+            $this->taskcards = new \stdClass();  
+            $this->achieveDic = new \stdClass(); 
         } else {
             parent::__construct($arg);
         }

+ 53 - 0
Gameserver/App/model/User/Ins_Achieve.php

@@ -0,0 +1,53 @@
+<?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_Achieve
+ *
+ * @author c'y'zhao
+ */
+class Ins_Achieve {   
+    
+    public $typeId = 0;
+    
+    /**
+     * 当前进度条的最大值
+     * @var type
+     */
+    public $max = 0;
+
+    /**
+     * 累计值
+     * @var type
+     */
+    public $val = 0;
+
+    /**
+     * 领取奖励记录
+     * @var type
+     */
+    public $received = 0;
+    
+    /**
+     * 类型
+     * @var type
+     */
+    public $cmd = 0;
+    
+    public function __construct($args) {
+        if ($args != null) {
+           parent::__construct($args); 
+        } 
+    }
+    
+    public function getAchieveMo() {
+        return GameConfig::achieve_getItem($this->typeId);
+    }
+}

+ 124 - 0
Gameserver/App/process/TaskProc.php

@@ -25,11 +25,135 @@ class TaskProc {
                 return TaskProc::getTaskInfo();
             case CmdCode::cmd_task_getReward:                                   # 6202
                 return TaskProc::getReward();    
+            case CmdCode::cmd_task_getAchieveReward:                            # 6203 领取成就奖励
+                return TaskProc::getAchieveReward();                            
+                
             default:
                 Err(ErrCode::cmd_err);
         }
     }
     
+    /**
+     * 6203 领取成就奖励
+     * @return type
+     */
+    public static function getAchieveReward() {
+        list($typeId) = req()->paras;
+         
+        $mo = GameConfig::achieve_getItem($typeId);
+        my_Assert($mo != null, ErrCode::err_const_no);
+        
+        my_Assert(StlUtil::dictHasProperty(ctx()->task->achieveDic, $typeId), ErrCode::err_const_no);
+        $achieveDic = ctx()->task->achieveDic->$typeId;
+       
+        $list = explode(',', $mo->condition);
+        $length = count($list);
+        my_Assert($achieveDic->val>= $achieveDic->max, ErrCode::task_CanotPriceReviced);
+        my_Assert($achieveDic->received < $achieveDic->max, ErrCode::task_PriceRepeatReviced);
+                                    
+        $index = 0;
+        foreach ($list as $k =>$num) {
+            if($num == $achieveDic->max){
+                $index = $k;
+                break;
+            }
+        }        
+        //领取奖励
+        $pList = explode(';', $mo->reward);
+        StoreProc::AddMultiItemInStore($pList[$index]);
+        
+        //下一个max    
+        if($index +1 < $length){
+            $achieveDic->max = $list[$index+1];
+        }
+        ctx()->task->achieveDic->$typeId = $achieveDic;
+        
+        UserProc::updateUserInfo();                    
+        return Resp::ok(array(
+            "achieve"=>ctx()->task->achieveDic,            
+            "cash"=> ctx()->baseInfo->cash,
+            ));
+    }
+    
+    /**
+     * 初始化成就信息
+     */
+    public static function initAchieveData() {
+        $dic = GameConfig::achieve();
+        if($dic == null){
+            return;
+        }
+        
+        $achieveDic = ctx()->task->achieveDic;
+        if(count((array)$achieveDic) > 0){
+            return;
+        }
+        
+        foreach ($dic as $key => $value) {
+            $item = new Ins_Achieve();
+            $typeId = $value->typeId;
+            $item->typeId = $typeId;
+            $item->cmd = $value->cmd;
+            $item->max = explode(',', $value->condition)[0];
+            $achieveDic->$typeId = $item;
+        }
+        ctx()->task->achieveDic = $achieveDic;
+    }
+    
+    //检测成就条件
+    public static function CheckAchieveConditions($arg) {        
+        $achieveDic = ctx()->task->achieveDic;
+        foreach ($achieveDic as $key => $value) {
+            $achieve = new Ins_Achieve($value);
+            $tag = false;
+            if($achieve->cmd == $arg->taskType){
+                $mo = $achieve->getAchieveMo();               
+                if($mo->paras == $arg->paras[0]){//暂定,若有多个参数,在进行解析
+                    $tag = true;
+                }
+                
+            }
+            
+            if($tag){//找到正确数据
+                switch ($arg->ope) {
+                    case Enum_PropelType::set:
+                        $achieve->val = $arg->val; 
+                        break;
+                    case Enum_PropelType::add:
+                        $achieve->val += $arg->val; 
+                        break;
+                    default:
+                        break;
+                }
+                
+                
+            }
+            
+        }
+        
+        ctx()->task->achieveDic = $achieveDic;
+        UserProc::updateUserInfo();            
+        
+    }
+    
+    //-------------------成就条件检测
+    //单件装备等级达到X级
+    static function accumulateEquiplevel_one($lv) {  
+        $taskEventArg = new Ins_TaskEventArgs(Enum_AchieveType::equiplevel_one, Enum_PropelType::set,$lv, array());
+        self::CheckAchieveConditions($taskEventArg);                
+    }
+    
+    
+    //累计消耗X钻石
+    static function accumulateCostCash($num) {  
+        $taskEventArg = new Ins_TaskEventArgs(Enum_AchieveType::accumulateCostCash, Enum_PropelType::add,$num, array());
+        self::CheckAchieveConditions($taskEventArg);                           
+    }
+    
+    
+    
+    //------------------------------------------------------
+    
     public static function getTaskInfo() {
         list($type) = req()->paras;//武器uid