/** * 体力系统 */ import { ActionPointModel } from '../db/ActionPoint'; import { ACTION_POIN } from '../consts/consts'; import { ChannelService, pinus } from 'pinus'; import { STATUS } from '../consts/statusCode'; import {resResult } from '../pubUtils/util'; import {HeroModel} from '../db/Hero'; import {RoleModel} from '../db/Role'; //战力计算TODO export function calPlayerCe(hero:any) { let ce = 0; return ce; } //修改并下发战力 export async function calPlayerCeAndSave(sid: string, roleId: string, heros:Array) { let playerCe = 0; let pushHeros = []; for (let hero of heros) { hero.ce = calPlayerCe(hero); playerCe = playerCe + hero.ce; hero = await HeroModel.updateHeroInfo(roleId, hero.hid, hero); pushHeros.push({ hid: hero.hid, ce: hero.ce }); } let role = await RoleModel.findByRoleId(roleId); role.ce = playerCe; await RoleModel.updateRoleInfo(roleId, role); //下发战力 let uids = [{uid: roleId, sid}]; pinus.app.get('channelService').pushMessageByUids('onPlayerCeUpdate', resResult(STATUS.SUCCESS, {ce: playerCe, heros:pushHeros, topFiveCe:0}), uids); return heros; }