1
This commit is contained in:
parent
d60494418f
commit
ce1f4b3fe1
@ -17,6 +17,8 @@ class Mission(object):
|
||||
],
|
||||
'response': [
|
||||
_common.RspHead(),
|
||||
['current_active_value', 0, '当前活跃度'],
|
||||
['max_active_value', 0, '活跃度上限'],
|
||||
['!mission_list1', [_common.Mission()], '任务列表1'],
|
||||
['!mission_list2', [_common.Mission()], '任务列表2'],
|
||||
]
|
||||
|
@ -7,6 +7,7 @@ require_once('mt/Item.php');
|
||||
require_once('mt/Parameter.php');
|
||||
require_once('mt/Drop.php');
|
||||
require_once('mt/Task.php');
|
||||
require_once('mt/Season.php');
|
||||
|
||||
require_once('models/User.php');
|
||||
require_once('models/DynData.php');
|
||||
@ -16,9 +17,11 @@ require_once('models/HeroSkin.php');
|
||||
require_once('models/GunSkin.php');
|
||||
require_once('models/ShopBuyRecord.php');
|
||||
require_once('models/Mission.php');
|
||||
require_once('models/Season.php');
|
||||
|
||||
require_once('services/AwardService.php');
|
||||
require_once('services/PropertyChgService.php');
|
||||
require_once('services/SeasonService.php');
|
||||
|
||||
use phpcommon\SqlHelper;
|
||||
use models\User;
|
||||
@ -29,18 +32,52 @@ use models\HeroSkin;
|
||||
use models\GunSkin;
|
||||
use models\ShopBuyRecord;
|
||||
use models\Mission;
|
||||
use models\Season;
|
||||
|
||||
class MissionController extends BaseAuthedController {
|
||||
|
||||
private $propertyChgService = null;
|
||||
private $userInfo = null;
|
||||
private $seasonService = null;
|
||||
private $currSeasonMeta = null;
|
||||
private $seasonDb = null;
|
||||
|
||||
public function _handlePre()
|
||||
{
|
||||
parent::_handlePre();
|
||||
DynData::preload();
|
||||
$this->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()
|
||||
{
|
||||
DynData::preload();
|
||||
$missionMetaList = array();
|
||||
$type = getReqVal('type', 0);
|
||||
$missionMetaList = mt\Task::getCustomTypeMetaList($type);
|
||||
$missionHash = Mission::allToHash();
|
||||
$missionDtoList = array();
|
||||
foreach ($missionMetaList as $missionMeta) {
|
||||
$missionDb = getXVal($missionHash, $missionId, null);
|
||||
$missionDto = $this->getMissionDto($missionDb, $missionMeta);
|
||||
$missionDb = getXVal($missionHash, $missionMeta['id'], null);
|
||||
$missionDto = $this->getMissionDto($this->userInfo, $this->seasonDb, $missionDb, $missionMeta);
|
||||
array_push($missionDtoList, $missionDto);
|
||||
}
|
||||
$this->_rspData(array(
|
||||
@ -57,7 +94,7 @@ class MissionController extends BaseAuthedController {
|
||||
return;
|
||||
}
|
||||
$missionDb = Mission::find($missionId);
|
||||
$missionDto = $this->getMissionDto($missionDb, $missionMeta);
|
||||
$missionDto = $this->getMissionDto($this->userInfo, $this->seasonDb, $missionDb, $missionMeta);
|
||||
if (!$missionDto) {
|
||||
$this->_rspErr(10, '服务器内部错误');
|
||||
return;
|
||||
@ -499,10 +536,10 @@ class MissionController extends BaseAuthedController {
|
||||
case mt\Task::CONSUME_GOLD_COND:
|
||||
{
|
||||
//消耗X个金币
|
||||
/*if ($userInfo['consume_gold'] >= $missionDto['target']) {
|
||||
if ($userInfo['consume_gold'] >= $missionDto['target']) {
|
||||
$missionDto['current'] = $missionDto['target'];
|
||||
$missionDto['state'] = Mission::RECEIVEABLE_STATE;
|
||||
}*/
|
||||
}
|
||||
}
|
||||
break;
|
||||
case mt\Task::BATTLE_RANK_COND:
|
||||
|
@ -9,7 +9,7 @@ class DynData extends BaseModel {
|
||||
|
||||
public static function preload()
|
||||
{
|
||||
if (!self::$dynData) {
|
||||
if (is_null(self::$dynData)) {
|
||||
self::$dynData = array();
|
||||
$rows = SqlHelper::ormSelect(
|
||||
myself()->_getSelfMysql(),
|
||||
@ -32,7 +32,7 @@ class DynData extends BaseModel {
|
||||
return getXVal(self::$dynData, $key, $defVal);
|
||||
} else {
|
||||
++self::$hitCount;
|
||||
if (self::$hitCount > 5) {
|
||||
if (self::$hitCount > 5 && is_null(self::$dynData)) {
|
||||
self::preload();
|
||||
return self::getV($x, $y, $defVal);
|
||||
} else {
|
||||
|
@ -52,7 +52,7 @@ class Task {
|
||||
const ACHIEVEMENT_MISSON_TYPE = 2;
|
||||
const ACTIVITY_MISSON_TYPE = 3;
|
||||
const RANK_MISSON_TYPE = 4;
|
||||
const SEASONCARD_MISSON_TYPE = 4;
|
||||
const SEASONCARD_MISSON_TYPE = 5;
|
||||
|
||||
const SEASON_WEAKLY_MISSON_SUBTYPE = 1;
|
||||
const SEASON_CHALLENGE_MISSON_SUBTYPE = 2;
|
||||
@ -60,11 +60,43 @@ class Task {
|
||||
|
||||
const SEASON_MISSON_FLAG = 1;
|
||||
|
||||
const DAILY_MISSION_CUSTOM_TYPE = 1;
|
||||
const SEASON_WEEKLY_MISSION_CUSTOM_TYPE = 2;
|
||||
|
||||
public static function get($id)
|
||||
{
|
||||
return getXVal(self::getMetaList(), $id);
|
||||
}
|
||||
|
||||
public static function getCustomTypeMetaList($type)
|
||||
{
|
||||
$metaList = array();
|
||||
foreach (self::getMetaList() as $meta) {
|
||||
switch ($type) {
|
||||
case self::DAILY_MISSION_CUSTOM_TYPE:
|
||||
{
|
||||
if ($meta['type'] == self::DAILY_MISSON_TYPE) {
|
||||
array_push($metaList, $meta);
|
||||
}
|
||||
}
|
||||
break;
|
||||
case self::SEASON_WEEKLY_MISSION_CUSTOM_TYPE:
|
||||
{
|
||||
if ($meta['type'] == self::SEASONCARD_MISSON_TYPE &&
|
||||
$meta['subtype'] == self::SEASON_WEAKLY_MISSON_SUBTYPE) {
|
||||
array_push($metaList, $meta);
|
||||
}
|
||||
}
|
||||
break;
|
||||
default:
|
||||
{
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
return $metaList;
|
||||
}
|
||||
|
||||
protected static function getMetaList()
|
||||
{
|
||||
if (!self::$metaList) {
|
||||
|
11
webapp/services/Mission.php
Normal file
11
webapp/services/Mission.php
Normal file
@ -0,0 +1,11 @@
|
||||
<?php
|
||||
|
||||
namespace services;
|
||||
|
||||
use phpcommon\SqlHelper;
|
||||
use mt;
|
||||
use models\User;
|
||||
|
||||
class MissionService extends BaseService {
|
||||
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user