战力方法

This commit is contained in:
mamengke01
2020-12-11 15:48:37 +08:00
parent 6c88fda867
commit 8d53a9b32d

View File

@@ -4,24 +4,28 @@
import { ActionPointModel } from '../db/ActionPoint'; import { ActionPointModel } from '../db/ActionPoint';
import { ACTION_POIN } from '../consts/consts'; import { ACTION_POIN } from '../consts/consts';
import { ChannelService, pinus } from 'pinus'; import { pinus } from 'pinus';
import { STATUS } from '../consts/statusCode'; import { STATUS } from '../consts/statusCode';
import {resResult } from '../pubUtils/util'; import {resResult } from '../pubUtils/util';
import {HeroModel} from '../db/Hero'; import {HeroModel} from '../db/Hero';
import {RoleModel} from '../db/Role'; import {RoleModel} from '../db/Role';
//战力计算TODO //战力计算TODO
export function calPlayerCe(hero:any) { export function calPlayerCe(hero:any, type: number, args: Array<{id: number}>) {
let ce = 0; let ce = 0;
let incCe;
if (type == 1) {
incCe = calHeroStarIncCe(hero, args);
}
return ce; return ce;
} }
//修改并下发战力 //修改并下发战力
export async function calPlayerCeAndSave(sid: string, roleId: string, heros:Array<any>) { export async function calPlayerCeAndSave(sid: string, roleId: string, heros:Array<any>, type?: number, args?: Array<{id: number}>) {
let playerCe = 0; let playerCe = 0;
let pushHeros = []; let pushHeros = [];
for (let hero of heros) { for (let hero of heros) {
hero.ce = calPlayerCe(hero); hero.ce = calPlayerCe(hero, type, args);
playerCe = playerCe + hero.ce; playerCe = playerCe + hero.ce;
await hero.save(); await hero.save();
pushHeros.push({ pushHeros.push({
@@ -37,3 +41,8 @@ export async function calPlayerCeAndSave(sid: string, roleId: string, heros:Arra
pinus.app.get('channelService').pushMessageByUids('onPlayerCeUpdate', resResult(STATUS.SUCCESS, {ce: playerCe, heros:pushHeros, topFiveCe:0}), uids); pinus.app.get('channelService').pushMessageByUids('onPlayerCeUpdate', resResult(STATUS.SUCCESS, {ce: playerCe, heros:pushHeros, topFiveCe:0}), uids);
return heros; return heros;
} }
export function calHeroStarIncCe (hero:any, args: Array<{id: number}>) {
let incCe = 0;
return {incCe};//属性增量可以是多个
}