diff --git a/game-server/app/services/pvpService.ts b/game-server/app/services/pvpService.ts index 61a0878f9..ea8e7ddc4 100644 --- a/game-server/app/services/pvpService.ts +++ b/game-server/app/services/pvpService.ts @@ -494,9 +494,10 @@ export async function findPvpDefAllByRoleId(roleId: string) { export function getRobotAttribute(attribute: {id: number, val: number}[], ce: number, enemyCe: number, ratio: number) { let newAttribute = new Attribute(); - newAttribute.setByWarJson(attribute, ce / enemyCe * ratio) + newAttribute.setByWarJson(attribute, ce / enemyCe * ratio); + let attrJson = newAttribute.getReduceAttributes(); - return newAttribute; + return attrJson; } /** @@ -504,11 +505,12 @@ export function getRobotAttribute(attribute: {id: number, val: number}[], ce: nu * @param ceAttr hero表的ceAttr * @param globalCeAttr role表中的globalCeAttr */ -export function getPlayerAttribute(heroAttrs: CeAttrData[], roleAttrs: CeAttrDataRole[]) { +export function getPlayerAttribute(heroAttrs: CeAttrData[] = [], roleAttrs: CeAttrDataRole[] = []) { let newAttribute = new Attribute(); newAttribute.setByDbData(roleAttrs, heroAttrs); + let attrJson = newAttribute.getReduceAttributes(); - return newAttribute; + return attrJson; } /** diff --git a/shared/consts/constModules/selectConst.ts b/shared/consts/constModules/selectConst.ts index fb9097071..1b854ddfd 100644 --- a/shared/consts/constModules/selectConst.ts +++ b/shared/consts/constModules/selectConst.ts @@ -7,7 +7,7 @@ export enum ROLE_SELECT { // 显示申请需要的信息 SHOW_FRIEND_APPLY_LIST = 'roleId roleName ce headHid sHid lv title job quitTime vLv guildName friendCnt recFrdApplyCnt serverId userInfo.serverType', HANDLE_APPLY = 'roleId friendCnt lv', - ATTR = 'globalCeAttr', + ATTR = 'attr', GET_LV = 'lv', GET_ROLE_ID = 'roleId', GET_MY_SERVER = 'lv serverId userInfo.serverType', @@ -15,8 +15,8 @@ export enum ROLE_SELECT { }; export enum HERO_SELECT { - ENTRY = '-ceAttr', - HERO_DETAIL = 'roleId roleName hid hName ce lv star colorStar quality job skins ceAttr' + ENTRY = '-attr', + HERO_DETAIL = 'roleId roleName hid hName ce lv star colorStar quality job skins attr' } export enum EQUIP_SELECT { diff --git a/shared/domain/roleField/attribute.ts b/shared/domain/roleField/attribute.ts index 3e3262cd4..7cbcd2e9d 100644 --- a/shared/domain/roleField/attribute.ts +++ b/shared/domain/roleField/attribute.ts @@ -1,5 +1,6 @@ import { prop } from '@typegoose/typegoose'; import { HERO_CE_RATIO, getAtrrNameById, CE_CONST, HERO_SUB_ATTR_RATIO } from '../../consts'; +import { reduceCe } from '../../pubUtils/util'; // hero表内属性基础格式 export class CeAttrData { @@ -107,7 +108,7 @@ export class Attribute { setByWarJson( attributes: {id: number, val: number}[], ratio: number = 1) { for(let {id, val} of attributes) { let attrName = getAtrrNameById(id); - if(attrName in this) this[attrName] = Math.floor(val * ratio); + if(attrName in this) this[attrName] = Math.floor(val * ratio * HERO_CE_RATIO * HERO_CE_RATIO); } } @@ -115,7 +116,7 @@ export class Attribute { return (heroFix + heroEquip + roleFix) * HERO_CE_RATIO + heroBase * ( HERO_CE_RATIO + heroRatio + roleRatio ); } - private setSubAttrRatio() { + private getRealSubAttr() { return { hit: this.hit / HERO_SUB_ATTR_RATIO / HERO_CE_RATIO / HERO_CE_RATIO, cri: this.cri / HERO_SUB_ATTR_RATIO / HERO_CE_RATIO / HERO_CE_RATIO, @@ -128,7 +129,7 @@ export class Attribute { } } - private setMainAttrRatio() { + private getRealMainAttr() { return { hp: this.hp / HERO_CE_RATIO / HERO_CE_RATIO, atk: this.atk / HERO_CE_RATIO / HERO_CE_RATIO, @@ -137,10 +138,30 @@ export class Attribute { } } + public getReduceAttributes() { + let newAttr = new Attribute(); + newAttr.hp = reduceCe(this.hp); + newAttr.atk = reduceCe(this.atk); + newAttr.def = reduceCe(this.def); + newAttr.mdef = reduceCe(this.mdef); + newAttr.speed = reduceCe(this.speed); + newAttr.hit = reduceCe(this.hit); + newAttr.cri = reduceCe(this.cri); + newAttr.flee = reduceCe(this.flee); + newAttr.antCri = reduceCe(this.antCri); + newAttr.damageIncrease = reduceCe(this.damageIncrease); + newAttr.damageDecrease = reduceCe(this.damageDecrease); + newAttr.defIngnore = reduceCe(this.defIngnore); + newAttr.bloodSuck = reduceCe(this.bloodSuck); + newAttr.ap = reduceCe(this.ap); + newAttr.damageCri = reduceCe(this.damageCri); + return newAttr; + } + // 战力计算 public calCe() { - let { hp, atk, def, mdef } = this.setMainAttrRatio(); - let { cri, flee, damageIncrease, damageDecrease, damageCri } = this.setSubAttrRatio(); + let { hp, atk, def, mdef } = this.getRealMainAttr(); + let { cri, flee, damageIncrease, damageDecrease, damageCri } = this.getRealSubAttr(); let putHit = CE_CONST.PUT_HIT / HERO_SUB_ATTR_RATIO; let putAntCri = CE_CONST.PUT_ANT_CRI / HERO_SUB_ATTR_RATIO; diff --git a/shared/pubUtils/data.ts b/shared/pubUtils/data.ts index fa688f42a..9be842513 100644 --- a/shared/pubUtils/data.ts +++ b/shared/pubUtils/data.ts @@ -213,8 +213,9 @@ export function getBossHpByWarId(warId: number) { warInfo.forEach(hero => { let { attribute, dataId, relation, actorId } = hero; if (relation === 2) { - let attrJson = new Attribute(); - attrJson.setByWarJson(attribute, 1); + let newAttr = new Attribute(); + newAttr.setByWarJson(attribute, 1); + let attrJson = newAttr.getReduceAttributes(); const hp = attrJson.hp||0; if (hp > 0) {