From bcaad8698cab214cf7b7cce45f24815f149d9cd7 Mon Sep 17 00:00:00 2001 From: mamengke01 <794347210@qq.com> Date: Wed, 9 Dec 2020 14:54:36 +0800 Subject: [PATCH] =?UTF-8?q?=E6=88=98=E5=8A=9B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- game-server/app/services/playerCeService.ts | 39 +++++++++++++++++++++ 1 file changed, 39 insertions(+) create mode 100644 game-server/app/services/playerCeService.ts diff --git a/game-server/app/services/playerCeService.ts b/game-server/app/services/playerCeService.ts new file mode 100644 index 000000000..a6d9e405d --- /dev/null +++ b/game-server/app/services/playerCeService.ts @@ -0,0 +1,39 @@ +/** + * 体力系统 + */ + +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 {updateHeroInfo} from '../db/Hero'; +import {findByRoleId, updateRoleInfo} from '../db/Role'; +import { forEach } from 'pinus-robot/lib/common/util'; +//战力计算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 updateHeroInfo(roleId, hero.hid, hero); + pushHeros.push({ + hid: hero.hid, + ce: hero.ce + }); + } + let role = await findByRoleId(roleId); + role.ce = playerCe; + await 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; +}