任务:修复每日任务未正确开启bug

This commit is contained in:
luying
2021-04-21 16:12:19 +08:00
parent 6f65ff880f
commit 7540aa5150
4 changed files with 80 additions and 24 deletions

View File

@@ -205,4 +205,57 @@ export class ShopHandler {
let curTask = await getCurTask(roleId, session);;
return resResult(STATUS.SUCCESS, curTask);
}
async debugCompleteMainStage(msg: { }, session: BackendSession) {
let roleId = session.get('roleId');
let sid = session.get('sid');
// 检查
let userTask = await UserTaskModel.findByRole(roleId);
let stage = userTask.mainTaskStage;
let dicMainStage = gameData.mainTaskStage.get(stage);
if(!dicMainStage) return resResult(STATUS.DIC_DATA_NOT_FOUND);
let recs = await UserTaskRecModel.getReceiveRec(roleId, TASK_FUN_TYPE.MAIN);
for(let id of dicMainStage.mainTaskId) {
let dicTask = gameData.tasks.get(TASK_FUN_TYPE.MAIN)?.get(id);
if(!dicTask) continue;
let curRecs = recs.find(cur => cur.received.includes(id));
if(!curRecs) {
await UserTaskRecModel.setTaskRec(roleId, TASK_FUN_TYPE.MAIN, dicTask.taskType, dicTask.group, dicTask.condition);
};
}
let mainTask = await getMainTask(roleId, userTask);
return resResult(STATUS.SUCCESS, { mainTask });
}
async debugIncPoint(msg: { type: number, point: number }, session: BackendSession) {
let roleId = session.get('roleId');
let sid = session.get('sid');
let { type, point: incPoint } = msg;
// 每日、成就增加积分
let point = 0, weeklyPoint = 0;
if(type == TASK_FUN_TYPE.DAILY) { // 增加积分
let userTask = await UserTaskModel.findByRole(roleId);
let curWeek = getCurWeekDate(1, 5);
if(curWeek > userTask.dailyTaskRefWeekly) {
userTask = await UserTaskModel.resetDailyScore(roleId, incPoint, curWeek);
} else {
userTask = await UserTaskModel.incInfo(roleId, { dailyTaskPoint: incPoint, dailyTaskPointWeekly: incPoint });
}
point = userTask.dailyTaskPoint;
weeklyPoint = userTask.dailyTaskPointWeekly;
} else if (type == TASK_FUN_TYPE.ACHIEVEMENT) {
let userTask = await UserTaskModel.incInfo(roleId, { achievementPoint: incPoint });
point = userTask.achievementPoint;
}
return resResult(STATUS.SUCCESS, {
type, point, weeklyPoint
});
}
}

View File

@@ -17,7 +17,7 @@ export async function switchOnFunc(roleId: string, type: number, param: number,
await eventOnPlayerLvUp(roleId, param, addFuncs, dataFuncs);
break;
case FUNC_OPT_TYPE.BATTLE_END://战斗结束,触发事件
//开启奇遇
// 暂无
break;
}
if (addFuncs.length) {

View File

@@ -1,6 +1,6 @@
import { checkPvp, findPvpDefByRoleId } from '../services/pvpService'
import { getFuncsSwitch } from '../pubUtils/data';
import { getFuncsSwitch, gameData } from '../pubUtils/data';
import { FUNCS_ID, FUNC_OPT_TYPE } from '../consts/constModules/sysConst';
import { RoleModel } from '../db/Role';
/**
@@ -12,21 +12,20 @@ import { RoleModel } from '../db/Role';
*/
export async function eventOnPlayerLvUp(roleId: string, lv: number, addFuncs: Array<number>, dataFuncs: Array<number>) {
if (!dataFuncs.includes(FUNCS_ID.PVP)) {//开启pvp
let res = getFuncsSwitch(FUNCS_ID.PVP);
if (!res || lv >= res.param) {
let role = await RoleModel.findByRoleId(roleId, null, true);
await checkPvp(role);
addFuncs.push(FUNCS_ID.PVP);
}
}
if (!dataFuncs.includes(FUNCS_ID.EVENT)) {//开启奇遇
let res = getFuncsSwitch(FUNCS_ID.EVENT);
if (res && lv >= res.param) {
addFuncs.push(FUNCS_ID.EVENT);
}
for(let [id, dicFunSwitch] of gameData.funcsSwitch) {
if(dicFunSwitch.conditionType != FUNC_OPT_TYPE.LEVEL_UP) continue;
if (dataFuncs.includes(id)) continue; // 已开启过了
if (dicFunSwitch && lv >= dicFunSwitch.param) {
addFuncs.push(id);
if(id == FUNCS_ID.PVP) {
let role = await RoleModel.findByRoleId(roleId, null, true);
await checkPvp(role);
}
}
}
}
export async function loginRefresh(roleId: string) {

View File

@@ -310,20 +310,24 @@ export async function checkTaskWithGoods(roleId: string, taskType: number, goods
export async function checkTask(roleId: string, taskType: number, count: number, isInc: boolean, param: TaskParam, funcs?: number[]) {
let tasks = gameData.taskType.get(taskType)||[];
let pushMessage = new Array<TaskListReturn>();
let groups = new Map<number, { task0: DicTask, tasks: DicTask[] }>();
let groups = new Map<string, { task0: DicTask, tasks: DicTask[] }>();
for(let dicTask of tasks) {
if(!groups.has(dicTask.group)) {
groups.set(dicTask.group, { task0: dicTask, tasks: new Array<DicTask>() });
if(!groups.has(`${dicTask.type}_${dicTask.group}`)) {
groups.set(`${dicTask.type}_${dicTask.group}`, { task0: dicTask, tasks: new Array<DicTask>() });
}
groups.get(dicTask.group).tasks.push(dicTask);
groups.get(`${dicTask.type}_${dicTask.group}`).tasks.push(dicTask);
}
if(!funcs) {
let role = await RoleModel.findByRoleId(roleId, 'funcs');
funcs = role.funcs||[];
}
for(let [ group, { task0, tasks } ] of groups) {
let rec = await checkTaskRec(roleId, group, task0, count, isInc, param, funcs);
for(let [ typeAndGroup, { task0, tasks } ] of groups) {
let arr = typeAndGroup.split('_');
let type = parseInt(arr[0]);
let group = parseInt(arr[1]);
let rec = await checkTaskRec(roleId, type, group, task0, count, isInc, param, funcs);
if(rec) {
for(let dicTask of tasks) {
if(checkRecResult(rec, dicTask.id, dicTask.condition)) {
@@ -337,8 +341,8 @@ export async function checkTask(roleId: string, taskType: number, count: number,
}
// 检查各项任务是否达成,达成了就保存到数据库
export async function checkTaskRec(roleId: string, group: number, dicTask: DicTask, count: number, isInc: boolean, param: TaskParam, funcs: number[] ) {
let { type, taskParam, taskType } = dicTask;
export async function checkTaskRec(roleId: string, type: number, group: number, dicTask: DicTask, count: number, isInc: boolean, param: TaskParam, funcs: number[] ) {
let { taskParam, taskType } = dicTask;
let sp = [TASK_TYPE.LOGIN_SUM, TASK_TYPE.LOGIN_SERIES];
if(type == TASK_FUN_TYPE.DAILY && funcs.indexOf(FUNCS_ID.DAILY_TASK) == -1 && sp.indexOf(taskType) == -1) { // 功能未开启