战力
This commit is contained in:
@@ -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<any>) {
|
||||||
|
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;
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user