cyzhao 3 anos atrás
pai
commit
ed3520a730

+ 11 - 1
Gameserver/Amfphp/base/CmdCode.php

@@ -1190,9 +1190,19 @@ class CmdCode {
      *  领取课程奖励
      */
     const cmd_college_ReceiveCourseReward = 7303;
+    
+    /**
+     * 积分兑换道具
+     */
+    const cmd_college_ScoreExchangeItem = 7304;
+    
+    /**
+     * 
+     */
+    //const cmd_college_GetCollegeTaskCardData = 7305;
 
 // </editor-fold>
-// <editor-fold defaultstate="collapsed" desc="学院操作码 - 74xx">
+// <editor-fold defaultstate="collapsed" desc="Auction操作码 - 74xx">
 
     /**
      *  获取全部拍卖信息

+ 11 - 0
Gameserver/Amfphp/base/ErrCode.php

@@ -1502,6 +1502,17 @@ class ErrCode {
      */
     const college_taskCardNumError = 5204;
 
+    /**
+     * 
+     */
+    const college_taskScoreRewardRepeatReceive = 5205;
+    
+    const college_CourseRewardRepeatReceive = 5206;
+    
+    /**
+     * 没有解锁
+     */
+    const college_CourseNotUnlocked = 5207;
 // </editor-fold>
     //
     // <editor-fold defaultstate="collapsed" desc="    反射方法    ">

+ 17 - 1
Gameserver/Amfphp/configs/GameConfig.php

@@ -3,7 +3,7 @@
  // 由CodeGenerator创建。
  // Copyright (C) gwang (wanggangzero@qq.com), Loyalsoft@sjz Inc
  // author: gwang 
- // 日期: 2021-09-24 16:35:29
+ // 日期: 2021-09-26 14:30:16
 ////////////////////
 namespace loyalsoft;
 /**
@@ -1480,6 +1480,22 @@ class GameConfig {
         return self::get_hash_item('worldboss_rankreward2', $itemid);
     }
     /**
+    * 学院积分兑换道具表
+    * @return \score
+    */
+    public static function score()
+    { 
+        static $a = null; 
+        return self::initValue($a, 'score');
+    }
+    /**
+    * @return \sm_score score item数据 
+    */
+    public static function score_getItem($itemid)
+    { 
+        return self::get_hash_item('score', $itemid);
+    }
+    /**
     * 当前版本(时间戳)
     * @return \ver
     */

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

@@ -3,7 +3,7 @@
  // 由CodeGenerator创建。
  // Copyright (C) gwang (wanggangzero@qq.com), Loyalsoft@sjz Inc
  // author: gwang 
- // 日期: 2021-09-24 16:35:29
+ // 日期: 2021-09-26 14:30:16
 ////////////////////
 
 /**
@@ -1480,6 +1480,22 @@ class GameConfig {
         return self::get_hash_item('worldboss_rankreward2', $itemid);
     }
     /**
+    * 学院积分兑换道具表
+    * @return \score
+    */
+    public static function score()
+    { 
+        static $a = null; 
+        return self::initValue($a, 'score');
+    }
+    /**
+    * @return \sm_score score item数据 
+    */
+    public static function score_getItem($itemid)
+    { 
+        return self::get_hash_item('score', $itemid);
+    }
+    /**
     * 当前版本(时间戳)
     * @return \ver
     */

+ 32 - 0
Gameserver/Amfphp/model/Const/sm_score.php

@@ -0,0 +1,32 @@
+<?php
+////////////////////
+ // 由CodeGenerator创建。
+ // Copyright (C) gwang (wanggangzero@qq.com), Loyalsoft@sjz Inc
+ // author: gwang 
+ // 日期: 2021-09-24 16:32:39
+////////////////////
+
+
+/**
+ * Static Model score 学院积分兑换道具表
+ */
+class sm_score
+{
+
+    /**
+    * @var Int32 用途未知!!请到数据库中添加字段注释。  
+    */
+    public $tid;
+
+    /**
+    * @var Int32 学分累计值 default(0) 
+    */
+    public $score;
+
+    /**
+    * @var String 兑换道具  
+    */
+    public $items;
+
+}
+

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

@@ -3,7 +3,7 @@
  // 由CodeGenerator创建。
  // Copyright (C) gwang (wanggangzero@qq.com), Loyalsoft@sjz Inc
  // author: gwang 
- // 日期: 2021-06-22 11:48:06
+ // 日期: 2021-09-26 11:49:18
 ////////////////////
 
 

+ 1 - 1
Gameserver/Amfphp/model/User/Data_UserGame.php

@@ -124,7 +124,7 @@ class Data_UserGame extends HashSaver {
         $this->pvp = new Info_UserPVP();
 //        $this->task->initialize();                                              # 任务初始化
         $this->taskCardShop = new Info_TaskCard_Shop();
-        $this->college->initialize();
+        //$this->college->initialize();//改为按天解锁了
         $this->shenmiao->initialize();
         
     }

+ 157 - 1
Gameserver/Amfphp/model/User/Info_College.php

@@ -53,6 +53,30 @@ class Info_College extends Object_ext{
      * @var type
      */
     public $maskCollege = 0;
+    
+    /**
+     * 
+     * @var type
+     */
+    public $ingTaskCardDic = null;
+
+    /**
+     * 圣哲学院功能结算时间
+     * @var type
+     */
+    public $funUnluckTs = 0;
+    
+    /**
+     * 累计积分
+     * @var type
+     */
+    public $score = 0;
+    
+    /**
+     * 
+     * @var type
+     */
+    public $scoreRewardList = array();
 
     /**
      * 构造函数
@@ -61,6 +85,7 @@ class Info_College extends Object_ext{
     public function __construct($args = null) {    
         if($args == null){
             $this->compMissCardDic = new \stdClass();
+            $this->ingTaskCardDic = new \stdClass();
         } else {
             parent::__construct($args);   
         }                    
@@ -165,6 +190,137 @@ class Info_College extends Object_ext{
             }                               
         }           
     }
-    
+//------------------new---------------------
+    /**
+     * 根据天 初始化
+     * @return type
+     */
+    public function initTaskCard() {
+        if($this->funUnluckTs == 0){
+           return;
+        }
+        
+        $day = TimeUtil::tsDay($this->funUnluckTs);
+        $curDay = TimeUtil::tsDay(time());
+        $num = $curDay - $day;
+               
+        $college = GameConfig::college();
+        $index = 0;
+        foreach ($college as $collegeId => $collegeMo) {
+            $courseArr = explode(',',$collegeMo->cList);            
+            foreach ($courseArr as $courseId) {                
+                if(!StlUtil::dictHasProperty($this->ingTaskCardDic, $courseId)){
+                    $mo= GameConfig::course_getItem($courseId);
+                    $arr = explode(',',$mo->misslist);
+                    $dic = new \stdClass();
+                    foreach ($arr as $cardId) {
+                        $item = new ins_missCourseItem();        
+                        $item->initialize($cardId);         
+                            
+                        $cid = StoreProc::PutTaskCardInStore($cardId);                      // 存入背包
+                        NormalEventProc::OnTaskCard_Actived($cid, null);                        # 带入事件
+                
+                        $item->indexId = $cid;
+                        $taskCard = new Ins_TaskCard(req()->userInfo->game->store->taskcards->$cid);# 任务卡对象
+                        $taskCard->state = Enum_TaskCardStateType::ing;
+                
+                        TaskProc::OnGetSchoolTask();
+                        foreach ($taskCard->curSteps as &$tsp) {                                # 初期里面只有一个任务
+                            $tsp = new Ins_TaskStep($tsp);
+                            if ($tsp->isStatusType()) {                                         # 如果是道具收集类的, 扣除所收集道具
+                                $tsp->autoCalcStatusCur();
+                            }
+                        }
+
+                        if ($taskCard->IsFinish()) {                                            # 检查是否任务卡的所有步骤都已完成
+                            $taskCard->state = Enum_TaskCardStateType::finish;
+                            $item->type = Enum_TaskCardStateType::finish;
+                            TaskProc::OnFinishSchoolTask();
+                            NormalEventProc::OnTaskCard_Finish($taskCard->uid, null);           # 广播卡完成事件
+                        }
+                        $dic->$cardId = $item;
+                        req()->userInfo->game->store->taskcards->$cid = $taskCard;
+                    }              
+                    $this->ingTaskCardDic->$courseId = $dic;                                      
+                }
+              
+                if($index >= $num){
+                    break;
+                }
+                $index += 1;  
+            }
+        } 
+        req()->userInfo->game->college->ingTaskCardDic = $this->ingTaskCardDic;  
+        //$courseDic = GameConfig::course();
+//        $index = 0;
+//        foreach ($courseDic as $courseId => $mo) {
+//            if(!StlUtil::dictHasProperty($this->ingTaskCardDic, $courseId)){
+//                $arr = explode(',',$mo->misslist);
+//                $dic = new \stdClass();
+//                foreach ($arr as $cardId) {
+//                    $item = new ins_missCourseItem();        
+//                    $item->initialize($cardId);         
+//                            
+//                    $cid = StoreProc::PutTaskCardInStore($cardId);                      // 存入背包
+//                    NormalEventProc::OnTaskCard_Actived($cid, null);                        # 带入事件
+//                
+//                    $item->indexId = $cid;
+//                    $taskCard = new Ins_TaskCard(req()->userInfo->game->store->taskcards->$cid);# 任务卡对象
+//                    $taskCard->state = Enum_TaskCardStateType::ing;
+//                
+//                    TaskProc::OnGetSchoolTask();
+//                    foreach ($taskCard->curSteps as &$tsp) {                                # 初期里面只有一个任务
+//                        $tsp = new Ins_TaskStep($tsp);
+//                        if ($tsp->isStatusType()) {                                         # 如果是道具收集类的, 扣除所收集道具
+//                            $tsp->autoCalcStatusCur();
+//                        }
+//                    }
+//
+//                    if ($taskCard->IsFinish()) {                                            # 检查是否任务卡的所有步骤都已完成
+//                        $taskCard->state = Enum_TaskCardStateType::finish;
+//                        $item->type = Enum_TaskCardStateType::finish;
+//                        TaskProc::OnFinishSchoolTask();
+//                        NormalEventProc::OnTaskCard_Finish($taskCard->uid, null);           # 广播卡完成事件
+//                    }
+//                    $dic->$cardId = $item;
+//                    req()->userInfo->game->store->taskcards->$cid = $taskCard;
+//                }              
+//                $this->ingTaskCardDic->$courseId = $dic;                                      
+//            }
+//                
+//            if($index >= $num){
+//                break;
+//            }
+//            $index += 1;
+//        }                 
+    }
+            
+    /**
+     * 圣哲学院功能结算时间
+     */
+    public function setFunUnluckTs() {
+        if($this->funUnluckTs != 0){
+            return;
+        }
+        
+        $this->funUnluckTs = time();     
+        $this->initTaskCard();
+    }
+
+    /**
+     * 记录已经领取奖励的课程
+     * @param type $id
+     */
+//    public function addReceiveCourseList($id) {
+//        $this->comCourseList[] = $id;
+//    }
+
+    /**
+     * 累计积分
+     * @param type $val
+     */
+    public function addScore($val) {
+        $this->score += $val;
+    }
     
 }

+ 2 - 1
Gameserver/Amfphp/model/User/ins_missCourseItem.php

@@ -28,12 +28,13 @@ class ins_missCourseItem extends Object_ext{
      *  任务状态
      */
     public $type =1;
-    
+   
     public function __construct($args=null) {      
         parent::__construct($args);       
     }
     
     public function initialize($missId) {
         $this->missCardId = $missId;
+        $this->type = Enum_TaskCardStateType::ing;
     }
 }

+ 90 - 41
Gameserver/Amfphp/process/CollegeProc.php

@@ -23,20 +23,21 @@ class CollegeProc {
      */
     public static function procMain() {
         switch (req()->cmd) {
-            case CmdCode::cmd_college_ActiveTaskCard:                           # 7301 激活任务卡
+            case CmdCode::cmd_college_ActiveTaskCard://废弃                     # 7301 激活任务卡
                 return CollegeProc::ActiveTaskCard();
             case CmdCode::cmd_college_ReceiveCollegeReward:                     # 7302 领取年级奖励
                 return CollegeProc::ReceiveCollegeReward();
             case CmdCode::cmd_college_ReceiveCourseReward:                      # 7303 领取课程奖励
                 return CollegeProc::ReceiveCourseReward();
-
+            case cmd_college_ScoreExchangeItem:                                 #7304 积分兑换道具
+                return CollegeProc::ScoreExchangeItem();                        
             default:
                 Err(ErrCode::cmd_err);
         }
     }
 
     /**
-     * 7301 激活
+     * 7301 激活---废弃
      */
     public static function ActiveTaskCard() {
         $req = req();
@@ -86,25 +87,35 @@ class CollegeProc {
      */
     public static function ReceiveCollegeReward() {
         $req = req();
+        list($collegeId) = $req->paras;
+        
         $collegeInfo = $req->userInfo->game->college;
-        $dic = GameConfig::college_getItem($collegeInfo->collegeId);
-        $tag = true;
-        $cList = explode(',', $dic->cList);
-        foreach ($cList as $cId) {
-            if (!in_array($cId, $collegeInfo->comCourseList)) {
-                $tag = false;
-            }
-        }
-
-        if (!$tag) {
-            return Resp::err(ErrCode::college_courseNumError);
-        }
-        StoreProc::AddMultiItemInStore(GameConfig::course_getItem($collegeInfo->courseId)->prize);      # 发放奖励
-
-        $college = new Info_College($req->userInfo->game->college);
-        $college->updataCourseNew();
-
-        $req->userInfo->game->college = $college;
+        $mo = GameConfig::college_getItem($collegeId);
+        my_Assert(count($collegeInfo->comCourseList) == count(explode(',', $mo->cList)), ErrCode::college_courseNumError);
+        
+        StoreProc::AddMultiItemInStore($mo->prize);      # 发放奖励
+        
+        $collegeInfo->collegeRewardList[] = $collegeId;
+        
+//        $collegeInfo = $req->userInfo->game->college;
+//        $dic = GameConfig::college_getItem($collegeInfo->collegeId);
+//        $tag = true;
+//        $cList = explode(',', $dic->cList);
+//        foreach ($cList as $cId) {
+//            if (!in_array($cId, $collegeInfo->comCourseList)) {
+//                $tag = false;
+//            }
+//        }
+//
+//        if (!$tag) {
+//            return Resp::err(ErrCode::college_courseNumError);
+//        }
+//        StoreProc::AddMultiItemInStore($dic->prize);      # 发放奖励
+//
+//        $college = new Info_College($req->userInfo->game->college);
+//        $college->updataCourseNew();
+
+        $req->userInfo->game->college = $collegeInfo;
         UserProc::updateUserInfo();
 
         return Resp::ok(array('store' => $req->userInfo->game->store,
@@ -119,28 +130,44 @@ class CollegeProc {
      */
     public static function ReceiveCourseReward() {
         $req = req();
-        //list($taskCardId) = $req->paras;
+        list($courseId) = $req->paras;
+               
         $collegeInfo = $req->userInfo->game->college;
-
-        $tag = true;
-        foreach ($collegeInfo->compMissCardDic as $key => $value) {
-            if ($value->type != Enum_TaskCardStateType::drawed) {
-                $tag = false;
-                break;
-            }
-        }
-
-        if (!$tag) {
-            return Resp::err(ErrCode::college_taskCardNumError);
+        my_Assert(!in_array($courseId, $collegeInfo->comCourseList), ErrCode::college_CourseRewardRepeatReceive);
+
+        $mo = GameConfig::course_getItem($courseId);
+        $list = explode(',', $mo->misslist);
+        
+        my_Assert(StlUtil::dictHasProperty($collegeInfo->ingTaskCardDic, $courseId), ErrCode::college_CourseNotUnlocked);
+               
+        foreach ($list as $id) {
+            my_Assert(StlUtil::dictHasProperty($collegeInfo->ingTaskCardDic->$courseId, $id) && $collegeInfo->ingTaskCardDic->$courseId->$id->type == Enum_TaskCardStateType::drawed, ErrCode::college_TaskCardStateError);           
         }
-
-        StoreProc::AddMultiItemInStore(GameConfig::course_getItem($collegeInfo->courseId)->prize);      # 发放奖励
-        TaskProc::OnFinishAllSchoolTaskOfGrade($collegeInfo->courseId);
-
-        $college = new Info_College($req->userInfo->game->college);
-        $college->updataCourse();
-
-        $req->userInfo->game->college = $college;
+        
+        StoreProc::AddMultiItemInStore($mo->prize);      # 发放奖励
+        TaskProc::OnFinishAllSchoolTaskOfGrade($courseId);
+        
+        $collegeInfo->comCourseList[] = $courseId;
+        
+//        $tag = true;
+//        foreach ($collegeInfo->compMissCardDic as $key => $value) {
+//            if ($value->type != Enum_TaskCardStateType::drawed) {
+//                $tag = false;
+//                break;
+//            }
+//        }
+//
+//        if (!$tag) {
+//            return Resp::err(ErrCode::college_taskCardNumError);
+//        }
+//
+//        StoreProc::AddMultiItemInStore(GameConfig::course_getItem($collegeInfo->courseId)->prize);      # 发放奖励
+//        TaskProc::OnFinishAllSchoolTaskOfGrade($collegeInfo->courseId);
+//
+//        $college = new Info_College($req->userInfo->game->college);
+//        $college->updataCourse();
+
+        $req->userInfo->game->college = $collegeInfo;
         UserProc::updateUserInfo();
 
         return Resp::ok(array('store' => $req->userInfo->game->store,
@@ -151,4 +178,26 @@ class CollegeProc {
         ));
     }
 
+    /**
+     * 7304 积分兑换道具
+     */
+    public static function ScoreExchangeItem() {
+        $req = req();
+        list($id) = $req->paras;
+        
+        $scoreRewardList = $req->userInfo->game->college->scoreRewardList;
+        my_Assert(in_array($id,$scoreRewardList), ErrCode::college_taskScoreRewardRepeatReceive);
+        
+        $score = $req->userInfo->game->college->score;
+        my_Assert($score >= $id, ErrCode::college_taskScoreRewardRepeatReceive);
+        
+        $mo = GameConfig::score_getItem($id);      
+        $req->userInfo->game->college->scoreRewardList[] = $id;
+        StoreProc::AddMultiItemInStore($mo->items);
+        UserProc::updateUserInfo();
+
+        return Resp::ok(array('store' => $req->userInfo->game->store,              
+                    'college' => $req->userInfo->game->college,
+        ));
+    }
 }

+ 6 - 1
Gameserver/Amfphp/process/TaskProc.php

@@ -365,7 +365,6 @@ class TaskProc {
         $store = ctx()->store();                                   # 快速访问store
         my_Assert(StlUtil::dictHasProperty($store->taskcards, $taskCardUID), ErrCode::taskCard_no); # 防御找不到实例
         $taskCard = new Ins_TaskCard($store->taskcards->$taskCardUID);          # 任务卡对象
-//
 
         foreach ($taskCard->curSteps as &$tsp) {                                # 初期里面只有一个任务
             $tsp = new Ins_TaskStep($tsp);
@@ -393,6 +392,12 @@ class TaskProc {
         }
         StlUtil::dictRemove($store->taskcards, $taskCardUID);                   # 移除任务卡
         self::autoRecoverStateMissions();                                       # 重新更新其它状态类的任务卡
+
+        StatisticsProc::SelfTaskDataCollect($taskCard->typeId);                 #统计自己的任务完成情况
+        StatisticsProc::TaskDataCollect($taskCard->typeId);                     #统计最新任务
+        
+        req()->userInfo->game->college->addScore($taskCard->mo()->score);       #圣哲学院的任务是有积分累计的
+        
         UserProc::updateUserInfo();                                             # 回存玩家数据
         return Resp::ok(array(
                     'gold' => req()->userInfo->game->baseInfo->gold,