初始:初始账号bug
This commit is contained in:
@@ -48,11 +48,16 @@ export class RoleHandler {
|
||||
if (checkName) return resResult(STATUS.NAME_HAS_USED);
|
||||
|
||||
console.log('****** createHeroes before', Date.now())
|
||||
let initInfos: { role: RoleUpdate, heroes: HeroUpdate[], skins: SkinUpdate[], figureInfo: { heads: Figure[], frames: Figure[], spines: Figure[] }}
|
||||
let initInfos: { role: RoleUpdate, initInfos: {heroInfo: HeroUpdate, skinInfo: SkinUpdate}[], figureInfo: { heads: Figure[], frames: Figure[], spines: Figure[] }}
|
||||
= await this.app.rpc.role.roleRemote.getInitRoleInfos.toServer(this.app.getServerId());
|
||||
role = await RoleModel.updateRoleInfo(roleId, {...initInfos.role, roleName, hasInit: true});
|
||||
let createHero = new CreateHeroes(roleId, roleName, serverId, funcs);
|
||||
await createHero.createWithInitInfo(initInfos.heroes, initInfos.skins, initInfos.figureInfo);
|
||||
|
||||
let infos = new Map();
|
||||
for(let {heroInfo, skinInfo} of initInfos.initInfos) {
|
||||
infos.set(heroInfo.hid, { heroInfo, skinInfo });
|
||||
}
|
||||
await createHero.createWithInitInfo(infos, initInfos.figureInfo);
|
||||
await createHero.pushMessage(pinus, sid);
|
||||
await createHero.updateRedisRank(Rank);
|
||||
let heroes = createHero.getResultHeroes();
|
||||
|
||||
@@ -39,9 +39,15 @@ export class RoleRemote {
|
||||
}
|
||||
|
||||
public getInitRoleInfos() {
|
||||
let initInfos = [];
|
||||
for(let hid of DEFAULT_HEROES) {
|
||||
initInfos.push({
|
||||
heroInfo: this.initHeroes.get(hid),
|
||||
skinInfo: this.initSkins.get(hid)
|
||||
});
|
||||
}
|
||||
return {
|
||||
heroes: this.getInitHeroes(),
|
||||
skins: this.getInitSkins(),
|
||||
initInfos,
|
||||
role: this.initRole,
|
||||
figureInfo: this.figureInfo
|
||||
};
|
||||
|
||||
@@ -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() {
|
||||
@@ -177,33 +176,8 @@ export class CreateHeroes extends UpdateHeroes {
|
||||
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();
|
||||
}
|
||||
|
||||
|
||||
@@ -25,6 +25,10 @@ export default (appInfo: EggAppInfo) => {
|
||||
options: { useNewUrlParser: true, useUnifiedTopology: true },
|
||||
};
|
||||
|
||||
config.redis = {
|
||||
url: 'r-8vbl8okinxn1zhkwh2.redis.zhangbei.rds.aliyuncs.com', // 内网
|
||||
pw: 'zyz_alpha_2021'
|
||||
};
|
||||
// config.alinode = {
|
||||
// appid: '86043',
|
||||
// secret: '54ef0364995b0c4f2ab42150e29ad30df8327a3a',
|
||||
|
||||
@@ -25,8 +25,8 @@ export default (appInfo: EggAppInfo) => {
|
||||
options: { useNewUrlParser: true, useUnifiedTopology: true },
|
||||
};
|
||||
config.redis = {
|
||||
url: 'r-8vbl8okinxn1zhkwh2.redis.zhangbei.rds.aliyuncs.com', // 内网
|
||||
pw: 'zyz_alpha_2021'
|
||||
url: 'r-8vb418l8kkju9sis8k.redis.zhangbei.rds.aliyuncs.com', // 内网
|
||||
pw: 'zyz_dev_2021'
|
||||
};
|
||||
|
||||
// config.alinode = {
|
||||
|
||||
Reference in New Issue
Block a user