优化:任务中的活动读内存

This commit is contained in:
luying
2021-09-13 09:51:57 +08:00
parent aef511b1aa
commit d3f743ab4e
7 changed files with 61 additions and 16 deletions
+4 -5
View File
@@ -15,6 +15,7 @@ import { reduceCe, resResult } from "./util";
import { calculatetopLineup, } from "./playerCe";
import { GuildModel, GuildType } from "../db/Guild";
import { PvpDefenseModel } from "../db/PvpDefense";
import { ActivityModelType } from "../db/Activity";
// 储存在内存中的初始数据
export function getInitRoleInfo() {
@@ -219,7 +220,6 @@ export class CreateHeroes extends UpdateHeroes {
this.addRoleUpdateParam({ frames, heads, spines });
// 更新战力
await this.saveCeToDb();
await this.clearTask();
}
// 创建初始账号时候的初始
@@ -233,10 +233,9 @@ export class CreateHeroes extends UpdateHeroes {
heroeInfos.push({ ...heroInfo, skins, _id: new HeroModel()._id});
}
this.resultHeroes = await HeroModel.insertHeroes(this.roleId, this.roleName, this.serverId, heroeInfos);
await this.clearTask();
}
private async clearTask() {
public async clearTask(activitiesTypeMap: ActivityModelType[]) {
// 任务
console.log('****** checkTask before', Date.now())
let m1 = await checkTask(this.roleId, TASK_TYPE.HERO_NUM, this.heroNum, true, {});
@@ -247,8 +246,8 @@ export class CreateHeroes extends UpdateHeroes {
console.log('****** checkTask after', Date.now())
//成长任务
console.log('****** accomplishTask before', Date.now())
let mm1 = await accomplishTask(this.serverId, this.roleId, TASK_TYPE.HERO_NUM, this.heroNum)
let mm2 = await accomplishTask(this.serverId, this.roleId, TASK_TYPE.HERO_QUALITY, this.heroNum, { heroes: this.resultHeroes })
let mm1 = await accomplishTask(this.serverId, this.roleId, TASK_TYPE.HERO_NUM, this.heroNum, null, activitiesTypeMap)
let mm2 = await accomplishTask(this.serverId, this.roleId, TASK_TYPE.HERO_QUALITY, this.heroNum, { heroes: this.resultHeroes }, activitiesTypeMap)
console.log('****** accomplishTask after', Date.now())
this.activityTaskPushMessage.push(...mm1, ...mm2);
}