1
This commit is contained in:
parent
9c462c7bb2
commit
46adde072b
@ -41,22 +41,22 @@ class MissionController extends BaseAuthedController {
|
|||||||
{
|
{
|
||||||
parent::_handlePre();
|
parent::_handlePre();
|
||||||
DynData::preload();
|
DynData::preload();
|
||||||
$this->currRankSeasonMeta = mt\RankSeason::getCurrentSeason();
|
// $this->currRankSeasonMeta = mt\RankSeason::getCurrentSeason();
|
||||||
if (!$this->currRankSeasonMeta) {
|
// if (!$this->currRankSeasonMeta) {
|
||||||
$this->_rspErr(10, 'server internal error');
|
// $this->_rspErr(10, 'server internal error');
|
||||||
die();
|
// die();
|
||||||
}
|
// }
|
||||||
$this->propertyChgService = new services\PropertyChgService();
|
$this->propertyChgService = new services\PropertyChgService();
|
||||||
$this->userInfo = $this->_safeGetOrmUserInfo();
|
$this->userInfo = $this->_safeGetOrmUserInfo();
|
||||||
$this->seasonDb = Season::find($this->currRankSeasonMeta['id']);
|
// $this->seasonDb = Season::find($this->currRankSeasonMeta['id']);
|
||||||
if (!$this->seasonDb) {
|
// if (!$this->seasonDb) {
|
||||||
Season::add($this->currRankSeasonMeta['id']);
|
// Season::add($this->currRankSeasonMeta['id']);
|
||||||
$this->seasonDb = Season::find($this->currRankSeasonMeta['id']);
|
// $this->seasonDb = Season::find($this->currRankSeasonMeta['id']);
|
||||||
}
|
// }
|
||||||
if (!$this->seasonDb) {
|
// if (!$this->seasonDb) {
|
||||||
$this->_rspErr(10, 'server internal error');
|
// $this->_rspErr(10, 'server internal error');
|
||||||
die();
|
// die();
|
||||||
}
|
// }
|
||||||
$this->awardService = new services\AwardService();
|
$this->awardService = new services\AwardService();
|
||||||
$this->missionService = new services\MissionService();
|
$this->missionService = new services\MissionService();
|
||||||
$this->missionService->init($this->userInfo, $this->seasonDb);
|
$this->missionService->init($this->userInfo, $this->seasonDb);
|
||||||
|
@ -56,36 +56,40 @@ class MissionService extends BaseService {
|
|||||||
public function init($userInfo, $seasonDb)
|
public function init($userInfo, $seasonDb)
|
||||||
{
|
{
|
||||||
$this->userInfo = $userInfo;
|
$this->userInfo = $userInfo;
|
||||||
$this->seasonDb = $seasonDb;
|
// $this->seasonDb = $seasonDb;
|
||||||
$this->hisBattleData = Battle::getMyBattleData();
|
$this->hisBattleData = Battle::getMyBattleData();
|
||||||
$seasonBattleData = json_decode($this->seasonDb['battle_data'], true);
|
// $seasonBattleData = json_decode($this->seasonDb['battle_data'], true);
|
||||||
if (!isset($seasonBattleData)) {
|
// if (!isset($seasonBattleData)) {
|
||||||
$seasonBattleData = array();
|
// $seasonBattleData = array();
|
||||||
}
|
// }
|
||||||
$this->seasonBattleData = getXVal($seasonBattleData, 'season_data', array());
|
// $this->seasonBattleData = getXVal($seasonBattleData, 'season_data', array());
|
||||||
$this->thisWeekBattleData = getXVal($seasonBattleData, 'this_week_data', array());
|
// $this->thisWeekBattleData = getXVal($seasonBattleData, 'this_week_data', array());
|
||||||
$this->todayBattleData = getXVal($seasonBattleData, 'today_data', array());
|
// $this->todayBattleData = getXVal($seasonBattleData, 'today_data', array());
|
||||||
if (myself()->_getDaySeconds(getXVal($this->todayBattleData, 'modifytime', 0)) <
|
// if (myself()->_getDaySeconds(getXVal($this->todayBattleData, 'modifytime', 0)) <
|
||||||
myself()->_getNowDaySeconds()) {
|
// myself()->_getNowDaySeconds()) {
|
||||||
$this->todayBattleData = array(
|
// $this->todayBattleData = array(
|
||||||
'createtime' => myself()->_getNowTime(),
|
// 'createtime' => myself()->_getNowTime(),
|
||||||
'modifytime' => myself()->_getNowTime(),
|
// 'modifytime' => myself()->_getNowTime(),
|
||||||
);
|
// );
|
||||||
}
|
// }
|
||||||
if (myself()->_getDaySeconds(getXVal($this->thisWeekBattleData, 'modifytime', 0)) <
|
// if (myself()->_getDaySeconds(getXVal($this->thisWeekBattleData, 'modifytime', 0)) <
|
||||||
myself()->_getMondaySeconds()) {
|
// myself()->_getMondaySeconds()) {
|
||||||
$this->thisWeekBattleData = array(
|
// $this->thisWeekBattleData = array(
|
||||||
'createtime' => myself()->_getNowTime(),
|
// 'createtime' => myself()->_getNowTime(),
|
||||||
'modifytime' => myself()->_getNowTime(),
|
// 'modifytime' => myself()->_getNowTime(),
|
||||||
);
|
// );
|
||||||
}
|
// }
|
||||||
$this->offerRewartdMission = BigData::getData(BigData::OFFER_REWARD_MISSION_TYPE);
|
$this->offerRewartdMission = BigData::getData(BigData::OFFER_REWARD_MISSION_TYPE);
|
||||||
if (!$this->offerRewartdMission) {
|
if (!$this->offerRewartdMission) {
|
||||||
$this->offerRewartdMission = array(
|
$this->offerRewartdMission = array(
|
||||||
'missions' => array()
|
'missions' => array(),
|
||||||
|
'refreshtime' => 0
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
$this->refreshOfferRewardMission();
|
// print_r($this->offerRewartdMission);die;
|
||||||
|
if (myself()->_getDaySeconds(myself()->_getNowTime()) - $this->offerRewartdMission['refreshtime'] >= 86400){
|
||||||
|
$this->refreshOfferRewardMission();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getMissionDto($userInfo, $seasonDb, $missionDb, $missionMeta)
|
public function getMissionDto($userInfo, $seasonDb, $missionDb, $missionMeta)
|
||||||
@ -558,12 +562,31 @@ class MissionService extends BaseService {
|
|||||||
return myself()->_getV($x, $y);
|
return myself()->_getV($x, $y);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private function getMissionsCount(){
|
||||||
|
$num = 0;
|
||||||
|
$missionHash = Mission::allToHash();
|
||||||
|
if (count($this->offerRewartdMission['missions'])){
|
||||||
|
foreach ($this->offerRewartdMission['missions'] as $val){
|
||||||
|
$missionDb = getXVal($missionHash, $val['mission_id'], null);
|
||||||
|
$missionMeta = mt\Task::get($val['mission_id']);
|
||||||
|
$missionDto = $this->getMissionDto($this->userInfo, $this->seasonDb, $missionDb, $missionMeta);
|
||||||
|
if ($missionDto['state'] != 0){
|
||||||
|
$num+=1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return $num;
|
||||||
|
}
|
||||||
|
|
||||||
private function refreshOfferRewardMission()
|
private function refreshOfferRewardMission()
|
||||||
{
|
{
|
||||||
$wantedRefreshMissionNum = mt\Parameter::getVal
|
$wantedRefreshMissionNum = mt\Parameter::getVal
|
||||||
('wanted_refresh_mission_num', 0);
|
('wanted_refresh_mission_num', 0);
|
||||||
|
|
||||||
if ($wantedRefreshMissionNum <=
|
if ($wantedRefreshMissionNum <=
|
||||||
count($this->offerRewartdMission['missions'])) {
|
// count($this->offerRewartdMission['missions'])
|
||||||
|
$this->getMissionsCount()
|
||||||
|
) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
$metas = mt\Task::getOfferRewardMissions
|
$metas = mt\Task::getOfferRewardMissions
|
||||||
@ -573,8 +596,8 @@ class MissionService extends BaseService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
foreach (array_rand($metas, count($metas)) as $key) {
|
foreach (array_rand($metas, count($metas)) as $key) {
|
||||||
$meta = $metas[$key];
|
$meta = $metas[array_rand($metas,1)];
|
||||||
if (count($this->offerRewartdMission['missions']) >=
|
if ($this->getMissionsCount() >=
|
||||||
$wantedRefreshMissionNum) {
|
$wantedRefreshMissionNum) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -593,35 +616,46 @@ class MissionService extends BaseService {
|
|||||||
));
|
));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
$this->offerRewartdMission['refreshtime'] = myself()->_getNowTime();
|
// unset($this->offerRewartdMission['missions']);
|
||||||
|
// print_r($this->offerRewartdMission['missions']);die;
|
||||||
|
$this->offerRewartdMission['refreshtime'] = myself()->_getDaySeconds(myself()->_getNowTime());
|
||||||
$this->saveOfferRewardMission();
|
$this->saveOfferRewardMission();
|
||||||
}
|
}
|
||||||
|
|
||||||
public function updateOfferRewardMission($missionId)
|
public function updateOfferRewardMission($missionId)
|
||||||
{
|
{
|
||||||
$metas = mt\Task::getOfferRewardMissions
|
foreach ($this->offerRewartdMission['missions'] as $k=>&$mission) {
|
||||||
($this->offerRewartdMission['missions']);
|
if ($mission['mission_id'] == $missionId) {
|
||||||
$selectMeta = null;
|
unset($this->offerRewartdMission['missions'][$k]);
|
||||||
shuffle($metas);
|
|
||||||
foreach ($metas as $meta) {
|
|
||||||
if (!$this->inOfferRewardMission($meta['id'])) {
|
|
||||||
$selectMeta = $meta;
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($selectMeta) {
|
print_r(json_encode($this->offerRewartdMission));die;
|
||||||
foreach ($this->offerRewartdMission['missions'] as &$mission) {
|
|
||||||
if ($mission['mission_id'] == $missionId) {
|
// $metas = mt\Task::getOfferRewardMissions
|
||||||
$mission['mission_id'] = $selectMeta['id'];
|
// ($this->offerRewartdMission['missions']);
|
||||||
$mission['createtime'] = myself()->_getNowTime();
|
// $selectMeta = null;
|
||||||
$mission['modifytime'] = myself()->_getNowTime();
|
// shuffle($metas);
|
||||||
$mission['sendtime'] = 0;
|
// foreach ($metas as $meta) {
|
||||||
$mission['objects'] = array();
|
// if (!$this->inOfferRewardMission($meta['id'])) {
|
||||||
break;
|
// $selectMeta = $meta;
|
||||||
}
|
// break;
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
|
// if ($selectMeta) {
|
||||||
|
// foreach ($this->offerRewartdMission['missions'] as $k=>&$mission) {
|
||||||
|
// if ($mission['mission_id'] == $missionId) {
|
||||||
|
// $mission['mission_id'] = $selectMeta['id'];
|
||||||
|
// $mission['createtime'] = myself()->_getNowTime();
|
||||||
|
// $mission['modifytime'] = myself()->_getNowTime();
|
||||||
|
// $mission['sendtime'] = 0;
|
||||||
|
// $mission['objects'] = array();
|
||||||
|
// break;
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function &getOfferRewardMissions()
|
public function &getOfferRewardMissions()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user