✨ feat(gvg): 任务
This commit is contained in:
@@ -15,12 +15,13 @@ import { SevenDaysData } from "../../domain/activityField/sevenDaysField";
|
||||
import { ThirtyDaysData } from "../../domain/activityField/thirtyDaysField";
|
||||
import { TreasureHuntData } from "../../domain/activityField/treasureHuntField";
|
||||
import { TaskListReturn, TaskParam, TaskParamInter, UpdateTaskParam } from "../../domain/roleField/task";
|
||||
import { gameData, getDicBlueprtById, getEquipSuitByHero } from "../../pubUtils/data";
|
||||
import { gameData, getDicBlueprtById, getEquipSuitByHero, getGVGTasksByType } from "../../pubUtils/data";
|
||||
import { getZeroPoint } from "../../pubUtils/timeUtil";
|
||||
import { getActivityByServerId } from "../activity/activityService";
|
||||
import { getRoleCreateTime, getRoleOnlineInfo, getServerCreateTime } from "../redisService";
|
||||
import { getEquipById, getJewelByEquip, isRandSeUnLock } from "../equipService";
|
||||
import { sendMessageToUserWithSuc } from "../pushService";
|
||||
import { GVGUserTaskModel } from "../../db/GVGUserTask";
|
||||
|
||||
export class CheckTask {
|
||||
serverId: number; // 区id
|
||||
@@ -29,8 +30,12 @@ export class CheckTask {
|
||||
roleCreateTime: number; // 玩家的创建时间
|
||||
serverCreateTime: number; // 服务器的创建时间
|
||||
|
||||
configId?: number;
|
||||
leagueCode?: string;
|
||||
|
||||
taskPushMessages: TaskListReturn[] = [];
|
||||
activityTaskPushMessages = [];
|
||||
gvgTaskPushMessages = [];
|
||||
|
||||
tasks: CheckSingleTask[] = [];
|
||||
|
||||
@@ -45,6 +50,11 @@ export class CheckTask {
|
||||
this.tasks.push(task);
|
||||
}
|
||||
|
||||
setLeague(configId: number, leagueCode: string) {
|
||||
this.configId = configId;
|
||||
this.leagueCode = leagueCode;
|
||||
}
|
||||
|
||||
public async saveAndPush(sid?: string) {
|
||||
for(let task of this.tasks) {
|
||||
await task.check();
|
||||
@@ -92,6 +102,9 @@ export class CheckTask {
|
||||
if (this.taskPushMessages.length > 0) {
|
||||
sendMessageToUserWithSuc(roleId, PUSH_ROUTE.TASK_UPDATE,this.taskPushMessages, sid);
|
||||
}
|
||||
if(this.gvgTaskPushMessages.length > 0) {
|
||||
sendMessageToUserWithSuc(roleId, PUSH_ROUTE.GVG_TASK_UPDATE,this.gvgTaskPushMessages, sid);
|
||||
}
|
||||
if (this.activityTaskPushMessages.length > 0) {
|
||||
sendMessageToUserWithSuc(roleId, PUSH_ROUTE.ACTIVITY_TASK_UPDATE, this.activityTaskPushMessages, sid);
|
||||
}
|
||||
@@ -123,6 +136,10 @@ export class CheckSingleTask {
|
||||
this.parent.taskPushMessages.push(...param);
|
||||
}
|
||||
|
||||
private addGVGTaskPushMessage(...param: {id: number, count: number}[]) {
|
||||
this.parent.gvgTaskPushMessages.push(...param);
|
||||
}
|
||||
|
||||
private addActivityTaskPushMessage(...param: any[]) {
|
||||
this.parent.activityTaskPushMessages.push(...param);
|
||||
}
|
||||
@@ -177,6 +194,21 @@ export class CheckSingleTask {
|
||||
}
|
||||
}
|
||||
|
||||
// 联军任务
|
||||
let dicGVGTasks = getGVGTasksByType(taskType);
|
||||
console.log('#####', taskType, dicGVGTasks)
|
||||
for(let { taskId, taskType, taskParam } of dicGVGTasks) {
|
||||
let taskUpdateParam = await this.checkIsMatch(taskParam, async () => []);
|
||||
if (taskUpdateParam) {
|
||||
let rec = await GVGUserTaskModel.setOrIncTask(this.parent.configId, this.parent.leagueCode, roleId, taskType, taskId, taskUpdateParam);
|
||||
if (!rec) continue;
|
||||
|
||||
if(rec.status == 1) {
|
||||
this.addGVGTaskPushMessage({ id: taskId, count: rec.count });
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 检查活动任务
|
||||
let activities = await getActivityByServerId(serverId);
|
||||
for(let activity of activities) {
|
||||
@@ -1404,6 +1436,24 @@ export class CheckSingleTask {
|
||||
}
|
||||
break;
|
||||
}
|
||||
case TASK_TYPE.GVG_FARM: // 132. 农庄种植/矿山采集/木堆砍柴
|
||||
{
|
||||
let { count } = param;
|
||||
result = { inc: count };
|
||||
break;
|
||||
}
|
||||
case TASK_TYPE.GVG_VESTIGE: // 133. 中原遗迹挑战
|
||||
{
|
||||
let { count } = param;
|
||||
result = { inc: count };
|
||||
break;
|
||||
}
|
||||
case TASK_TYPE.GVG_TECH: // 134. 千机阁捐献
|
||||
{
|
||||
let { count } = param;
|
||||
result = { inc: count };
|
||||
break;
|
||||
}
|
||||
}
|
||||
return result
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user