每日任务迭代
This commit is contained in:
parent
ed9b26bae7
commit
3b3d8d1c69
@ -25,6 +25,7 @@ class Mission(object):
|
||||
['week_time_end', 0, '每周活动结算时间'],
|
||||
['!mission_list1', [_common.Mission()], '任务列表1'],
|
||||
['!mission_list2', [_common.Mission()], '任务列表2'],
|
||||
['refreshInfo', RefreshInfo(), '刷新任务信息'],
|
||||
]
|
||||
},
|
||||
{
|
||||
@ -133,5 +134,28 @@ class Mission(object):
|
||||
['award', _common.Award(), '奖励信息'],
|
||||
['property_chg', _common.PropertyChg(), '属性变更'],
|
||||
]
|
||||
},{
|
||||
'name': 'refreshMissionList',
|
||||
'desc': '刷新任务',
|
||||
'group': 'Mission',
|
||||
'url': 'webapp/index.php?c=Mission&a=refreshMissionList',
|
||||
'params': [
|
||||
_common.ReqHead(),
|
||||
],
|
||||
'response': [
|
||||
_common.RspHead(),
|
||||
['property_chg', _common.PropertyChg(), '属性变更'],
|
||||
]
|
||||
},
|
||||
]
|
||||
|
||||
|
||||
class RefreshInfo(object):
|
||||
|
||||
def __init__(self):
|
||||
self.fields = [
|
||||
['refreshTimes', 0, '当前刷新次数'],
|
||||
['maxRefreshTimes', 0, '最大刷新次数'],
|
||||
['item_id', 0, '消耗道具id'],
|
||||
['item_num', 0, '消耗道具数量'],
|
||||
]
|
@ -59,6 +59,7 @@ define('TN_DAILY_GET_STAR_NUM', 9016);
|
||||
define('TN_DAILY_BUY_PASS_STATE', 9017);
|
||||
define('TN_DAILY_BUY_LEVEL_STATE', 9018);
|
||||
define('TN_DAILY_RESET_HERO_LEVEL_STATE', 9019);
|
||||
define('TN_DAILY_REFRESH_MISSION_TIMES', 9020);
|
||||
|
||||
define('TN_WEEKLY_BEGIN', 10001);
|
||||
define('TN_WEEKLY_ACTIVE', 10002);
|
||||
|
@ -18,6 +18,7 @@ require_once('services/PropertyChgService.php');
|
||||
require_once('services/SeasonService.php');
|
||||
require_once('services/MissionService.php');
|
||||
require_once('services/FormulaService.php');
|
||||
require_once('services/LogService.php');
|
||||
|
||||
use phpcommon\SqlHelper;
|
||||
use models\User;
|
||||
@ -26,6 +27,7 @@ use models\Mission;
|
||||
use models\Season;
|
||||
use models\Hero;
|
||||
use models\Gun;
|
||||
use services\LogService;
|
||||
|
||||
class MissionController extends BaseAuthedController {
|
||||
|
||||
@ -102,6 +104,22 @@ class MissionController extends BaseAuthedController {
|
||||
//// $specMissionDto['state'] = Mission::RECEIVEABLE_STATE;
|
||||
// $specMissionDto['state'] = 9636;
|
||||
// }
|
||||
|
||||
//刷新任务所需
|
||||
{
|
||||
$refreshTimes = $this->_getDailyV(TN_DAILY_REFRESH_MISSION_TIMES, 0);
|
||||
$maxRefreshTimes = mt\Parameter::getVal('task_refresh_max', 0);
|
||||
$taskCostParam = explode("|",mt\Parameter::getVal('task_refresh_cost', 10));
|
||||
|
||||
$key = min($refreshTimes,count($taskCostParam)-1);
|
||||
|
||||
$refreshInfo = array(
|
||||
"refreshTimes" =>$refreshTimes,
|
||||
"maxRefreshTimes" =>$maxRefreshTimes,
|
||||
"item_id" =>V_ITEM_GOLD,
|
||||
"item_num" =>$taskCostParam[$key],
|
||||
);
|
||||
}
|
||||
$this->_rspData(array(
|
||||
'current_day_active_value' => min($this->_getDailyV(TN_DAILY_ACTIVE, 0), mt\Parameter::getVal('activeness_limit', 0)),
|
||||
'current_week_active_value' => min($this->_getWeeklyV(TN_WEEKLY_ACTIVE, 0), mt\Parameter::getVal('max_weekly', 0)),
|
||||
@ -110,7 +128,8 @@ class MissionController extends BaseAuthedController {
|
||||
'day_time_end' => $this->_getDaySeconds(time())+3600*24,
|
||||
'week_time_end' => $this->_getMondaySeconds() + 7*24*3600,
|
||||
'mission_list1' => $missionDtoList1,
|
||||
'mission_list2' => $missionDtoList2
|
||||
'mission_list2' => $missionDtoList2,
|
||||
'refreshInfo' => $refreshInfo
|
||||
));
|
||||
}
|
||||
|
||||
@ -325,6 +344,7 @@ class MissionController extends BaseAuthedController {
|
||||
$this->propertyChgService);
|
||||
}
|
||||
|
||||
|
||||
private function procSpecMissionCommit($missionDto, $missionMeta)
|
||||
{
|
||||
switch ($missionMeta['type']) {
|
||||
@ -363,4 +383,67 @@ class MissionController extends BaseAuthedController {
|
||||
}
|
||||
}
|
||||
|
||||
public function refreshMissionList()
|
||||
{
|
||||
|
||||
$missionMetaList = mt\Task::getCustomTypeMetaList(0, $this->missionService);
|
||||
$missionHash = Mission::allToHash();
|
||||
$missionDtoList = array();
|
||||
$refreshList = array();
|
||||
$specMissionDto = null;
|
||||
$num =1;
|
||||
foreach ($missionMetaList as $missionMeta) {
|
||||
$num ++;
|
||||
$missionDb = getXVal($missionHash, $missionMeta['id'], null);
|
||||
$missionDto = $this->missionService->getMissionDto(
|
||||
$this->userInfo, $this->seasonDb, $missionDb, $missionMeta);
|
||||
array_push($missionDtoList, $num);
|
||||
if ($missionDto['state'] == Mission::NOT_FINISHED_STATE) {
|
||||
array_push($refreshList, $missionDto['mission_id']);
|
||||
}
|
||||
}
|
||||
// //任务全完成不刷新
|
||||
|
||||
//刷新次数上限不刷新
|
||||
$refreshTimes = $this->_getDailyV(TN_DAILY_REFRESH_MISSION_TIMES, 0);
|
||||
$maxRefreshTimes = mt\Parameter::getVal('task_refresh_max', 0);
|
||||
if ($refreshTimes >= $maxRefreshTimes || count($refreshList) < 1){
|
||||
$this->_rspErr(1, 'Unable to refresh');
|
||||
return;
|
||||
}
|
||||
//消耗不足不刷新
|
||||
$taskCostParam = explode("|",mt\Parameter::getVal('task_refresh_cost', 10));
|
||||
$key = min($refreshTimes,count($taskCostParam)-1);
|
||||
$costNum = $taskCostParam[$key];
|
||||
$costItems = array(
|
||||
array(
|
||||
'item_id' => V_ITEM_GOLD,
|
||||
'item_num' => $costNum
|
||||
),
|
||||
);
|
||||
$lackItem = null;
|
||||
if (!$this->_hasEnoughItems($costItems, $lackItem)) {
|
||||
$this->_rspErr(3, $this->_getLackItemErrMsg($lackItem));
|
||||
return;
|
||||
}
|
||||
foreach ($refreshList as $value){
|
||||
$this->missionService->updateDailyRewardMission($value);
|
||||
}
|
||||
|
||||
$this->_incDailyV(TN_DAILY_REFRESH_MISSION_TIMES, 0,1);
|
||||
$this->_decItems($costItems);
|
||||
{
|
||||
//埋点
|
||||
$event = [
|
||||
'name' => LogService::REFRESH_MISSION,
|
||||
'val' => $costNum
|
||||
];
|
||||
LogService::consumeGold($event);
|
||||
}
|
||||
$this->propertyChgService->addUserChg();
|
||||
$this->_rspData(array(
|
||||
'property_chg' => $this->propertyChgService->toDto(),
|
||||
));
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -18,6 +18,7 @@ class LogService extends BaseService
|
||||
const BUY_BATTLE_PASS = "buy_battle_pass"; //通行证购买
|
||||
const BUY_PASS_EXP = "buy_pass_exp"; //购买通行证经验
|
||||
const BUY_HERO_AVATAR = "buy_hero_avatar"; //购买英雄装饰
|
||||
const REFRESH_MISSION = "refresh_mission"; //刷新每日任务
|
||||
|
||||
const SHOP_BUY_ITEM = "shop_buy_item_normal"; //商城购买物品
|
||||
const SHOP_BUY_ITEM_DAILY = "shop_buy_item_daily"; //商城每日精选购买物品
|
||||
|
@ -1447,4 +1447,41 @@ class MissionService extends BaseService {
|
||||
return round($cegNum,2);
|
||||
}
|
||||
|
||||
public function updateDailyRewardMission($missionId)
|
||||
{
|
||||
|
||||
$metas = mt\Task::getDaildyMission();
|
||||
$selectMeta = null;
|
||||
shuffle($metas);
|
||||
foreach ($metas as $meta) {
|
||||
if (!$this->inDailyRewardMission($meta['id'])) {
|
||||
$selectMeta = $meta;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if ($selectMeta) {
|
||||
foreach ($this->dailyMission['missions'] as $k=>&$mission) {
|
||||
if ($mission['mission_id'] == $missionId) {
|
||||
$mission['mission_id'] = $selectMeta['id'];
|
||||
$mission['createtime'] = myself()->_getNowTime();
|
||||
$mission['modifytime'] = myself()->_getNowTime();
|
||||
$mission['objects'] = array();
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
$this->saveDailyMission();
|
||||
}
|
||||
|
||||
private function inDailyRewardMission($missionId)
|
||||
{
|
||||
foreach ($this->dailyMission['missions'] as $mission) {
|
||||
if ($mission['mission_id'] == $missionId) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user