解析修改:playerCeService

This commit is contained in:
luying
2020-12-15 19:54:32 +08:00
parent 9fe95f2a4e
commit 7f256c996e
8 changed files with 89 additions and 193 deletions
+44 -43
View File
@@ -7,18 +7,19 @@ import { pinus } from 'pinus';
import { STATUS } from '../consts/statusCode';
import { resResult, deepCopy } from '../pubUtils/util';
import Hero from '../db/Hero';
import { HeroModel, HeroType } from '../db/Hero';
import { RoleModel } from '../db/Role';
import { CeAttrData, CeAttr } from '../db/generalField';
import { getFashionsById, getJobInfoById, getJobByGradeAndClass, getHeroInfoById, getHeroStar, getHeroWake, getFiendShipLevel, getFriendShipById, getHeroSkillById, getSeidById } from '../pubUtils/gamedata';
import { getAttrNameByJobStage, getAttrCeRatio, getAtrrNameById, ABI_TYPE_TO_STAGE, ABI_STAGE, SEID_TYPE, HERO_ATTR} from '../consts';
import { gameData, getJobByGradeAndClass, getHeroWakeByQuality, getHeroStarByQuality, getFriendShipById } from '../pubUtils/data';
import { Attributes } from '../pubUtils/interface';
const HERO_CE_RATIO = 100;
const _ = require('underscore');
//战力计算TODO
export function calPlayerCe(hero: any, type: number, args: Array<number>) {
export function calPlayerCe(hero: HeroType, type: number, args: Array<number>) {
let incCe = 0;
let incArr = {};
let reIncAttr = {}; // {"hp": {"base": number, "fixUp": number, "ratioUp": number}}
let incArr: Attributes = {};
let reIncAttr: CeAttr = {}; // {"hp": {"base": number, "fixUp": number, "ratioUp": number}}
let addSeidList = new Array<number>();
let removeSeidList = new Array<number>();
@@ -54,15 +55,15 @@ export function calPlayerCe(hero: any, type: number, args: Array<number>) {
}
//修改并下发战力
export async function calPlayerCeAndSave(sid: string, roleId: string, heros: Array<any>, type?: number, args?: Array<number>) {
export async function calPlayerCeAndSave(sid: string, roleId: string, heros: Array<HeroType>, type?: number, args?: Array<number>) {
let incPlayerCe = 0;
let pushHeros = [];
let pushHeros = new Array<{hid: number, ce: number, incHeroCe: number}>();
for (let hero of heros) {
let incHeroCe = calPlayerCe(hero, type, args);
incPlayerCe += incHeroCe;
await hero.save();
await HeroModel.updateHeroInfo(roleId, hero.hid, hero );
pushHeros.push({
hid: hero.hid,
ce: hero.ce,
@@ -78,10 +79,10 @@ export async function calPlayerCeAndSave(sid: string, roleId: string, heros: Arr
return heros;
}
export function calHeroStarIncAttr (hero: Hero, args: Array<number>, addSeidList: Array<number>, removeSeidList: Array<number>) {
export function calHeroStarIncAttr (hero: HeroType, args: Array<number>, addSeidList: Array<number>, removeSeidList: Array<number>) {
let {star, starStage, quality, colorStar, colorStarStage, ceAttr} = hero;
let res = {};
const dicHero = getHeroInfoById(hero.hid);
let res: CeAttr = {};
const dicHero = gameData.hero.get(hero.hid);
const isWake = colorStar > 0; // 是否觉醒,只要激活了觉醒,彩星就会 > 1
if(isWake) {
@@ -89,7 +90,7 @@ export function calHeroStarIncAttr (hero: Hero, args: Array<number>, addSeidList
} else {
if(starStage == ABI_STAGE.START) star = star -1;
}
const dicStar = isWake? getHeroWake(quality, colorStar): getHeroStar(quality, star); // 星级表
const dicStar = isWake? getHeroWakeByQuality(quality, colorStar): getHeroStarByQuality(quality, star); // 星级表
for(let stage of args) {
@@ -107,7 +108,7 @@ export function calHeroStarIncAttr (hero: Hero, args: Array<number>, addSeidList
// 解锁技能
if(dicHero.skill){
let {starSeidArr, colorStarSeidArr} = getHeroSkillById(dicHero.skill);
let {starSeidArr, colorStarSeidArr} = gameData.heroSkill.get(dicHero.skill);
if(isWake) {
for(let {star, value} of starSeidArr){
if(hero.star == star){
@@ -134,14 +135,14 @@ export function getAllAttrStage () {
return attrs;
}
//训练
export function calHeroTrainIncAttr(hero: any) {
let res = {};
export function calHeroTrainIncAttr(hero: HeroType) {
let res: CeAttr = {};
let attrName: string = getAttrNameByJobStage(hero.jobStage);
res[attrName] = {fixUp: hero.ceAttr[attrName].fixUp, base: hero.ceAttr[attrName].base, ratioUp: hero.ceAttr[attrName].ratioUp};
let currentJob = getJobInfoById(hero.job);
let currentJob = gameData.job.get(hero.job);
if (currentJob.grade > 1) {
let jobGradeAndClass = getJobByGradeAndClass(currentJob.job_class, currentJob.grade - 1);
let lastJob = getJobInfoById(jobGradeAndClass.jobid);
let lastJob = gameData.job.get(jobGradeAndClass.jobid);
res[attrName].fixUp += (currentJob[attrName] - lastJob[attrName]) * HERO_CE_RATIO;
} else {
res[attrName].fixUp += currentJob[attrName] * HERO_CE_RATIO;
@@ -149,13 +150,13 @@ export function calHeroTrainIncAttr(hero: any) {
return res;
}
//进阶
export function calHeroJobStageUpIncAttr(hero: any, args: Array<number>, addSeidList: Array<number>, removeSeidList: Array<number> ) {
let res = {};
let lastJob = getJobInfoById(args[0]);
let currentJob = getJobInfoById(hero.job);
addSeidList.concat(deepCopy(currentJob.seids));
for (let seid of lastJob.seids) {
let index = _.indexOf(currentJob.seids, seid);
export function calHeroJobStageUpIncAttr(hero: HeroType, args: Array<number>, addSeidList: Array<number>, removeSeidList: Array<number> ) {
let res: CeAttr = {};
let lastJob = gameData.job.get(args[0]);
let currentJob = gameData.job.get(hero.job);
addSeidList.concat(deepCopy(currentJob.seid));
for (let seid of lastJob.seid) {
let index = _.indexOf(currentJob.seid, seid);
if (index > 0) {
addSeidList.splice(index, 1);
} else {
@@ -165,17 +166,17 @@ export function calHeroJobStageUpIncAttr(hero: any, args: Array<number>, addSeid
return res;
}
//穿戴时装
export function calWaerHeroSkinIncAttr(hero: any, args: Array<number>) {
let res = {};
let addSkin = getFashionsById(args[0]);
let delSkin = getFashionsById(args[1]);
let attrName;
for (let attr of delSkin.actorAttrs) {
export function calWaerHeroSkinIncAttr(hero: HeroType, args: Array<number>) {
let res: CeAttr = {};
let addSkin = gameData.fashion.get(args[0]);
let delSkin = gameData.fashion.get(args[1]);
let attrName: string;
for (let attr of delSkin.actorAttr) {
attrName = getAtrrNameById(attr.id);
res[attrName] = {fixUp: hero.ceAttr[attrName].fixUp, base: hero.ceAttr[attrName].base, ratioUp: hero.ceAttr[attrName].ratioUp};
res[attrName].fixUp += attr.number * HERO_CE_RATIO;
}
for (let attr of addSkin.actorAttrs) {
for (let attr of addSkin.actorAttr) {
attrName = getAtrrNameById(attr.id);
res[attrName] = {fixUp: hero.ceAttr[attrName].fixUp, base: hero.ceAttr[attrName].base, ratioUp: hero.ceAttr[attrName].ratioUp};
res[attrName].fixUp -= attr.number * HERO_CE_RATIO;
@@ -184,12 +185,12 @@ export function calWaerHeroSkinIncAttr(hero: any, args: Array<number>) {
}
//羁绊解锁
export function calHeroConectIncAttr(hero: any, args: Array<number>) {
let res = {};
let fiendShipLevel = getFiendShipLevel(hero.favourLv);
export function calHeroConectIncAttr(hero: HeroType, args: Array<number>) {
let res: CeAttr = {};
let fiendShipLevel = gameData.friendShipLevelMap.get(hero.favourLv);
let shipId = args[0];//当前升级的羁绊序号
let level = args[1];//当前升级的羁绊等级
let attrName;
let attrName: string;
let currentShip = getFriendShipById(shipId, level);
for (let attr of currentShip.attributes) {
attrName = getAtrrNameById(attr.id);
@@ -208,15 +209,15 @@ export function calHeroConectIncAttr(hero: any, args: Array<number>) {
}
//好感升级
export function calHeroFavourUpIncAttr(hero: any, args: Array<number>) {
let res = {};
let currentFiendShipLevel = getFiendShipLevel(hero.favourLv);
export function calHeroFavourUpIncAttr(hero: HeroType, args: Array<number>) {
let res: CeAttr = {};
let currentFiendShipLevel = gameData.friendShipLevelMap.get(hero.favourLv);
let difAdd = currentFiendShipLevel.add;
if (!!args[0]) {
let lastFiendShipLevel = getFiendShipLevel(args[0]);
let lastFiendShipLevel = gameData.friendShipLevelMap.get(args[0]);
difAdd -= lastFiendShipLevel.add;
}
let attrName;
let attrName: string;
for (let connect of hero.connections) {
let heroShip = getFriendShipById(connect.shipId, connect.level);
for (let attr of heroShip.attributes) {
@@ -234,7 +235,7 @@ function getFieldByStage(stage: number, jobid: number) {
if(typeof targetAttrId === 'number') {
return targetAttrId
} else {
const dicJob = getJobInfoById(jobid);
const dicJob = gameData.job.get(jobid);
return targetAttrId(dicJob.type);
}
}
@@ -250,7 +251,7 @@ function addSeidEffect(reIncAttr: CeAttr, addSeidList: Array<number>, removeSeid
for(let {list, multi} of otiginalSeidList) {
let effectList = new Array<any>(); // any: dic_zyz_se表内容
for(let seid of list) {
let dicSeid = getSeidById(seid);
let dicSeid = gameData.se.get(seid);
if(dicSeid && dicSeid.id > 0){
addSeid(effectList, dicSeid.id, dicSeid.gainValueArr)
}
@@ -272,7 +273,7 @@ function addSeidEffect(reIncAttr: CeAttr, addSeidList: Array<number>, removeSeid
// 获取dic_zyz_se内容
function addSeid(effectList: Array<any>, seidId:number, seidValue = new Array<number>()){
// console.log('addSeidEffect', seidId, seidValue)
let curSeid = getSeidById(seidId);
let curSeid = gameData.se.get(seidId);
if(!curSeid) {console.log("seidId not found:"+seidId);return;}
if(!seidValue) seidValue = curSeid.gainValueArr;