1
This commit is contained in:
parent
b0e722bf6b
commit
224bdcbabe
@ -448,6 +448,7 @@ class Mission(object):
|
||||
def __init__(self):
|
||||
self.fields = [
|
||||
['mission_id', 0, '任务id'],
|
||||
['last_game', 0, '上局游戏完成的进度 -1:不用在战斗结束展示'],
|
||||
['current', 0, '任务进度-当前'],
|
||||
['target', 0, '任务进度-目标'],
|
||||
['state', 0, '任务状态 0:任务已完成-可领取奖励 1:可接任务(send) 2:任务进行中-未完成(不可领取)'],
|
||||
|
@ -52,6 +52,7 @@ class MissionService extends BaseService {
|
||||
private $seasonBattleData = array();
|
||||
private $thisWeekBattleData = array();
|
||||
private $todayBattleData = array();
|
||||
private $lastGameBattleData = array();
|
||||
private $offerRewartdMission = array();
|
||||
private $dailyMission = array();
|
||||
|
||||
@ -75,6 +76,7 @@ class MissionService extends BaseService {
|
||||
}
|
||||
}
|
||||
$this->hisBattleData = Battle::getMyBattleData();
|
||||
$this->lastGameBattleData = getXVal($this->hisBattleData, 'last_game_data', array());
|
||||
$this->todayBattleData = getXVal($this->hisBattleData, 'today_data', array());
|
||||
if (myself()->_getDaySeconds(getXVal($this->todayBattleData, 'modifytime', 0)) <
|
||||
myself()->_getNowDaySeconds()) {
|
||||
@ -108,10 +110,21 @@ class MissionService extends BaseService {
|
||||
}
|
||||
}
|
||||
|
||||
private function celRealityDto($total,$target,$current){
|
||||
if ($total > $target){
|
||||
$current = $current - ($total - $target);
|
||||
if ($current < 0){
|
||||
$current = 0;
|
||||
}
|
||||
}
|
||||
return $current;
|
||||
}
|
||||
|
||||
public function getMissionDto($userInfo, $seasonDb, $missionDb, $missionMeta)
|
||||
{
|
||||
$missionDto = array(
|
||||
'mission_id' => $missionMeta['id'],
|
||||
'last_game' => -1,
|
||||
'current' => 0,
|
||||
'target' => getXVal($missionMeta, 'target', 1),
|
||||
'state' => Mission::NOT_FINISHED_STATE,
|
||||
@ -159,6 +172,70 @@ class MissionService extends BaseService {
|
||||
}
|
||||
}
|
||||
$handled = true;
|
||||
|
||||
//统计上一场战斗的数据
|
||||
if ($missionMeta['display']){
|
||||
$missionDto['last_game'] = 0;
|
||||
switch ($missionMeta['condition']) {
|
||||
case mt\Task::DAILY_LOGIN_TIMES_COND:
|
||||
{
|
||||
//进行X场比赛
|
||||
$total = $this->getBattleData($missionDb, $missionMeta, 'total_battle_times');
|
||||
$current = $this->getLastGameData('total_battle_times');
|
||||
$missionDto['last_game'] = $this->celRealityDto($total,$missionMeta['target'],$current) ;
|
||||
}
|
||||
break;
|
||||
case mt\Task::TEAM_BATTLE_RANK_COND:
|
||||
{
|
||||
//组队比赛排名前X次数
|
||||
$total = $this->getBattleData($missionDb, $missionMeta, 'total_team_top_X_battle_times');
|
||||
$current = $this->getLastGameData('total_team_top_X_battle_times');
|
||||
$missionDto['last_game'] = $this->celRealityDto($total,$missionMeta['target'],$current) ;
|
||||
}
|
||||
break;
|
||||
case mt\Task::TOTAL_KILL_NUM_COND:
|
||||
{
|
||||
//累计击败X个敌人
|
||||
$total = $this->getBattleData($missionDb, $missionMeta, 'total_kills_times');
|
||||
$current = $this->getLastGameData('total_kills_times');
|
||||
$missionDto['last_game'] = $this->celRealityDto($total,$missionMeta['target'],$current) ;
|
||||
}
|
||||
break;
|
||||
case mt\Task::TOTAL_DAMGE_OUT_COND:
|
||||
{
|
||||
//累计造成X点伤害
|
||||
$total = $this->getBattleData($missionDb, $missionMeta, 'total_damage_out');
|
||||
$current = $this->getLastGameData('total_damage_out');
|
||||
$missionDto['last_game'] = $this->celRealityDto($total,$missionMeta['target'],$current) ;
|
||||
}
|
||||
break;
|
||||
case mt\Task::RESCUE_TEAMMATE_TIMES_COND:
|
||||
{
|
||||
//救援X个队友
|
||||
$total = $this->getBattleData($missionDb, $missionMeta, 'rescue_teammate_times');
|
||||
$current = $this->getLastGameData('rescue_teammate_times');
|
||||
$missionDto['last_game'] = $this->celRealityDto($total,$missionMeta['target'],$current) ;
|
||||
}
|
||||
break;
|
||||
case mt\Task::TOTAL_SURVIVAL_TIME_COND:
|
||||
{
|
||||
//累计生存X分钟
|
||||
$total = $this->getBattleData($missionDb, $missionMeta, 'total_alive_time');
|
||||
$current = $this->getLastGameData('total_alive_time');
|
||||
$missionDto['last_game'] = $this->celRealityDto($total,$missionMeta['target'],$current) ;
|
||||
}
|
||||
break;
|
||||
case mt\Task::TOTAL_USE_SKILL_TIMES_COND:
|
||||
{
|
||||
//累计使用X次角色技能
|
||||
$total = $this->getBattleData($missionDb, $missionMeta, 'use_skill_times');
|
||||
$current = $this->getLastGameData('use_skill_times');
|
||||
$missionDto['last_game'] = $this->celRealityDto($total,$missionMeta['target'],$current) ;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
switch ($missionMeta['condition']) {
|
||||
case mt\Task::DAILY_LOGIN_TIMES_COND:
|
||||
{
|
||||
@ -476,6 +553,15 @@ class MissionService extends BaseService {
|
||||
return $missionDto;
|
||||
}
|
||||
|
||||
private function getLastGameData($key){
|
||||
$battleData = $this->lastGameBattleData;
|
||||
$val = getXVal($battleData, $key, 0);
|
||||
if ($key == 'total_alive_time'){
|
||||
$val = floor($val/1000/60);
|
||||
}
|
||||
return $val;
|
||||
}
|
||||
|
||||
private function getBattleData($missionDb, $missionMeta, $key)
|
||||
{
|
||||
//今天
|
||||
|
@ -399,6 +399,12 @@ class TameBattleDataService extends BaseService {
|
||||
'modifytime' => myself()->_getNowTime()
|
||||
);
|
||||
}
|
||||
//上局游戏数据
|
||||
$hisBattleData['last_game_data'] = array(
|
||||
'createtime' => myself()->_getNowTime(),
|
||||
'modifytime' => myself()->_getNowTime()
|
||||
);
|
||||
|
||||
|
||||
if (myself()->_getDaySeconds($hisBattleData['today_data']['modifytime']) <
|
||||
myself()->_getNowDaySeconds()) {
|
||||
@ -414,6 +420,7 @@ class TameBattleDataService extends BaseService {
|
||||
'modifytime' => myself()->_getNowTime()
|
||||
);
|
||||
}
|
||||
$this->apply($hisBattleData['last_game_data']);
|
||||
$this->apply($hisBattleData['today_data']);
|
||||
$this->apply($hisBattleData['this_week_data']);
|
||||
$oldDataKills = getXVal($hisBattleData['data'], 'total_kills_times', 0);
|
||||
@ -924,8 +931,8 @@ class TameBattleDataService extends BaseService {
|
||||
$this->minValue($battleData, 'team_battle_rank', getXVal($this->allInfo,'pvp_team_rank', 0));
|
||||
//组队模式战斗次数
|
||||
$this->incValue($battleData, 'total_team_battle_times', 1);
|
||||
//组队模式前30名次数
|
||||
if (getXVal($this->battleInfo,'pvp_personal_rank', 0) <= 30){
|
||||
//组队模式前15名次数
|
||||
if (getXVal($this->battleInfo,'pvp_personal_rank', 0) <= 15){
|
||||
$this->incValue($battleData, 'total_team_top_X_battle_times', 1);
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user