任务:今日挑战区分累积型和去做型

This commit is contained in:
luying
2022-01-17 18:20:37 +08:00
parent 683dfeda81
commit 64b6d4706e
6 changed files with 194 additions and 101 deletions
+2 -1
View File
@@ -82,7 +82,7 @@ import { dicGiftPackage, loadGiftPackage } from "./dictionary/DicGiftPackage";
import { dicRecruit, loadRecruit } from './dictionary/DicRecruit';
import { loadRMB, dicRMB } from './dictionary/DicRMB';
import { dicActivityType, loadActivityType } from './dictionary/DicActivityType';
import { DicTaskType, dicTaskTypeDesc, loadTaskType } from './dictionary/DicTaskType';
import { DicTaskType, dicTaskTypeDesc, loadTaskType, taskDescByType } from './dictionary/DicTaskType';
import { dicServerName, loadServerName } from "./dictionary/DicServerName";
import { dicAp, loadAp, dicApMaxLevel } from './dictionary/DicAp';
import { dicApBuy, dicApMaxBuyTimes, loadApBuy } from "./dictionary/DicApBuy";
@@ -227,6 +227,7 @@ export const gameData = {
rmb: dicRMB,
activityType: dicActivityType,
taskTypeDesc: dicTaskTypeDesc,
taskDescByType: taskDescByType,
serverNames: dicServerName,
ap: dicAp,
apMaxLevel: dicApMaxLevel,
+7 -1
View File
@@ -13,6 +13,8 @@ export interface DicTaskType {
readonly param: string;
// condition怎么填
readonly condition: string;
// 累积类型 1-累积型 2-去做型
readonly sumType: number;
}
const DicTaskTypeKeys: KeysEnum<DicTaskType> = {
@@ -20,15 +22,19 @@ const DicTaskTypeKeys: KeysEnum<DicTaskType> = {
name: true,
info: true,
param: true,
condition: true
condition: true,
sumType: true,
};
export const dicTaskTypeDesc = new Array<DicTaskType>();
export const taskDescByType = new Map<number, DicTaskType>();
export function loadTaskType() {
dicTaskTypeDesc.splice(0, dicTaskTypeDesc.length);
taskDescByType.clear();
let arr = readFileAndParse(FILENAME.DIC_TASK_TYPE);
arr.forEach(o => {
dicTaskTypeDesc.push(_.pick(o, Object.keys(DicTaskTypeKeys)));
taskDescByType.set(o.id, _.pick(o, Object.keys(DicTaskTypeKeys)));
});
arr = undefined;
}
+8 -3
View File
@@ -1,6 +1,6 @@
import { gameData } from './data';
import { DicTask } from './dictionary/DicTask';
import { TASK_TYPE, ABI_STAGE, WAR_TYPE, GUILD_JOB } from '../consts';
import { TASK_TYPE, ABI_STAGE, WAR_TYPE, GUILD_JOB, TASK_SUM_TYPE } from '../consts';
import { UserTaskRecModel, UserTaskRecType } from '../db/UserTaskRec'
import { RoleType, RoleModel } from '../db/Role';
import { TaskParam, TaskListReturn } from '../domain/roleField/task';
@@ -492,6 +492,7 @@ function checkRecResult(rec: UserTaskRecType, id: number) {
*/
export async function accomplishTask(serverId: number, roleId: string, taskType: TASK_TYPE, count: number, parma?: any, activities?: ActivityInRemote[]) {
// console.log('accomplishTask', roleId, taskType, count, JSON.stringify(parma))
let dicTaskType = gameData.taskDescByType.get(taskType);
let pushMessage = [];
let { activityGroupId } = await ServerlistModel.findByServerId(serverId);
let findActivitiesByTypes = async (types: number[]) => {
@@ -520,7 +521,7 @@ export async function accomplishTask(serverId: number, roleId: string, taskType:
let playerData = new SevenDaysData(activity, createTime)
//成长活动统计
let growthActivity = playerData.growth;
let growthTaskArray = growthActivity.findTaskByType(taskType);
let growthTaskArray = growthActivity.findTaskByType(taskType); // 所有任务
for (let task of growthTaskArray) {
let taskRecord = await ActivityGrowthModel.findDataByCellIndex(serverId, activity.activityId, roleId, task.dayIndex, task.cellIndex, task.taskType);
let recordData = taskRecord && taskRecord.data ? JSON.parse(taskRecord.data) : null;
@@ -547,8 +548,12 @@ export async function accomplishTask(serverId: number, roleId: string, taskType:
}
//今日挑战统计
let dailyChallengeActivity = playerData.dailyChallenge;
let dailyChallengeTaskArray = dailyChallengeActivity.findTaskByType(taskType, playerData.today());
let dailyChallengeTaskArray = dailyChallengeActivity.findTaskByType(taskType);
for (let task of dailyChallengeTaskArray) {
if(dicTaskType.sumType == TASK_SUM_TYPE.DO && task.dayIndex != playerData.today()) {
continue;
}
let taskRecord = await ActivityDailyChallengesModel.findDataByCellIndex(serverId, activity.activityId, roleId, task.dayIndex, task.cellIndex, task.taskType)
let recordData = taskRecord && taskRecord.data ? JSON.parse(taskRecord.data) : null
let { addCount, record } = isComplete(roleId, task.taskType, task.taskParam, count, activity.activityId, parma, recordData);