pvp:添加PVP任务

This commit is contained in:
luying
2021-10-29 12:03:16 +08:00
parent 2cf5895c52
commit 0d0855d312
9 changed files with 120 additions and 9 deletions

View File

@@ -7,7 +7,7 @@ import { addItems } from "../../../services/rewardService";
import { UserTaskModel } from "../../../db/UserTask";
import { nowSeconds, getZeroPointD } from "../../../pubUtils/timeUtil";
import { DicDailyTask, DicAchievement, DicMainTask } from "../../../pubUtils/dictionary/DicTask";
import { getMainTask, refDailyTaskBox, removeHistoryTask, getCurTask, checkTask } from "../../../services/taskService";
import { getMainTask, refDailyTaskBox, removeHistoryTask, getCurTask, checkTask, getPvpTask } from "../../../services/taskService";
import { TASK } from "../../../pubUtils/dicParam";
import { newHeroGiftPoint } from "../../../services/activity/newHeroGiftsService";
import { ActivityTaskPointModel, ActivityTaskPointModelType } from "../../../db/ActivityTaskPoint";
@@ -31,6 +31,13 @@ export class ShopHandler {
return resResult(STATUS.SUCCESS, res);
}
public async getPvpTaskList(msg: {}, session: BackendSession) {
const roleId: string = session.get('roleId');
const res = await getPvpTask(roleId);
return resResult(STATUS.SUCCESS, res);
}
// 领取主线任务、每日任务、成就单条任务
async receiveTask(msg: { type: number, id: number }, session: BackendSession) {
const roleId: string = session.get('roleId');

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);

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);

View File

@@ -473,6 +473,7 @@ export const FILENAME = {
DIC_AUCTION_BASIC_POOL: 'dic_zyz_auction_basicPool',
DIC_AUCTION_REWARD: 'dic_zyz_auctionReward',
DIC_PVP_DIFFICULTRATIO: 'dic_zyz_pvp_difficultRatio',
DIC_PVP_DAILY_TASK: 'dic_zyz_pvp_dailyTask',
}
export const WAR_RELATE_TABLES = [
@@ -562,6 +563,7 @@ export enum TASK_FUN_TYPE {
MAIN = 1, // 主线
DAILY = 2, // 每日
ACHIEVEMENT = 3, // 成就
PVP = 4, // pvp任务
}
export enum TASK_TYPE {

View File

@@ -108,7 +108,7 @@ export default class PvpDefense extends BaseModel {
const result: PvpDefenseType = await PvpDefenseModel.findOne({ roleId })
.populate('role', 'head frame spine topLineupCe roleId roleName lv globalCeAttr')
.populate('heroes.hero')
.populate('oppPlayers.oppDef', 'oppRoleId pos roleName head frame spine heads frames spines rankLv title lv pLv defCe heroes').lean({ getters: true, virtuals: true });
.populate('oppPlayers.oppDef', 'oppRoleId pos roleName head frame spine heads frames spines rankLv title lv pLv defCe heroes warId buff').lean({ getters: true, virtuals: true });
return result;
}
@@ -116,7 +116,7 @@ export default class PvpDefense extends BaseModel {
const result: PvpDefenseType[] = await PvpDefenseModel.find({ seasonNum, 'defense.pLv': { $gte: min, $lte: max } })
.populate('role', '_id head frame spine heads frames spines topLineupCe roleId roleName lv globalCeAttr')
.populate('heroes.hero')
.populate('oppPlayers.oppDef', 'oppRoleId pos roleName head frame spine heads frames spines rankLv pLv title lv defCe heroes')
.populate('oppPlayers.oppDef', 'oppRoleId pos roleName head frame spine heads frames spines rankLv pLv title lv defCe heroes warId buff')
.lean({ getters: true, virtuals: true });
return result;
}
@@ -125,7 +125,7 @@ export default class PvpDefense extends BaseModel {
delete update._id;
let result: PvpDefenseType = await PvpDefenseModel.findOneAndUpdate({roleId}, {$set:update}, {new: true})
.populate('role', 'head frame spine heads frames spines topLineupCe roleId roleName lv')
.populate('oppPlayers.oppDef', 'oppRoleId pos roleName head frame spine heads frames spines rankLv pLv title lv defCe heroes').lean({ getters: true, virtuals: true });
.populate('oppPlayers.oppDef', 'oppRoleId pos roleName head frame spine heads frames spines rankLv pLv title lv defCe heroes warId buff').lean({ getters: true, virtuals: true });
return result;
}
public static async updateInfo(roleId: string, update: pvpUpdateInter, lean = true) {

View File

@@ -36,7 +36,7 @@ export default class UserTaskRec extends BaseModel {
private static getRefreshCondition(type: number) {
let today = getZeroPointD();
if(type == TASK_FUN_TYPE.DAILY) {
if(type == TASK_FUN_TYPE.DAILY || type == TASK_FUN_TYPE.PVP) {
return { type, createdAt: { $gte: today } };
} else {
return { type };

View File

@@ -73,7 +73,7 @@ import { dicShop, dicShopItem, loadShop } from "./dictionary/DicShop";
import { dicShopList, loadShopList } from "./dictionary/DicShopList";
import { dicRank, loadRank } from "./dictionary/DicRank";
import { dicRankReward, loadRankReward } from "./dictionary/DicRankReward";
import { dicTaskType, taskMap, dicMainTask, dicDailyTask, dicAchievement, loadTask } from "./dictionary/DicTask";
import { dicTaskType, taskMap, dicMainTask, dicDailyTask, dicAchievement, loadTask, dicPvpDailyTask } from "./dictionary/DicTask";
import { dicMainTaskStage, loadMainTaskStage } from "./dictionary/DicMainTaskStage";
import { dicTaskBox, loadTaskBox } from './dictionary/DicTaskBox';
import { dicGacha, loadGacha } from "./dictionary/DicGacha";
@@ -206,6 +206,7 @@ export const gameData = {
mainTask: dicMainTask,
dailyTask: dicDailyTask,
achievement: dicAchievement,
pvpDailyTask: dicPvpDailyTask,
mainTaskStage: dicMainTaskStage,
taskBox: dicTaskBox,
gacha: dicGacha,

View File

@@ -87,21 +87,40 @@ const DicAchievementKeys: KeysEnum<DicAchievement> = {
point: true
};
// pvp任务
export interface DicPvpDailyTask extends DicTaskBase {
// 奖励
readonly taskReward: RewardInter[];
}
const DicPvpDailyTaskKeys: KeysEnum<DicPvpDailyTask> = {
id: true,
taskType: true,
group: true,
taskParam: true,
condition: true,
taskReward: true
};
export type DicTask = DicTaskBase & { type: number };
export const dicMainTask = new Map<number, DicMainTask>(); // 主线任务
export const dicDailyTask = new Map<number, DicDailyTask>(); // 每日任务
export const dicAchievement = new Map<number, DicAchievement>(); // 成就
export const taskMap = new Map<number, Map<number, DicMainTask | DicDailyTask | DicAchievement>>();
export const dicPvpDailyTask = new Map<number, DicDailyTask>(); // 成就
export const taskMap = new Map<number, Map<number, DicMainTask | DicDailyTask | DicAchievement | DicDailyTask>>();
taskMap.set(TASK_FUN_TYPE.MAIN, dicMainTask);
taskMap.set(TASK_FUN_TYPE.DAILY, dicDailyTask);
taskMap.set(TASK_FUN_TYPE.ACHIEVEMENT, dicAchievement);
taskMap.set(TASK_FUN_TYPE.PVP, dicPvpDailyTask);
export const dicTaskType = new Map<number, DicTask[]>();
export function loadTask() {
dicMainTask.clear();
dicDailyTask.clear();
dicAchievement.clear();
dicPvpDailyTask.clear();
const arrMainTask = readFileAndParse(FILENAME.DIC_MAIN_TASK);
arrMainTask.forEach(o => {
@@ -128,6 +147,14 @@ export function loadTask() {
pushDicTaskType(o.taskType, TASK_FUN_TYPE.ACHIEVEMENT, o);
});
const arrPvpDailyTask = readFileAndParse(FILENAME.DIC_PVP_DAILY_TASK);
arrPvpDailyTask.forEach(o => {
o.taskParam = parseNumberList(o.taskParam);
o.taskReward = parseGoodStr(o.taskReward);
o.group = 1;
dicPvpDailyTask.set(o.id, _.pick(o, Object.keys(DicPvpDailyTaskKeys)));
pushDicTaskType(o.taskType, TASK_FUN_TYPE.PVP, o);
});
}
function pushDicTaskType(taskType: number, type: number, o: any) {

View File

@@ -0,0 +1,56 @@
[
{
"id": 1,
"dailyTaskId": 8,
"taskType": 57,
"taskInfo": "演武3次",
"taskParam": "3&",
"taskReward": "40004&30",
"condition": 3
},
{
"id": 2,
"dailyTaskId": 8,
"taskType": 57,
"taskInfo": "演武5次",
"taskParam": "5&",
"taskReward": "40004&60",
"condition": 5
},
{
"id": 3,
"dailyTaskId": 8,
"taskType": 57,
"taskInfo": "演武7次",
"taskParam": "7&",
"taskReward": "40004&100",
"condition": 7
},
{
"id": 4,
"dailyTaskId": 9,
"taskType": 58,
"taskInfo": "演武胜利1次",
"taskParam": "1&",
"taskReward": "40004&100",
"condition": 1
},
{
"id": 5,
"dailyTaskId": 9,
"taskType": 58,
"taskInfo": "演武胜利3次",
"taskParam": "3&",
"taskReward": "40004&300",
"condition": 3
},
{
"id": 6,
"dailyTaskId": 9,
"taskType": 58,
"taskInfo": "演武胜利5次",
"taskParam": "5&",
"taskReward": "40004&500",
"condition": 5
}
]