currSeasonMeta = mt\Season::getCurrentSeason(); if (!$this->currSeasonMeta) { $this->_rspErr(10, '服务器内部错误'); die(); } $this->propertyChgService = new services\PropertyChgService(); $this->userInfo = $this->_safeGetOrmUserInfo(); $this->seasonService = new services\SeasonService(); if (!$this->seasonService->checkSeason($this->userInfo)) { $this->userInfo = $this->_safeGetOrmUserInfo(); $this->propertyChgService->addUserChg(); } $this->seasonDb = Season::find($this->currSeasonMeta['id']); if (!$this->seasonDb) { Season::add($this->currSeasonMeta['id']); $this->seasonDb = Season::find($this->currSeasonMeta['id']); } if (!$this->seasonDb) { $this->_rspErr(10, '服务器内部错误'); die(); } } public function missionList() { $type = getReqVal('type', 0); $missionMetaList = mt\Task::getCustomTypeMetaList($type); $missionHash = Mission::allToHash(); $missionDtoList = array(); foreach ($missionMetaList as $missionMeta) { $missionDb = getXVal($missionHash, $missionMeta['id'], null); $missionDto = $this->getMissionDto($this->userInfo, $this->seasonDb, $missionDb, $missionMeta); array_push($missionDtoList, $missionDto); } $this->_rspData(array( 'mission_list' => $missionDtoList )); } public function commitMission() { $missionId = getReqVal('mission_id', 0); $missionMeta = mt\Task::get($missionId); if (!$missionMeta) { $this->_rspErr(1, 'mission_id参数错误'); return; } $missionDb = Mission::find($missionId); $missionDto = $this->getMissionDto($this->userInfo, $this->seasonDb, $missionDb, $missionMeta); if (!$missionDto) { $this->_rspErr(10, '服务器内部错误'); return; } if ($missionDto[state] == Mission::RECEIVED_STATE) { $this->_rspErr(2, '不能重复领取'); return; } if ($missionDto[state] == Mission::NOT_FINISHED_STATE) { $this->_rspErr(3, '任务目标未达成'); return; } if ($missionDto[state] != Mission::RECEIVEABLE_STATE) { $this->_rspErr(3, '未知任务状态'); return; } $dropMeta = mt\Drop::get($missionMeta['reward']); if (!$dropMeta) { $this->_rspErr(10, '服务器内部错误drop错误'); return; } $propertyChgService = new services\PropertyChgService(); $awardService = new services\AwardService(); $this->_scatterDrop($dropMeta, $awardService, $propertyChgService); Mission::add($missionId); $missionDb = Mission::find($missionId); $missionDto = $this->getMissionDto($missionDb, $missionMeta); $this->_rspData(array( 'award' => $awardService->toDto(), 'property_chg' => $propertyChgService->toDto(), 'mission_chg' => $missionDto )); } public function commitAll() { } }