优化:创建武将从util放到game-server的service

This commit is contained in:
陆莹
2022-03-16 20:42:46 +08:00
parent 73e5ec2698
commit 4e110afc70
11 changed files with 439 additions and 428 deletions

View File

@@ -20,13 +20,13 @@ import { checkTaskWithHero, checkTask, checkTaskWithArgs, checkActivityTask } fr
import { getGoldObject, getCoinObject } from '../../../pubUtils/itemUtils';
import { RScriptRecordModel } from '../../../db/RScriptRecord';
import { SkinModel, SkinUpdate } from '../../../db/Skin';
import { CreateHeroes, deletRole } from '../../../pubUtils/roleUtil';
import { Figure } from '../../../domain/dbGeneral';
import { getActivities } from '../../../services/activity/activityService';
import * as dicParam from '../../../pubUtils/dicParam';
import Counter from '../../../db/Counter';
import { UserModel } from '../../../db/User';
import { checkFilterWords, reportTAEvent, treatRoleName } from '../../../services/sdkService';
import { CreateHeroes } from '../../../services/role/createHero';
export default function (app: Application) {
new HandlerService(app, {});
@@ -62,8 +62,8 @@ export class RoleHandler {
}
await createHero.createWithInitInfo(infos, initInfos.figureInfo);
await createHero.clearTask(await getActivities());
await createHero.pushMessage(pinus, sid);
await createHero.updateRedisRank(Rank);
await createHero.pushMessage(sid);
await createHero.updateRedisRank();
let heroes = createHero.getResultHeroes();
session.set('roleName', roleName);

View File

@@ -5,7 +5,6 @@ import { HeroUpdate } from '../../../db/Hero';
import { RoleUpdate } from '../../../db/Role';
import { SkinUpdate } from '../../../db/Skin';
import { RankFirstModel, RankFirstType } from '../../../db/RankFirst';
import { getInitRoleInfo } from '../../../pubUtils/roleUtil';
import { DEFAULT_HEROES } from '../../../consts';
import { Figure } from '../../../domain/dbGeneral';
import { getDefaultRoleInfo } from '../../../services/roleService';
@@ -13,6 +12,7 @@ import { PVPConfigModel, PVPConfigType } from '../../../db/SystemConfig';
import { treatRoleName, taflush } from '../../../services/sdkService';
import { getServerMainten, setServerMainten, stopServerMainten } from '../../../services/gmService';
import { errlogger } from '../../../util/logger';
import { getInitRoleInfo } from '../../../services/role/initRoleService';
export default function (app: Application) {
new HandlerService(app, {});

View File

@@ -179,7 +179,7 @@ export class Rank {
* @param hero 武将数据库
* @param isInc 得分是累加上的还是直接设置的
*/
public async setRankWithHeroInfo(roleId: string, hid: number, score: number, timestamp: number, hero?: HeroType, isInc = false) {
public async setRankWithHeroInfo(roleId: string, hid: number, score: number, timestamp: number, hero?: HeroUpdate, isInc = false) {
// 如果没有信息,更新玩家信息
for (let infoKey of [this.infoKey, ...this.extraKeys]) {
await this.generParamAndSet(infoKey, { roleId, hid }, { hero });
@@ -235,7 +235,7 @@ export class Rank {
* @param fields 玩家id
* @param db 数据库内的数据
*/
public async generParamAndSet(infoKey: string, fields: myIdInter, db: { role?: RoleType, guild?: GuildType, hero?: HeroType }) {
public async generParamAndSet(infoKey: string, fields: myIdInter, db: { role?: RoleType, guild?: GuildType, hero?: HeroUpdate }) {
let { roleId, guildCode, hid } = fields;
let { role, guild, hero } = db;

View File

@@ -19,7 +19,6 @@ import { HeroSkin } from '../db/Hero';
import { errlogger } from '../util/logger';
import { BAG } from '../pubUtils/dicParam';
import { sendMailByContent } from './mailService';
import { CreateHeroes } from '../pubUtils/roleUtil';
import { SkinUpdate } from '../db/Skin';
import { getInitHeroById } from './roleService';
import { getActivities } from './activity/activityService';
@@ -28,6 +27,7 @@ import { saveCoinChangeLog, saveFigureInfoLog, saveGoldChangeLog, saveItemChange
import { JewelModel, JewelType } from '../db/Jewel';
import { updateEplaces } from './equipService';
import { checkPopUpConditionInCreateHero } from './activity/popUpShopService';
import { CreateHeroes } from './role/createHero';
export class CheckMeterial {
private roleId: string;
@@ -601,8 +601,8 @@ export async function createHeroes(roleId: string, roleName: string, sid: string
let createHero = new CreateHeroes(roleId, roleName, serverId);
await createHero.createWithHeroInfo(infos);
await createHero.clearTask(await getActivities())
await createHero.pushMessage(pinus, sid);
await createHero.updateRedisRank(Rank);
await createHero.pushMessage(sid);
await createHero.updateRedisRank();
heroes = createHero.getShowHeroes();
resultHeroes = createHero.getResultHeroes();

View File

@@ -0,0 +1,233 @@
import { FIGURE_UNLOCK_CONDITION, ITEM_CHANGE_REASON, REDIS_KEY, STATUS, TASK_TYPE, HERO_SYSTEM_TYPE } from "../../consts";
import { SkinModel } from "../../db/Skin";
import { HeroModel, HeroSkin, HeroType, HeroUpdate } from "../../db/Hero";
import { RoleModel, RoleType, RoleUpdate } from "../../db/Role";
import { SkinUpdate } from "../../db/Skin";
import { Figure, TopHero } from "../../domain/dbGeneral";
import { accomplishTask, checkTask, checkTaskWithHeroes } from '../../pubUtils/taskUtil';
import { combineFigureInfo, unlockFigureWithoutSave } from '../../pubUtils/itemUtils';
import { TaskListReturn } from "../../domain/roleField/task";
import { GuildModel, GuildType } from "../../db/Guild";
import { PvpDefenseModel } from "../../db/PvpDefense";
import { pick } from "underscore";
import { calculatetopLineup } from "../../pubUtils/playerCe";
import { nowSeconds } from "../../pubUtils/timeUtil";
import { saveCeChangeLog } from "../../pubUtils/logUtil";
import { reduceCe, resResult } from "../../pubUtils/util";
import { AttributeCal } from "../../domain/roleField/attribute";
import { ActivityInRemote } from "../../domain/activityField/activityField";
import { HeroShowParam } from "../../domain/roleField/hero";
import { pinus } from "pinus";
import { Rank } from "../rankService";
export class UpdateHeroes {
roleId: string;
roleName: string;
serverId: number;
incHeroNum: number = 0;
incRoleCe: number = 0;
pushHeroes: {hid: number, incHeroCe: number, ce: number, hero: HeroUpdate}[] = [];
roleUpdate: RoleUpdate;
role: RoleType;
guild: GuildType;
constructor(roleId: string, roleName: string, serverId: number) {
this.roleId = roleId;
this.roleName = roleName;
this.serverId = serverId;
}
public setRole(role: RoleType) {
this.role = role;
}
public async getRole() {
if(!this.role) {
this.role = await RoleModel.findByRoleId(this.roleId);
}
return this.role;
}
public addRoleUpdateParam(param: RoleUpdate) {
this.roleUpdate = {...this.roleUpdate, ...param};
}
public async updateDbCe(isCreate: boolean, heroInfo: HeroUpdate, originCe = 0) {
let role = await this.getRole();
if(isCreate) this.incHeroNum ++;
if(heroInfo != originCe) this.incRoleCe += heroInfo.ce - originCe;
this.addRoleUpdateParam(await calculatetopLineup(role, heroInfo.hid, heroInfo.ce, heroInfo._id ));
this.pushHeroes.push({ hid: heroInfo.hid, incHeroCe: heroInfo.ce - originCe, ce: heroInfo.ce, hero: heroInfo });
}
// 更新战力相关的各个表
public async saveCeToDb() {
let role = await this.getRole();
// 更新role表
this.role = await RoleModel.updateRoleInfo(this.roleId, {
heroNum: this.incHeroNum + role.heroNum, ce: this.incRoleCe + role.ce, heroNumUpdatedAt: nowSeconds(), ...this.roleUpdate
});
// 更新guild表
if(role.hasGuild) {
this.guild = await GuildModel.updateCe(this.roleId, this.incRoleCe, true); // 公会更新战力
}
for(let { hid, incHeroCe } of this.pushHeroes) {
await PvpDefenseModel.updateCe(this.roleId, hid, incHeroCe); // 更新pvp防守阵战力
}
saveCeChangeLog(this.role, this.incRoleCe, this.role.ce, HERO_SYSTEM_TYPE.INIT, this.pushHeroes.map(cur => cur.hid));
}
public async updateRedisRank() {
let role = await this.getRole();
let { serverId, roleId, pushHeroes } = this;
// 更新军团信息
if(this.guild) {
let r = new Rank(REDIS_KEY.GUILD_INFO, { guildCode: this.guild.code });
await r.generParamAndSet(REDIS_KEY.GUILD_INFO, { guildCode: this.guild.code }, { guild: this.guild });
}
// 武将数量
if(this.incHeroNum > 0) {
let r = new Rank(REDIS_KEY.HERO_NUM_RANK, { serverId });
await r.setRankWithRoleInfo(roleId, role.heroNum, role.heroNumUpdatedAt, role);
}
// 最强阵容
let r = new Rank(REDIS_KEY.TOP_LINEUP_RANK, { serverId });
await r.setRankWithRoleInfo(roleId, reduceCe(role.topLineupCe), 0, role);
// 最强武将
for(let { hid, ce, hero } of pushHeroes) {
let r2 = new Rank(REDIS_KEY.TOP_HERO_RANK, { serverId });
await r2.setRankWithHeroInfo(roleId, hid, reduceCe(ce), 0, hero);
let r4 = new Rank(REDIS_KEY.HERO_RANK, { serverId, hid });
await r4.setRankWithHeroInfo(roleId, hid, reduceCe(ce), 0, hero);
}
// 总战力
let r3 = new Rank(REDIS_KEY.SUM_CE_RANK, { serverId });
await r3.setRankWithRoleInfo(roleId, reduceCe(role.ce), 0, role);
// 更新最强五人阵容信息
let r5 = new Rank(REDIS_KEY.TOP_LINEUP_INFO, { serverId });
await r5.generParamAndSet(REDIS_KEY.TOP_LINEUP_INFO, { roleId }, { role });
}
public async pushMessage(pinus: any, sid: string) {
let role = await this.getRole();
let uids = [{ uid: this.roleId, sid }];
pinus.app.get('channelService').pushMessageByUids('onPlayerCeUpdate', resResult(STATUS.SUCCESS, { ce: reduceCe(role.ce) , heros: this.pushHeroes.map(cur => { return {...cur, ce: reduceCe(cur.ce), incHeroCe: reduceCe(cur.incHeroCe) }}), topLineupCe: reduceCe(role.topLineupCe) }), uids);
}
}
export class CreateHeroes extends UpdateHeroes {
private resultHeroes: HeroType[] = [];
private heroNum = 0;
// 推送信息
private taskPushMessage: TaskListReturn[] = [];
private activityTaskPushMessage = [];
private figureInfos: { heads: Figure[], frames: Figure[], spines: Figure[] }[] = [];
private skinPushMessages: { heros: {skins: HeroSkin[], hid: number}[], skins: {id: number, hid: number, inc: number, reason: number }[]} = { heros: [], skins: [] };
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]);
let skinInfos = skin.map(cur => ({ id: cur.id, hid, inc: 1, reason: ITEM_CHANGE_REASON.GET_HERO_UNLOCK_SKIN}))
this.skinPushMessages.skins.push(...skinInfos);
if(skin) allSkins.push(...skin);
let skins: { id: number, skin: string, enable: boolean, skinId: number }[] = [];
for(let skin of allSkins) {
skins.push({ id: skin.id, skin: skin._id, enable: skin.id == initSkinInfo.id, skinId: skin.skinId });
}
return skins
}
// game-server里面创建武将
public async createWithHeroInfo(infos: Map<number, { heroInfo: HeroUpdate, skinInfo: SkinUpdate }>) {
let role = await this.getRole();
// 数据处理
let conditions = new Array<{ type: number, paramHid?: number, paramFavourLv?: number, paramSkinId?: number }>(); // 解锁头像条件
let initHeroInfos: HeroUpdate[] = [];
for (let [ hid, { heroInfo, skinInfo }] of infos) {
conditions.push({ type: FIGURE_UNLOCK_CONDITION.GET_HERO, paramHid: heroInfo.hid });
this.updateDbCe(true, heroInfo);
// 皮肤使用初始加载进内存的数据
let skins = await this.getSkinsOfThisHero(hid, { ...skinInfo, _id: new SkinModel()._id }, false);
let newAttr = new AttributeCal();
newAttr.setLv(heroInfo.lv);
newAttr.setByDbData(role.attr, heroInfo.attr);
let heroCe = newAttr.calCe(); // 计算最终战力
initHeroInfos.push({ ...heroInfo, skins, _id: new HeroModel()._id, ce: heroCe });
this.heroNum ++;
}
// 武将使用初始加载数据插入
this.resultHeroes = await HeroModel.insertHeroes(this.roleId, this.roleName, this.serverId, initHeroInfos);
let heroSkins = this.resultHeroes.map(cur => { return pick(cur, ['hid', 'skins']) });
this.skinPushMessages.heros.push(...heroSkins);
// 头像解锁
let { figureInfo, frames, heads, spines } = unlockFigureWithoutSave(conditions, role);
this.figureInfos.push(figureInfo);
this.addRoleUpdateParam({ frames, heads, spines });
// 更新战力
await this.saveCeToDb();
}
// 创建初始账号时候的初始
public async createWithInitInfo(infos: Map<number, { heroInfo: HeroUpdate, skinInfo: SkinUpdate }>, figureInfo: { heads: Figure[], frames: Figure[], spines: Figure[] }) {
this.figureInfos.push(figureInfo);
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.heroNum ++;
}
this.resultHeroes = await HeroModel.insertHeroes(this.roleId, this.roleName, this.serverId, heroeInfos);
}
public async clearTask(activitiesTypeMap: ActivityInRemote[]) {
// 任务
// console.log('****** checkTask before', Date.now())
let m1 = await checkTask(this.roleId, TASK_TYPE.HERO_NUM, this.heroNum, true, {});
let m2 = await checkTaskWithHeroes(this.roleId, TASK_TYPE.HERO_QUALITY, this.resultHeroes);
let m3 = await checkTaskWithHeroes(this.roleId, TASK_TYPE.HERO_QUALITY_STAR_UP, this.resultHeroes);
let m4 = await checkTaskWithHeroes(this.roleId, TASK_TYPE.HERO_LV, this.resultHeroes);
this.taskPushMessage.push(...m1, ...m2, ...m3, ...m4);
// 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, null, activitiesTypeMap)
console.log('****mn1', mm1)
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);
}
public async pushMessage(sid: string) {
let role = await this.getRole();
let uids = [{ uid: this.roleId, sid }];
pinus.app.get('channelService').pushMessageByUids('onPlayerCeUpdate', resResult(STATUS.SUCCESS, { ce: reduceCe(role.ce) , heros: this.pushHeroes.map(cur => { return {...cur, ce: reduceCe(cur.ce), incHeroCe: reduceCe(cur.incHeroCe) }}), topLineupCe: reduceCe(role.topLineupCe) }), uids);
pinus.app.get('channelService').pushMessageByUids('onTaskUpdate', resResult(STATUS.SUCCESS, this.taskPushMessage), uids);
pinus.app.get('channelService').pushMessageByUids('onActivityTaskUpdate', resResult(STATUS.SUCCESS, this.activityTaskPushMessage), uids);
let figureInfo = combineFigureInfo(this.figureInfos);
if (!!figureInfo && (figureInfo.heads.length > 0 || figureInfo.frames.length > 0 || figureInfo.spines.length > 0)) {
pinus.app.get('channelService').pushMessageByUids('onHeadChange', resResult(STATUS.SUCCESS, { ...figureInfo }), uids);
}
pinus.app.get('channelService').pushMessageByUids('onHeroSkinChange', resResult(STATUS.SUCCESS, this.skinPushMessages), uids);
pinus.app.get('channelService').pushMessageByUids('onHeroUpdate', resResult(STATUS.SUCCESS, { heroes: this.getResultHeroes() }), uids);
}
public getResultHeroes() {
return this.resultHeroes.map(cur => ({...cur, ce: reduceCe(cur.ce)}))
}
public getShowHeroes() {
return this.resultHeroes.map(cur => {
let hero = new HeroShowParam(cur);
return { ...hero, ce: reduceCe(cur.ce)}
});
}
}

View File

@@ -0,0 +1,61 @@
import { DEFAULT_HEROES, DEFAULT_HERO_LV, FIGURE_UNLOCK_CONDITION, HERO_SYSTEM_TYPE, LINEUP_NUM } from "../../consts";
import { HeroModel, HeroUpdate } from "../../db/Hero";
import { RoleModel, RoleUpdate } from "../../db/Role";
import { SkinModel, SkinUpdate } from "../../db/Skin";
import { TopHero } from "../../domain/dbGeneral";
import { CalHeroCe, CalRoleCe } from "../../domain/roleField/calCe";
import { gameData, getHeroExpByLv } from "../../pubUtils/data";
import { unlockFigureWithoutSave } from "../../pubUtils/itemUtils";
// 储存在内存中的初始数据
export function getInitRoleInfo() {
let topLineup: TopHero[] = [], topLineupCe = 0, allCe = 0,
heroes: HeroUpdate[] = [], initHeroes: HeroUpdate[] = [], initSkins: SkinUpdate[] = [], heroNum = 0,
conditions: {type: FIGURE_UNLOCK_CONDITION, paramHid: number }[] = [];
let role = new RoleModel();
let calRoleCe = new CalRoleCe(role);
let roleAttr = calRoleCe.cal(HERO_SYSTEM_TYPE.INIT);
for(let { actorId: hid } of gameData.recruit) {
let { quality, initialStars: star, jobid: job, name: hName, initialSkin } = gameData.hero.get(hid);
// 皮肤
let skin = new SkinModel();
let dicFashion = gameData.fashion.get(initialSkin);
if(!dicFashion) {
console.log(`not found skin: ${initialSkin} of ${hid}`);
continue;
}
let skinInfo = { ...skin.toJSON(), id: initialSkin, hid, skinName: dicFashion.name, skinId: dicFashion.heroId };
initSkins.push(skinInfo);
// 武将
let hero = new HeroModel();
let heroInfo = {...hero.toJSON(), hid, star, quality, hName, job, skins: [{ id: initialSkin, skin: skinInfo._id, enable: true, skinId: skinInfo.skinId }], skinId: skinInfo.skinId, lv: DEFAULT_HERO_LV, exp: getHeroExpByLv(DEFAULT_HERO_LV - 1) || 0 };
let calHeroCe = new CalHeroCe(hid, heroInfo);
let heroAttr = calHeroCe.cal(HERO_SYSTEM_TYPE.INIT);
let ce = calHeroCe.getCalculatedCe(roleAttr);
heroes.push({ ...heroInfo, attr: heroAttr, ce, historyCe: ce });
// 更新role表
if(DEFAULT_HEROES.includes(hid)) {
// 头像
conditions.push({ type: FIGURE_UNLOCK_CONDITION.GET_HERO, paramHid: hid });
allCe += ce;
heroNum++;
initHeroes.push({ ...heroInfo, attr: heroAttr, ce, historyCe: ce });
}
}
let { figureInfo, heads, frames, spines } = unlockFigureWithoutSave(conditions, role);
// 最强阵容
initHeroes.sort((a, b) => { return b.ce - a.ce });
for(let i = 0; i < LINEUP_NUM; i++) {
if(initHeroes[i]) {
let { hid, ce, _id } = initHeroes[i];
topLineup.push({ hid, ce, hero: _id });
topLineupCe += ce;
}
}
let initRole: RoleUpdate = { topLineupCe, topLineup, attr: roleAttr, ce: allCe, heroNum, heroNumUpdatedAt: Date.now(), heads, frames, spines };
return {
role: initRole, heroes, skins: initSkins, figureInfo
}
}

View File

@@ -1,8 +1,8 @@
import { Service } from 'egg';
import * as pubUtils from '@pubUtils/util';
import { HeroUpdate } from '@db/Hero';
import { SkinUpdate } from '@db/Skin';
import { getInitRoleInfo } from '@pubUtils/roleUtil';
// import { HeroUpdate } from '@db/Hero';
// import { SkinUpdate } from '@db/Skin';
// import { getInitRoleInfo } from '@pubUtils/roleUtil';
const csprng = require('csprng');
/**
@@ -13,29 +13,29 @@ export default class Utils extends Service {
constructor(args) {
super(args);
this.setInitRole();
// this.setInitRole();
}
private initHeroes: Map<number, HeroUpdate> = new Map(); // hid => hero
private initSkins: Map<number, SkinUpdate> = new Map(); // hid => skin
// private initHeroes: Map<number, HeroUpdate> = new Map(); // hid => hero
// private initSkins: Map<number, SkinUpdate> = new Map(); // hid => skin
public setInitRole() {
let result = getInitRoleInfo();
let { heroes, skins } = result;
for(let hero of heroes) {
this.initHeroes.set(hero.hid, hero);
}
for(let skin of skins) {
this.initSkins.set(skin.hid, skin);
}
}
// public setInitRole() {
// let result = getInitRoleInfo();
// let { heroes, skins } = result;
// for(let hero of heroes) {
// this.initHeroes.set(hero.hid, hero);
// }
// for(let skin of skins) {
// this.initSkins.set(skin.hid, skin);
// }
// }
public getInitHeroById(hid: number) {
return {
heroInfo: this.initHeroes.get(hid),
skinInfo: this.initSkins.get(hid)
}
}
// public getInitHeroById(hid: number) {
// return {
// heroInfo: this.initHeroes.get(hid),
// skinInfo: this.initSkins.get(hid)
// }
// }
/**
* 生成 len 长度的随机字符串

View File

@@ -3,17 +3,15 @@ import { CeAttrDataRole, RoleModel } from '@db/Role';
import { HeroModel } from '@db/Hero';
import { Service } from 'egg';
import { STATUS, ITEM_CHANGE_REASON, REDIS_KEY, WAR_TYPE } from '@consts';
import { ITID } from '@consts';
import { STATUS, REDIS_KEY, WAR_TYPE } from '@consts';
import { ItemModel } from '@db/Item';
import { gameData, getExpByLv } from '@pubUtils/data';
import { gameData } from '@pubUtils/data';
import { AttributeCal } from '@domain/roleField/attribute';
import { smsModel } from '@db/Sms';
import { isString } from 'underscore';
import { addSkin, addBags } from '@pubUtils/itemUtils';
import { GiftCodeModel } from '@db/GiftCode';
import { GiftCodeDetailModel } from '@db/GiftCodeDetail';
import { CreateHeroes, deletRole } from '@pubUtils/roleUtil';
import { deletRole } from '@pubUtils/roleUtil';
import { RScriptRecordModel } from '@db/RScriptRecord';
import { DicWar } from '@pubUtils/dictionary/DicWar';
import { SearchHeroParam, SearchUserParam, SearchGiftCodeParam, SearchGiftCodeDetailParam, SearchItemParam, SearchGuildParam } from '@domain/backEndField/search';
@@ -143,127 +141,127 @@ export default class GMUsers extends Service {
return ctx.service.utils.resResult(STATUS.SUCCESS, { list, total })
}
public async createHero(uids: Array<string>, _hid: string, _hlv: string) {
const { ctx } = this;
console.log('gm createHero', uids, _hid, _hlv);
let hlv = parseInt(_hlv);
if (isNaN(hlv)) return ctx.service.utils.resResult(STATUS.WRONG_PARMS);
let hids = (_hid as string).split('&').map(cur => parseInt(cur));
for (let hid of hids) {
if (isNaN(hid)) return ctx.service.utils.resResult(STATUS.WRONG_PARMS);
}
// public async createHero(uids: Array<string>, _hid: string, _hlv: string) {
// const { ctx } = this;
// console.log('gm createHero', uids, _hid, _hlv);
// let hlv = parseInt(_hlv);
// if (isNaN(hlv)) return ctx.service.utils.resResult(STATUS.WRONG_PARMS);
// let hids = (_hid as string).split('&').map(cur => parseInt(cur));
// for (let hid of hids) {
// if (isNaN(hid)) return ctx.service.utils.resResult(STATUS.WRONG_PARMS);
// }
for (let roleId of uids) {
let role = await RoleModel.findByRoleId(roleId);
if (role) {
let heroInfos = new Map();
for (let hid of hids) {
let heroInfo = ctx.service.utils.getInitHeroById(hid);
heroInfos.set(hid, {...heroInfo});
}
// for (let roleId of uids) {
// let role = await RoleModel.findByRoleId(roleId);
// if (role) {
// let heroInfos = new Map();
// for (let hid of hids) {
// let heroInfo = ctx.service.utils.getInitHeroById(hid);
// heroInfos.set(hid, {...heroInfo});
// }
let createHero = new CreateHeroes(roleId, role.roleName, role.serverId);
await createHero.createWithHeroInfo(heroInfos);
// let createHero = new CreateHeroes(roleId, role.roleName, role.serverId);
// await createHero.createWithHeroInfo(heroInfos);
} else {
return ctx.service.utils.resResult(STATUS.GM_CREATE_ERROR, null, '未找到角色' + roleId)
}
}
// } else {
// return ctx.service.utils.resResult(STATUS.GM_CREATE_ERROR, null, '未找到角色' + roleId)
// }
// }
return ctx.service.utils.resResult(STATUS.SUCCESS, { uids });
}
// return ctx.service.utils.resResult(STATUS.SUCCESS, { uids });
// }
public async createItem(uids: Array<string>, _itemid: string, _itemcount: string) {
const { ctx } = this;
console.log('gm createItem', uids, _itemid, _itemcount);
let itemids = (_itemid as string).split('&').map(cur => parseInt(cur));
for (let itemid of itemids) {
if (isNaN(itemid)) return ctx.service.utils.resResult(STATUS.WRONG_PARMS);
}
let itemcount = parseInt(_itemcount);
if (isNaN(itemcount)) return ctx.service.utils.resResult(STATUS.WRONG_PARMS);
// public async createItem(uids: Array<string>, _itemid: string, _itemcount: string) {
// const { ctx } = this;
// console.log('gm createItem', uids, _itemid, _itemcount);
// let itemids = (_itemid as string).split('&').map(cur => parseInt(cur));
// for (let itemid of itemids) {
// if (isNaN(itemid)) return ctx.service.utils.resResult(STATUS.WRONG_PARMS);
// }
// let itemcount = parseInt(_itemcount);
// if (isNaN(itemcount)) return ctx.service.utils.resResult(STATUS.WRONG_PARMS);
let flag = 0, msg = '创建失败';
let datas: {id: number, count: number }[] = []
for (let itemid of itemids) {
let dicGoods = gameData.goods.get(itemid);
let itidObj = ITID.get(dicGoods.itid);
// let flag = 0, msg = '创建失败';
// let datas: {id: number, count: number }[] = []
// for (let itemid of itemids) {
// let dicGoods = gameData.goods.get(itemid);
// let itidObj = ITID.get(dicGoods.itid);
if (!dicGoods) {
flag = 1, msg = "未找到道具" + itemid;
} else if (!itidObj) {
flag = 1, msg = "未找到道具" + itemid;
} else {
datas.push({ id: itemid, count: itemcount });
}
}
if(flag == 0) {
for (let roleId of uids) {
let role = await RoleModel.findByRoleId(roleId);
if (role) {
await addBags(roleId, role.roleName, datas, ITEM_CHANGE_REASON.DEBUG);
} else {
flag = 1, msg = '未找到角色' + roleId;
}
}
}
// if (!dicGoods) {
// flag = 1, msg = "未找到道具" + itemid;
// } else if (!itidObj) {
// flag = 1, msg = "未找到道具" + itemid;
// } else {
// datas.push({ id: itemid, count: itemcount });
// }
// }
// if(flag == 0) {
// for (let roleId of uids) {
// let role = await RoleModel.findByRoleId(roleId);
// if (role) {
// await addBags(roleId, role.roleName, datas, ITEM_CHANGE_REASON.DEBUG);
// } else {
// flag = 1, msg = '未找到角色' + roleId;
// }
// }
// }
if (flag) {
return ctx.service.utils.resResult(STATUS.GM_CREATE_ERROR, null, msg);
} else {
return ctx.service.utils.resResult(STATUS.SUCCESS, { uids });
}
}
// if (flag) {
// return ctx.service.utils.resResult(STATUS.GM_CREATE_ERROR, null, msg);
// } else {
// return ctx.service.utils.resResult(STATUS.SUCCESS, { uids });
// }
// }
public async addGold(uids: Array<string>, _count: string) {
const { ctx } = this;
console.log('gm addGold', uids, _count);
let count = parseInt(_count);
if (isNaN(count)) return ctx.service.utils.resResult(STATUS.WRONG_PARMS);
for (let roleId of uids) {
await RoleModel.addGoldFree(roleId, count);
}
// public async addGold(uids: Array<string>, _count: string) {
// const { ctx } = this;
// console.log('gm addGold', uids, _count);
// let count = parseInt(_count);
// if (isNaN(count)) return ctx.service.utils.resResult(STATUS.WRONG_PARMS);
// for (let roleId of uids) {
// await RoleModel.addGoldFree(roleId, count);
// }
return ctx.service.utils.resResult(STATUS.SUCCESS, { uids });
}
// return ctx.service.utils.resResult(STATUS.SUCCESS, { uids });
// }
public async addCoin(uids: Array<string>, _count: string) {
const { ctx } = this;
console.log('gm addCoin', uids, _count);
let count = parseInt(_count);
if (isNaN(count)) return ctx.service.utils.resResult(STATUS.WRONG_PARMS);
for (let roleId of uids) {
await RoleModel.addCoin(roleId, count);
}
// public async addCoin(uids: Array<string>, _count: string) {
// const { ctx } = this;
// console.log('gm addCoin', uids, _count);
// let count = parseInt(_count);
// if (isNaN(count)) return ctx.service.utils.resResult(STATUS.WRONG_PARMS);
// for (let roleId of uids) {
// await RoleModel.addCoin(roleId, count);
// }
return ctx.service.utils.resResult(STATUS.SUCCESS, { uids });
}
public async addSkin(uids: Array<string>, _id: string) {
const { ctx } = this;
console.log('gm addSkin', uids, _id);
let id = parseInt(_id);
if (isNaN(id)) return ctx.service.utils.resResult(STATUS.WRONG_PARMS);
for (let roleId of uids) {
let role = await RoleModel.findByRoleId(roleId);
await addSkin(roleId, role.roleName, id, false);
}
// return ctx.service.utils.resResult(STATUS.SUCCESS, { uids });
// }
// public async addSkin(uids: Array<string>, _id: string) {
// const { ctx } = this;
// console.log('gm addSkin', uids, _id);
// let id = parseInt(_id);
// if (isNaN(id)) return ctx.service.utils.resResult(STATUS.WRONG_PARMS);
// for (let roleId of uids) {
// let role = await RoleModel.findByRoleId(roleId);
// await addSkin(roleId, role.roleName, id, false);
// }
return ctx.service.utils.resResult(STATUS.SUCCESS, { uids });
}
// return ctx.service.utils.resResult(STATUS.SUCCESS, { uids });
// }
public async levelUp(uids: Array<string>, _lv: string) {
const { ctx } = this;
console.log('gm levelUp', uids, _lv);
let lv = parseInt(_lv);
if (isNaN(lv)) return ctx.service.utils.resResult(STATUS.WRONG_PARMS);
for (let roleId of uids) {
let exp = getExpByLv(lv - 1);
await RoleModel.levelup(roleId, lv, exp ? exp.sum : 0);
}
// public async levelUp(uids: Array<string>, _lv: string) {
// const { ctx } = this;
// console.log('gm levelUp', uids, _lv);
// let lv = parseInt(_lv);
// if (isNaN(lv)) return ctx.service.utils.resResult(STATUS.WRONG_PARMS);
// for (let roleId of uids) {
// let exp = getExpByLv(lv - 1);
// await RoleModel.levelup(roleId, lv, exp ? exp.sum : 0);
// }
return ctx.service.utils.resResult(STATUS.SUCCESS, { uids });
}
// return ctx.service.utils.resResult(STATUS.SUCCESS, { uids });
// }
// public async getHeroList(roleId: string) {
// const {ctx} = this;

View File

@@ -3,7 +3,7 @@ import { WoodenHorse } from "./battleField/guildActivity";
import { RoleUpdate, RoleType } from "../db/Role";
import { reduceCe } from "../pubUtils/util";
import { GuildUpdateParam } from "../db/Guild";
import { HeroType, } from "../db/Hero";
import { HeroUpdate, } from "../db/Hero";
import { getSeconds } from "../pubUtils/timeUtil";
import { prop } from "@typegoose/typegoose";
import { pick } from "underscore";
@@ -119,7 +119,7 @@ export class LineupParam {
@prop({ required: true })
job: number;
constructor(hero: HeroType) {
constructor(hero: HeroUpdate) {
this.hid = hero.hid;
this.skinId = hero.skinId;
this.star = hero.star;

View File

@@ -1,19 +1,7 @@
import { DEFAULT_HERO_LV, FIGURE_UNLOCK_CONDITION, ITEM_CHANGE_REASON, LINEUP_NUM, REDIS_KEY, STATUS, TASK_TYPE } from "../consts";
import { SkinModel } from "../db/Skin";
import { DEFAULT_HEROES, HERO_SYSTEM_TYPE } from "../consts";
import { HeroModel, HeroSkin, HeroType, HeroUpdate } from "../db/Hero";
import { RoleModel, RoleType, RoleUpdate } from "../db/Role";
import { SkinUpdate } from "../db/Skin";
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, unlockFigureWithoutSave } from './itemUtils';
import { TaskListReturn } from "../domain/roleField/task";
import { nowSeconds } from "./timeUtil";
import { reduceCe, resResult } from "./util";
import { calculatetopLineup, } from "./playerCe";
import { GuildModel, GuildType } from "../db/Guild";
import { HeroModel } from "../db/Hero";
import { RoleModel } from "../db/Role";
import { GuildModel } from "../db/Guild";
import { PvpDefenseModel } from "../db/PvpDefense";
import { ActionPointModel } from '../db/ActionPoint';
import { BattleDropModel } from '../db/BattleDrop';
@@ -94,277 +82,8 @@ import { UserTaskHistoryModel } from '../db/UserTaskHistory';
import { UserTaskRecModel } from '../db/UserTaskRec';
import { WishPoolReportModel } from '../db/WishPoolReport';
import { pick } from "underscore";
import { HeroShowParam } from '../domain/roleField/hero';
import { saveCeChangeLog } from "./logUtil";
import { ActivityInRemote } from "../domain/activityField/activityField";
import { AttributeCal } from "../domain/roleField/attribute";
import { JewelModel } from "../db/Jewel";
// 储存在内存中的初始数据
export function getInitRoleInfo() {
let topLineup: TopHero[] = [], topLineupCe = 0, allCe = 0,
heroes: HeroUpdate[] = [], initHeroes: HeroUpdate[] = [], initSkins: SkinUpdate[] = [], heroNum = 0,
conditions: {type: FIGURE_UNLOCK_CONDITION, paramHid: number }[] = [];
let role = new RoleModel();
let calRoleCe = new CalRoleCe(role);
let roleAttr = calRoleCe.cal(HERO_SYSTEM_TYPE.INIT);
for(let { actorId: hid } of gameData.recruit) {
let { quality, initialStars: star, jobid: job, name: hName, initialSkin } = gameData.hero.get(hid);
// 皮肤
let skin = new SkinModel();
let dicFashion = gameData.fashion.get(initialSkin);
if(!dicFashion) {
console.log(`not found skin: ${initialSkin} of ${hid}`);
continue;
}
let skinInfo = { ...skin.toJSON(), id: initialSkin, hid, skinName: dicFashion.name, skinId: dicFashion.heroId };
initSkins.push(skinInfo);
// 武将
let hero = new HeroModel();
let heroInfo = {...hero.toJSON(), hid, star, quality, hName, job, skins: [{ id: initialSkin, skin: skinInfo._id, enable: true, skinId: skinInfo.skinId }], skinId: skinInfo.skinId, lv: DEFAULT_HERO_LV, exp: getHeroExpByLv(DEFAULT_HERO_LV - 1) || 0 };
let calHeroCe = new CalHeroCe(hid, heroInfo);
let heroAttr = calHeroCe.cal(HERO_SYSTEM_TYPE.INIT);
let ce = calHeroCe.getCalculatedCe(roleAttr);
heroes.push({ ...heroInfo, attr: heroAttr, ce, historyCe: ce });
// 更新role表
if(DEFAULT_HEROES.includes(hid)) {
// 头像
conditions.push({ type: FIGURE_UNLOCK_CONDITION.GET_HERO, paramHid: hid });
allCe += ce;
heroNum++;
initHeroes.push({ ...heroInfo, attr: heroAttr, ce, historyCe: ce });
}
}
let { figureInfo, heads, frames, spines } = unlockFigureWithoutSave(conditions, role);
// 最强阵容
initHeroes.sort((a, b) => { return b.ce - a.ce });
for(let i = 0; i < LINEUP_NUM; i++) {
if(initHeroes[i]) {
let { hid, ce, _id } = initHeroes[i];
topLineup.push({ hid, ce, hero: _id });
topLineupCe += ce;
}
}
let initRole: RoleUpdate = { topLineupCe, topLineup, attr: roleAttr, ce: allCe, heroNum, heroNumUpdatedAt: Date.now(), heads, frames, spines };
return {
role: initRole, heroes, skins: initSkins, figureInfo
}
}
export class UpdateHeroes {
roleId: string;
roleName: string;
serverId: number;
incHeroNum: number = 0;
incRoleCe: number = 0;
pushHeroes: {hid: number, incHeroCe: number, ce: number, hero: HeroUpdate}[] = [];
roleUpdate: RoleUpdate;
role: RoleType;
guild: GuildType;
constructor(roleId: string, roleName: string, serverId: number) {
this.roleId = roleId;
this.roleName = roleName;
this.serverId = serverId;
}
public setRole(role: RoleType) {
this.role = role;
}
public async getRole() {
if(!this.role) {
this.role = await RoleModel.findByRoleId(this.roleId);
}
return this.role;
}
public addRoleUpdateParam(param: RoleUpdate) {
this.roleUpdate = {...this.roleUpdate, ...param};
}
public async updateDbCe(isCreate: boolean, heroInfo: HeroUpdate, originCe = 0) {
let role = await this.getRole();
if(isCreate) this.incHeroNum ++;
if(heroInfo != originCe) this.incRoleCe += heroInfo.ce - originCe;
this.addRoleUpdateParam(await calculatetopLineup(role, heroInfo.hid, heroInfo.ce, heroInfo._id ));
this.pushHeroes.push({ hid: heroInfo.hid, incHeroCe: heroInfo.ce - originCe, ce: heroInfo.ce, hero: heroInfo });
}
// 更新战力相关的各个表
public async saveCeToDb() {
let role = await this.getRole();
// 更新role表
this.role = await RoleModel.updateRoleInfo(this.roleId, {
heroNum: this.incHeroNum + role.heroNum, ce: this.incRoleCe + role.ce, heroNumUpdatedAt: nowSeconds(), ...this.roleUpdate
});
// 更新guild表
if(role.hasGuild) {
this.guild = await GuildModel.updateCe(this.roleId, this.incRoleCe, true); // 公会更新战力
}
for(let { hid, incHeroCe } of this.pushHeroes) {
await PvpDefenseModel.updateCe(this.roleId, hid, incHeroCe); // 更新pvp防守阵战力
}
saveCeChangeLog(this.role, this.incRoleCe, this.role.ce, HERO_SYSTEM_TYPE.INIT, this.pushHeroes.map(cur => cur.hid));
}
public async updateRedisRank(Rank: any) {
let role = await this.getRole();
let { serverId, roleId, pushHeroes } = this;
// 更新军团信息
if(this.guild) {
let r = new Rank(REDIS_KEY.GUILD_INFO, { code: this.guild.code });
await r.generParamAndSet(REDIS_KEY.GUILD_INFO, { guildCode: this.guild.code }, { guild: this.guild });
}
// 武将数量
if(this.incHeroNum > 0) {
let r = new Rank(REDIS_KEY.HERO_NUM_RANK, { serverId });
await r.setRankWithRoleInfo(roleId, role.heroNum, role.heroNumUpdatedAt, role);
}
// 最强阵容
let r = new Rank(REDIS_KEY.TOP_LINEUP_RANK, { serverId });
await r.setRankWithRoleInfo(roleId, reduceCe(role.topLineupCe), 0, role);
// 最强武将
for(let { hid, ce, hero } of pushHeroes) {
let r2 = new Rank(REDIS_KEY.TOP_HERO_RANK, { serverId });
await r2.setRankWithHeroInfo(roleId, hid, reduceCe(ce), 0, hero);
let r4 = new Rank(REDIS_KEY.HERO_RANK, { serverId, hid });
await r4.setRankWithHeroInfo(roleId, hid, reduceCe(ce), 0, hero);
}
// 总战力
let r3 = new Rank(REDIS_KEY.SUM_CE_RANK, { serverId });
await r3.setRankWithRoleInfo(roleId, reduceCe(role.ce), 0, role);
// 更新最强五人阵容信息
let r5 = new Rank(REDIS_KEY.TOP_LINEUP_INFO, { serverId });
await r5.generParamAndSet(REDIS_KEY.TOP_LINEUP_INFO, { roleId }, { role });
}
public async pushMessage(pinus: any, sid: string) {
let role = await this.getRole();
let uids = [{ uid: this.roleId, sid }];
pinus.app.get('channelService').pushMessageByUids('onPlayerCeUpdate', resResult(STATUS.SUCCESS, { ce: reduceCe(role.ce) , heros: this.pushHeroes.map(cur => { return {...cur, ce: reduceCe(cur.ce), incHeroCe: reduceCe(cur.incHeroCe) }}), topLineupCe: reduceCe(role.topLineupCe) }), uids);
}
}
export class CreateHeroes extends UpdateHeroes {
private resultHeroes: HeroType[] = [];
private heroNum = 0;
// 推送信息
private taskPushMessage: TaskListReturn[] = [];
private activityTaskPushMessage = [];
private figureInfos: { heads: Figure[], frames: Figure[], spines: Figure[] }[] = [];
private skinPushMessages: { heros: {skins: HeroSkin[], hid: number}[], skins: {id: number, hid: number, inc: number, reason: number }[]} = { heros: [], skins: [] };
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]);
let skinInfos = skin.map(cur => ({ id: cur.id, hid, inc: 1, reason: ITEM_CHANGE_REASON.GET_HERO_UNLOCK_SKIN}))
this.skinPushMessages.skins.push(...skinInfos);
if(skin) allSkins.push(...skin);
let skins: { id: number, skin: string, enable: boolean, skinId: number }[] = [];
for(let skin of allSkins) {
skins.push({ id: skin.id, skin: skin._id, enable: skin.id == initSkinInfo.id, skinId: skin.skinId });
}
return skins
}
// game-server里面创建武将
public async createWithHeroInfo(infos: Map<number, { heroInfo: HeroUpdate, skinInfo: SkinUpdate }>) {
let role = await this.getRole();
// 数据处理
let conditions = new Array<{ type: number, paramHid?: number, paramFavourLv?: number, paramSkinId?: number }>(); // 解锁头像条件
let initHeroInfos: HeroUpdate[] = [];
for (let [ hid, { heroInfo, skinInfo }] of infos) {
conditions.push({ type: FIGURE_UNLOCK_CONDITION.GET_HERO, paramHid: heroInfo.hid });
this.updateDbCe(true, heroInfo);
// 皮肤使用初始加载进内存的数据
let skins = await this.getSkinsOfThisHero(hid, { ...skinInfo, _id: new SkinModel()._id }, false);
let newAttr = new AttributeCal();
newAttr.setLv(heroInfo.lv);
newAttr.setByDbData(role.attr, heroInfo.attr);
let heroCe = newAttr.calCe(); // 计算最终战力
initHeroInfos.push({ ...heroInfo, skins, _id: new HeroModel()._id, ce: heroCe });
this.heroNum ++;
}
// 武将使用初始加载数据插入
this.resultHeroes = await HeroModel.insertHeroes(this.roleId, this.roleName, this.serverId, initHeroInfos);
let heroSkins = this.resultHeroes.map(cur => { return pick(cur, ['hid', 'skins']) });
this.skinPushMessages.heros.push(...heroSkins);
// 头像解锁
let { figureInfo, frames, heads, spines } = unlockFigureWithoutSave(conditions, role);
this.figureInfos.push(figureInfo);
this.addRoleUpdateParam({ frames, heads, spines });
// 更新战力
await this.saveCeToDb();
}
// 创建初始账号时候的初始
public async createWithInitInfo(infos: Map<number, { heroInfo: HeroUpdate, skinInfo: SkinUpdate }>, figureInfo: { heads: Figure[], frames: Figure[], spines: Figure[] }) {
this.figureInfos.push(figureInfo);
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.heroNum ++;
}
this.resultHeroes = await HeroModel.insertHeroes(this.roleId, this.roleName, this.serverId, heroeInfos);
}
public async clearTask(activitiesTypeMap: ActivityInRemote[]) {
// 任务
// console.log('****** checkTask before', Date.now())
let m1 = await checkTask(this.roleId, TASK_TYPE.HERO_NUM, this.heroNum, true, {});
let m2 = await checkTaskWithHeroes(this.roleId, TASK_TYPE.HERO_QUALITY, this.resultHeroes);
let m3 = await checkTaskWithHeroes(this.roleId, TASK_TYPE.HERO_QUALITY_STAR_UP, this.resultHeroes);
let m4 = await checkTaskWithHeroes(this.roleId, TASK_TYPE.HERO_LV, this.resultHeroes);
this.taskPushMessage.push(...m1, ...m2, ...m3, ...m4);
// 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, 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);
}
public async pushMessage(pinus: any, sid: string) {
let role = await this.getRole();
let uids = [{ uid: this.roleId, sid }];
pinus.app.get('channelService').pushMessageByUids('onPlayerCeUpdate', resResult(STATUS.SUCCESS, { ce: reduceCe(role.ce) , heros: this.pushHeroes.map(cur => { return {...cur, ce: reduceCe(cur.ce), incHeroCe: reduceCe(cur.incHeroCe) }}), topLineupCe: reduceCe(role.topLineupCe) }), uids);
pinus.app.get('channelService').pushMessageByUids('onTaskUpdate', resResult(STATUS.SUCCESS, this.taskPushMessage), uids);
pinus.app.get('channelService').pushMessageByUids('onActivityTaskUpdate', resResult(STATUS.SUCCESS, this.activityTaskPushMessage), uids);
let figureInfo = combineFigureInfo(this.figureInfos);
if (!!figureInfo && (figureInfo.heads.length > 0 || figureInfo.frames.length > 0 || figureInfo.spines.length > 0)) {
pinus.app.get('channelService').pushMessageByUids('onHeadChange', resResult(STATUS.SUCCESS, { ...figureInfo }), uids);
}
pinus.app.get('channelService').pushMessageByUids('onHeroSkinChange', resResult(STATUS.SUCCESS, this.skinPushMessages), uids);
pinus.app.get('channelService').pushMessageByUids('onHeroUpdate', resResult(STATUS.SUCCESS, { heroes: this.getResultHeroes() }), uids);
}
public getResultHeroes() {
return this.resultHeroes.map(cur => ({...cur, ce: reduceCe(cur.ce)}))
}
public getShowHeroes() {
return this.resultHeroes.map(cur => {
let hero = new HeroShowParam(cur);
return { ...hero, ce: reduceCe(cur.ce)}
});
}
}
export async function deletRole(roleId: string) {
let role = await RoleModel.findByRoleId(roleId);
if(!role ) return false;

View File

@@ -634,7 +634,7 @@ export async function accomplishTask(serverId: number, roleId: string, taskType:
let dicTaskType = gameData.taskDescByType.get(taskType);
let pushMessage = [];
let serverInfo = await ServerlistModel.findByServerId(serverId);
if (!serverInfo) return;
if (!serverInfo) return [];
let { activityGroupId } = serverInfo;
let findActivitiesByTypes = async (types: number[]) => {
if(activities) {