初始:初始账号bug
This commit is contained in:
+15
-36
@@ -8,14 +8,13 @@ import { Figure, TopHero } from "../domain/dbGeneral";
|
||||
import { CalHeroCe, CalRoleCe } from "../domain/roleField/calCe";
|
||||
import { gameData, getHeroExpByLv } from "../pubUtils/data";
|
||||
import { accomplishTask, checkTask, checkTaskWithHeroes } from './taskUtil';
|
||||
import { combineFigureInfo, unlockFigure, unlockFigureWithoutSave } from './itemUtils';
|
||||
import { combineFigureInfo, unlockFigureWithoutSave } from './itemUtils';
|
||||
import { TaskListReturn } from "../domain/roleField/task";
|
||||
import { nowSeconds } from "./timeUtil";
|
||||
import { reduceCe, resResult } from "./util";
|
||||
import { calculatetopLineup, calPlayerCeAndSave } from "./playerCe";
|
||||
import { calculatetopLineup, } from "./playerCe";
|
||||
import { GuildModel, GuildType } from "../db/Guild";
|
||||
import { PvpDefenseModel } from "../db/PvpDefense";
|
||||
import { CreateHeroParam } from "../domain/roleField/hero";
|
||||
|
||||
// 储存在内存中的初始数据
|
||||
export function getInitRoleInfo() {
|
||||
@@ -176,34 +175,9 @@ export class CreateHeroes extends UpdateHeroes {
|
||||
private taskPushMessage: TaskListReturn[] = [];
|
||||
private activityTaskPushMessage = [];
|
||||
private figureInfos: { heads: Figure[], frames: Figure[], spines: Figure[] }[] = [];
|
||||
|
||||
// web-server和gm-server里面创建
|
||||
public async calWithParam(heroInfos: CreateHeroParam[]) {
|
||||
let heroNum = 0;
|
||||
let conditions = new Array<{ type: number, paramHid?: number, paramFavourLv?: number, paramSkinId?: number }>();
|
||||
|
||||
for (let heroInfo of heroInfos) {
|
||||
let dicHero = gameData.hero.get(heroInfo.hid);
|
||||
let { quality, initialStars: star, jobid: job, name: hName, initialSkin } = dicHero;
|
||||
let info = { roleId: this.roleId, roleName: this.roleName, serverId: this.serverId, quality, star, job, hName };
|
||||
let skin = new SkinModel();
|
||||
let dicFashion = gameData.fashion.get(initialSkin);
|
||||
let skins = await this.getSkinsOfThisHero(heroInfo.hid, { ...skin.toJSON(), id: initialSkin, hid: heroInfo.hid, skinName: dicFashion.name });
|
||||
let curHero = await HeroModel.createHero(Object.assign(info, heroInfo, { skins }));
|
||||
|
||||
// 计算初始战力
|
||||
await calPlayerCeAndSave(HERO_SYSTEM_TYPE.INIT, this.roleId, curHero, {});
|
||||
conditions.push({ type: FIGURE_UNLOCK_CONDITION.GET_HERO, paramHid: heroInfo.hid });
|
||||
heroNum++;
|
||||
}
|
||||
this.figureInfos.push(await unlockFigure(this.roleId, conditions)); // 解锁头像
|
||||
|
||||
await RoleModel.incRoleInfo(this.roleId, { heroNum }, { heroNumUpdatedAt: nowSeconds() });
|
||||
await this.clearTask();
|
||||
}
|
||||
|
||||
private async getSkinsOfThisHero(hid: number, initSkinInfo: SkinUpdate) {
|
||||
let allSkins = await SkinModel.findbyRoleAndHid(this.roleId, hid);
|
||||
|
||||
private async getSkinsOfThisHero(hid: number, initSkinInfo: SkinUpdate, isInit: boolean) {
|
||||
let allSkins = isInit? []: await SkinModel.findbyRoleAndHid(this.roleId, hid);
|
||||
let skin = await SkinModel.insertSkins(this.roleId, this.roleName, [initSkinInfo]);
|
||||
if(skin) allSkins.push(...skin);
|
||||
let skins: { id: number, skin: string, enable: boolean }[] = [];
|
||||
@@ -223,8 +197,8 @@ export class CreateHeroes extends UpdateHeroes {
|
||||
conditions.push({ type: FIGURE_UNLOCK_CONDITION.GET_HERO, paramHid: heroInfo.hid });
|
||||
this.updateDbCe(true, heroInfo);
|
||||
// 皮肤使用初始加载进内存的数据
|
||||
let skins = await this.getSkinsOfThisHero(hid, skinInfo);
|
||||
initHeroInfos.push({ ...heroInfo, skins });
|
||||
let skins = await this.getSkinsOfThisHero(hid, { ...skinInfo, _id: new SkinModel()._id }, false);
|
||||
initHeroInfos.push({ ...heroInfo, skins, _id: new HeroModel()._id });
|
||||
}
|
||||
// 武将使用初始加载数据插入
|
||||
this.resultHeroes = await HeroModel.insertHeroes(this.roleId, this.roleName, this.serverId, initHeroInfos);
|
||||
@@ -238,11 +212,16 @@ export class CreateHeroes extends UpdateHeroes {
|
||||
}
|
||||
|
||||
// 创建初始账号时候的初始
|
||||
public async createWithInitInfo(heroeInfos: HeroUpdate[], skinInfos: SkinUpdate[], figureInfo: { heads: Figure[], frames: Figure[], spines: Figure[] }) {
|
||||
public async createWithInitInfo(infos: Map<number, { heroInfo: HeroUpdate, skinInfo: SkinUpdate }>, figureInfo: { heads: Figure[], frames: Figure[], spines: Figure[] }) {
|
||||
this.figureInfos.push(figureInfo);
|
||||
for(let heroInfo of heroeInfos) this.updateDbCe(true, heroInfo);
|
||||
let heroeInfos: HeroUpdate[] = [];
|
||||
for (let [ hid, { heroInfo, skinInfo }] of infos) {
|
||||
this.updateDbCe(true, heroInfo);
|
||||
let model = new SkinModel();
|
||||
let skins = await this.getSkinsOfThisHero(hid, { ...skinInfo, _id: model._id }, true);
|
||||
heroeInfos.push({ ...heroInfo, skins, _id: new HeroModel()._id});
|
||||
}
|
||||
this.resultHeroes = await HeroModel.insertHeroes(this.roleId, this.roleName, this.serverId, heroeInfos);
|
||||
await SkinModel.insertSkins(this.roleId, this.roleName, skinInfos);
|
||||
await this.clearTask();
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user