123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145 |
- <?php
- namespace loyalsoft;
- /*
- * 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 CollegeProc
- *
- * @author cyzhao
- */
- class CollegeProc {
- /**
- * 逻辑分发
- * 所有的Proc中必须有这样一个方法
- */
- public static function procMain() {
- switch (req()->cmd) {
- 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();
- default:
- Err(ErrCode::cmd_err);
- }
- }
- /**
- * 7301 激活
- */
- public static function ActiveTaskCard() {
- $req = req();
- list($taskCardId) = $req->paras;
- $collegeInfo = $req->userInfo->game->college;
- $compMissCardDic = $collegeInfo->compMissCardDic;
- if (!StlUtil::dictHasProperty($compMissCardDic, $taskCardId)) {
- return Resp::err(ErrCode::college_notExistTaskCard);
- }
- if ($compMissCardDic->$taskCardId->type > Enum_TaskCardStateType::notopen) {
- return Resp::err(ErrCode::college_TaskCardStateError);
- }
- $cid = StoreProc::PutTaskCardInStore($taskCardId); // 存入背包
- NormalEventProc::OnTaskCard_Actived($cid, null); # 带入事件
- $compMissCardDic->$taskCardId->indexId = $cid;
- $compMissCardDic->$taskCardId->type = Enum_TaskCardStateType::ing;
- $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;
- $compMissCardDic->$taskCardId->type = Enum_TaskCardStateType::finish;
- TaskProc::OnFinishSchoolTask();
- NormalEventProc::OnTaskCard_Finish($taskCard->uid, null); # 广播卡完成事件
- }
- $req->userInfo->game->college->compMissCardDic = $compMissCardDic;
- $req->userInfo->game->store->taskcards->$cid = $taskCard;
- UserProc::updateUserInfo();
- //$compMissCardDic->$taskCardId->type = 2;
- return Resp::ok(array('store' => $req->userInfo->game->store, 'college' => $req->userInfo->game->college)); # 返回值更新背包
- }
- /**
- * 7302 领取一个年级的奖励
- */
- public static function ReceiveCollegeReward() {
- $req = req();
- $collegeInfo = $req->userInfo->game->college;
- $dic = GameConfig::college_getItem($collegeInfo->collegeId);
- $tag = true;
- $cList = explode(',', $newCollegeDic->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;
- UserProc::updateUserInfo();
- return Resp::ok(array('store' => $req->userInfo->game->store, 'college' => $req->userInfo->game->college));
- }
- /**
- * 7303 领取课程奖励
- */
- public static function ReceiveCourseReward() {
- $req = req();
- //list($taskCardId) = $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);
- }
- 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;
- UserProc::updateUserInfo();
- return Resp::ok(array('store' => $req->userInfo->game->store, 'college' => $req->userInfo->game->college));
- }
- }
|