任务:修复任务无法达成bug

This commit is contained in:
luying
2021-04-25 17:18:16 +08:00
parent b5b1919a56
commit 7bb445693d
21 changed files with 79 additions and 52 deletions

View File

@@ -40,7 +40,7 @@ export async function checkTaskWithRole(roleId: string, taskType: number, role:
let today = getTodayZeroPoint();
if (today > role.loginTime) {
if (today - role.loginTime > 24 * 60 * 60) {
pushMessage = await checkTask(roleId, taskType, 0, false, {}, funcs);
pushMessage = await checkTask(roleId, taskType, 1, false, {}, funcs);
} else {
pushMessage = await checkTask(roleId, taskType, 1, true, {}, funcs);
}
@@ -81,7 +81,7 @@ export async function checkTaskWithHero(roleId: string, taskType: number, hero:
pushMessage = await checkTask(roleId, taskType, 1, true, { quality: dicHero.quality, star: hero.star }, funcs);
}
else if (taskType == TASK_TYPE.HERO_LV) {
pushMessage = await checkTask(roleId, taskType, 1, true, { lv: hero.lv }, funcs);
pushMessage = await checkTask(roleId, taskType, 1, true, { lv: hero.lv, oldLv: args[0] }, funcs);
}
else if (taskType == TASK_TYPE.HERO_TRAIN) {
let dicHero = gameData.hero.get(hero.hid);
@@ -283,6 +283,7 @@ export async function checkTaskWithGoods(roleId: string, taskType: number, goods
// 根据taskType判断有哪些任务需要check的
export async function checkTask(roleId: string, taskType: number, count: number, isInc: boolean, param: TaskParam, funcs?: number[]) {
console.log('******checkTask', roleId, taskType, count, isInc, param, funcs)
let tasks = gameData.taskType.get(taskType) || [];
let pushMessage = new Array<TaskListReturn>();
let groups = new Map<string, { task0: DicTask, tasks: DicTask[] }>();
@@ -343,7 +344,7 @@ export async function checkTaskRec(roleId: string, type: number, group: number,
isMatch = taskParam[1] == param.quality && taskParam[2] == param.star;
break;
case TASK_TYPE.HERO_LV:
isMatch = taskParam[1] == param.lv;
isMatch = param.lv >= taskParam[1] && param.oldLv < taskParam[1];
break;
case TASK_TYPE.HERO_TRAIN:
isMatch = taskParam[1] == param.count;
@@ -457,11 +458,7 @@ function checkRecResult(rec: UserTaskRecType, id: number, condition: number) {
if (!rec) return false;
if (rec.received && rec.received.includes(id)) return false; // 已领取,不再推送
if (rec.count >= condition) {
return rec
} else {
return false
}
return rec
}
@@ -561,3 +558,21 @@ export function isComplete(roleId: string, taskType: TASK_TYPE, taskParam: strin
}
return addCount;
}
/**
* 创建账号时临时获得可开启功能主要用于check 主公升级任务
* 该函数不会存储funcs如pvp开启会在entryHandler里面再查一次funcs那时候正式开启
* @param dataFuncs
* @param lv
*/
export async function getCreateUserFuncs(dataFuncs: number[], lv: number) {
let addFuncs: number[] = [];
for(let [id, dicFunSwitch] of gameData.funcsSwitch) {
if (dataFuncs.includes(id)) continue; // 已开启过了
if (dicFunSwitch && lv >= dicFunSwitch.param) {
addFuncs.push(id);
}
}
return addFuncs;
}