pvp:添加PVP任务

This commit is contained in:
luying
2021-10-29 16:36:23 +08:00
parent 2cf5895c52
commit 0d0855d312
9 changed files with 120 additions and 9 deletions
+4 -2
View File
@@ -3,7 +3,7 @@
*/
import { getMails } from './mailService';
import { recentGuildMsgs, recentPrivateChatInfos, recentSysMsgs, recentWorldMsgs } from './chatService';
import { getCurTask } from './taskService';
import { getCurTask, getPvpTask } from './taskService';
import { RoleType } from '../db/Role';
import { Application, FrontendOrBackendSession, pinus } from 'pinus';
@@ -128,7 +128,9 @@ async function getModuleData(type: string, data: { role: RoleType, session: Fron
return { receiveBoxs, donateFund, reports, donateCnt: donateCnt || 0, donationLv };
}
case 'task':
return await getCurTask(role.roleId, session);
let tasks = await getCurTask(role.roleId, session);
let pvpTask = await getPvpTask(role.roleId);
return {...tasks, pvpTask}
case 'chat':
const worldMsgs = await recentWorldMsgs(serverId);
const sysMsgs = await recentSysMsgs(serverId);
+16
View File
@@ -246,6 +246,22 @@ export async function getAchievement(roleId: string, userTask: UserTaskType) {
return { point, taskList, box }
}
export async function getPvpTask(roleId: string) {
let type = TASK_FUN_TYPE.PVP;
let recMap = await UserTaskRecModel.findByRoleAndType(roleId, type); // group=>userTaskRec
let taskList: TaskListReturn[] = [];
for (let [id, dic] of gameData.pvpDailyTask) {
let dbRec = recMap.get(dic.taskType)?.get(dic.group);
if (dbRec) {
taskList.push({ type, id, count: dbRec.count, received: dbRec.received.includes(id) });
} else {
taskList.push({ type, id, count: 0, received: false });
}
}
return { taskList }
}
// 刷新每日任务
export async function refDailyTask(roleId: string, sid: string) {
let userTask = await UserTaskModel.findByRole(roleId);