修改playerCe为通用方法
This commit is contained in:
@@ -1,6 +1,6 @@
|
|||||||
import {Application, BackendSession, createTcpMailBox, ChannelService} from 'pinus';
|
import {Application, BackendSession, createTcpMailBox, ChannelService} from 'pinus';
|
||||||
import { handleCost, addItems } from '../../../services/rewardService';
|
import { handleCost, addItems } from '../../../services/rewardService';
|
||||||
import { calPlayerCeAndSave, getAllAttrStage } from '../../../pubUtils/playerCe';
|
import { calPlayerCeAndSave, getAllAttrStage } from '../../../services/playerCeService';
|
||||||
import { resResult } from '../../../pubUtils/util';
|
import { resResult } from '../../../pubUtils/util';
|
||||||
import { STATUS } from '../../../consts/statusCode';
|
import { STATUS } from '../../../consts/statusCode';
|
||||||
import {HeroModel} from '../../../db/Hero';
|
import {HeroModel} from '../../../db/Hero';
|
||||||
|
|||||||
@@ -0,0 +1,22 @@
|
|||||||
|
/**
|
||||||
|
* 体力系统
|
||||||
|
*/
|
||||||
|
|
||||||
|
import { pinus } from 'pinus';
|
||||||
|
import { STATUS } from '../consts/statusCode';
|
||||||
|
|
||||||
|
import { resResult } from '../pubUtils/util';
|
||||||
|
import { calPlayerCeAndSave as pubCalPlayerCeAndSave } from '../pubUtils/playerCe';
|
||||||
|
import { HeroType } from '../db/Hero';
|
||||||
|
const _ = require('underscore');
|
||||||
|
|
||||||
|
|
||||||
|
//修改并下发战力
|
||||||
|
export async function calPlayerCeAndSave(sid: string, roleId: string, heros: Array<HeroType>, type?: number, args?: Array<number>) {
|
||||||
|
let {role, pushHeros} = await pubCalPlayerCeAndSave(roleId, heros, type, args);
|
||||||
|
|
||||||
|
//下发战力
|
||||||
|
let uids = [{ uid: roleId, sid }];
|
||||||
|
pinus.app.get('channelService').pushMessageByUids('onPlayerCeUpdate', resResult(STATUS.SUCCESS, { ce: role.ce, heros: pushHeros, topFiveCe: 0 }), uids);
|
||||||
|
return heros;
|
||||||
|
}
|
||||||
@@ -1,6 +1,8 @@
|
|||||||
import { Service } from 'egg';
|
import { Service } from 'egg';
|
||||||
import * as pubUtils from '../pubUtils/util';
|
import * as pubUtils from '../pubUtils/util';
|
||||||
import * as pubGamedata from '../pubUtils/gamedata'
|
import * as pubGamedata from '../pubUtils/gamedata'
|
||||||
|
import { HeroType } from '@db/Hero';
|
||||||
|
import { calPlayerCeAndSave } from '@pubUtils/playerCe';
|
||||||
const csprng = require('csprng');
|
const csprng = require('csprng');
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -46,4 +48,8 @@ export default class Utils extends Service {
|
|||||||
public resResult(status: {code: number, simStr: string}, data?, customMsg?: string) {
|
public resResult(status: {code: number, simStr: string}, data?, customMsg?: string) {
|
||||||
return pubUtils.resResult(status, data, customMsg);
|
return pubUtils.resResult(status, data, customMsg);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public calPlayerCeAndSave(roleId: string, heros: HeroType[], type: number, args: number[]) {
|
||||||
|
return calPlayerCeAndSave(roleId, heros, type, args)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,10 +3,8 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
import { HERO_SYSTEM_TYPE } from '../consts';
|
import { HERO_SYSTEM_TYPE } from '../consts';
|
||||||
import { pinus } from 'pinus';
|
|
||||||
import { STATUS } from '../consts/statusCode';
|
|
||||||
|
|
||||||
import { resResult, deepCopy } from '../pubUtils/util';
|
import { deepCopy } from '../pubUtils/util';
|
||||||
import { HeroModel, HeroType } from '../db/Hero';
|
import { HeroModel, HeroType } from '../db/Hero';
|
||||||
import { RoleModel } from '../db/Role';
|
import { RoleModel } from '../db/Role';
|
||||||
import { CeAttrData, CeAttr } from '../db/generalField';
|
import { CeAttrData, CeAttr } from '../db/generalField';
|
||||||
@@ -26,7 +24,7 @@ export function calPlayerCe(hero: HeroType, type: number, args: Array<number>) {
|
|||||||
let removeSeidList = new Array<number>();
|
let removeSeidList = new Array<number>();
|
||||||
|
|
||||||
if (type == HERO_SYSTEM_TYPE.STAR) {
|
if (type == HERO_SYSTEM_TYPE.STAR) {
|
||||||
reIncAttr = calHeroStarIncAttr(hero, args, addSeidList, removeSeidList); // args: 升的星盘
|
reIncAttr = calHeroStarIncAttr(hero, args, addSeidList); // args: 升的星盘
|
||||||
} else if (type == HERO_SYSTEM_TYPE.TRAIN) {
|
} else if (type == HERO_SYSTEM_TYPE.TRAIN) {
|
||||||
reIncAttr = calHeroTrainIncAttr(hero);
|
reIncAttr = calHeroTrainIncAttr(hero);
|
||||||
} else if (type == HERO_SYSTEM_TYPE.STAGEUP) {
|
} else if (type == HERO_SYSTEM_TYPE.STAGEUP) {
|
||||||
@@ -56,7 +54,7 @@ export function calPlayerCe(hero: HeroType, type: number, args: Array<number>) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
//修改并下发战力
|
//修改并下发战力
|
||||||
export async function calPlayerCeAndSave(sid: string, roleId: string, heros: Array<HeroType>, type?: number, args?: Array<number>) {
|
export async function calPlayerCeAndSave(roleId: string, heros: Array<HeroType>, type?: number, args?: Array<number>) {
|
||||||
let incPlayerCe = 0;
|
let incPlayerCe = 0;
|
||||||
let pushHeros = new Array<{hid: number, ce: number, incHeroCe: number}>();
|
let pushHeros = new Array<{hid: number, ce: number, incHeroCe: number}>();
|
||||||
|
|
||||||
@@ -74,13 +72,10 @@ export async function calPlayerCeAndSave(sid: string, roleId: string, heros: Arr
|
|||||||
let role = await RoleModel.findByRoleId(roleId);
|
let role = await RoleModel.findByRoleId(roleId);
|
||||||
role.ce += incPlayerCe;
|
role.ce += incPlayerCe;
|
||||||
await RoleModel.updateRoleInfo(roleId, role);
|
await RoleModel.updateRoleInfo(roleId, role);
|
||||||
//下发战力
|
return {pushHeros, role}
|
||||||
let uids = [{ uid: roleId, sid }];
|
|
||||||
pinus.app.get('channelService').pushMessageByUids('onPlayerCeUpdate', resResult(STATUS.SUCCESS, { ce: role.ce, heros: pushHeros, topFiveCe: 0 }), uids);
|
|
||||||
return heros;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export function calHeroStarIncAttr (hero: HeroType, args: Array<number>, addSeidList: Array<number>, removeSeidList: Array<number>) {
|
export function calHeroStarIncAttr (hero: HeroType, args: Array<number>, addSeidList: Array<number>) {
|
||||||
let {star, starStage, quality, colorStar, colorStarStage, ceAttr} = hero;
|
let {star, starStage, quality, colorStar, colorStarStage, ceAttr} = hero;
|
||||||
let res: CeAttr = {};
|
let res: CeAttr = {};
|
||||||
const dicHero = gameData.hero.get(hero.hid);
|
const dicHero = gameData.hero.get(hero.hid);
|
||||||
|
|||||||
@@ -456,8 +456,9 @@ export function readJsonFile(fileName: string) {
|
|||||||
export function readWarJsonFileList() {
|
export function readWarJsonFileList() {
|
||||||
const folder = 'warJsons';
|
const folder = 'warJsons';
|
||||||
return fs.readdirSync(__dirname + `/../resource/${folder}`)
|
return fs.readdirSync(__dirname + `/../resource/${folder}`)
|
||||||
|
.filter(cur => {return cur.indexOf('.') != 0})
|
||||||
.map(file => {
|
.map(file => {
|
||||||
return fs.readFileSync(path.resolve(__dirname, `../resource/${folder}/${file}`)).toString('utf8').replace(/^\uFEFF/, '');
|
return fs.readFileSync(path.resolve(__dirname, `../resource/${folder}/${file}`)).toString('utf8');
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,7 @@
|
|||||||
import { Service } from 'egg';
|
import { Service } from 'egg';
|
||||||
import { resResult as pubResult } from '../pubUtils/util';
|
import { resResult as pubResult } from '../pubUtils/util';
|
||||||
|
import { calPlayerCeAndSave } from 'app/pubUtils/playerCe';
|
||||||
|
import { HeroType } from '@db/Hero';
|
||||||
const csprng = require('csprng');
|
const csprng = require('csprng');
|
||||||
/**
|
/**
|
||||||
* Utils Service
|
* Utils Service
|
||||||
@@ -39,4 +41,9 @@ export default class Utils extends Service {
|
|||||||
public resResult(status: {code: number, simStr: string}, data?, customMsg?: string) {
|
public resResult(status: {code: number, simStr: string}, data?, customMsg?: string) {
|
||||||
return pubResult(status, data, customMsg);
|
return pubResult(status, data, customMsg);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public calPlayerCeAndSave(roleId: string, heros: HeroType[], type: number, args: number[]) {
|
||||||
|
return calPlayerCeAndSave(roleId, heros, type, args)
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user