属性: fix缩小战力倍数

This commit is contained in:
luying
2021-03-04 15:33:25 +08:00
parent a0e87a9513
commit 2a684d1860
4 changed files with 38 additions and 14 deletions
+6 -4
View File
@@ -494,9 +494,10 @@ export async function findPvpDefAllByRoleId(roleId: string) {
export function getRobotAttribute(attribute: {id: number, val: number}[], ce: number, enemyCe: number, ratio: number) { export function getRobotAttribute(attribute: {id: number, val: number}[], ce: number, enemyCe: number, ratio: number) {
let newAttribute = new Attribute(); 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 ceAttr hero表的ceAttr
* @param globalCeAttr role表中的globalCeAttr * @param globalCeAttr role表中的globalCeAttr
*/ */
export function getPlayerAttribute(heroAttrs: CeAttrData[], roleAttrs: CeAttrDataRole[]) { export function getPlayerAttribute(heroAttrs: CeAttrData[] = [], roleAttrs: CeAttrDataRole[] = []) {
let newAttribute = new Attribute(); let newAttribute = new Attribute();
newAttribute.setByDbData(roleAttrs, heroAttrs); newAttribute.setByDbData(roleAttrs, heroAttrs);
let attrJson = newAttribute.getReduceAttributes();
return newAttribute; return attrJson;
} }
/** /**
+3 -3
View File
@@ -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', 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', HANDLE_APPLY = 'roleId friendCnt lv',
ATTR = 'globalCeAttr', ATTR = 'attr',
GET_LV = 'lv', GET_LV = 'lv',
GET_ROLE_ID = 'roleId', GET_ROLE_ID = 'roleId',
GET_MY_SERVER = 'lv serverId userInfo.serverType', GET_MY_SERVER = 'lv serverId userInfo.serverType',
@@ -15,8 +15,8 @@ export enum ROLE_SELECT {
}; };
export enum HERO_SELECT { export enum HERO_SELECT {
ENTRY = '-ceAttr', ENTRY = '-attr',
HERO_DETAIL = 'roleId roleName hid hName ce lv star colorStar quality job skins ceAttr' HERO_DETAIL = 'roleId roleName hid hName ce lv star colorStar quality job skins attr'
} }
export enum EQUIP_SELECT { export enum EQUIP_SELECT {
+26 -5
View File
@@ -1,5 +1,6 @@
import { prop } from '@typegoose/typegoose'; import { prop } from '@typegoose/typegoose';
import { HERO_CE_RATIO, getAtrrNameById, CE_CONST, HERO_SUB_ATTR_RATIO } from '../../consts'; import { HERO_CE_RATIO, getAtrrNameById, CE_CONST, HERO_SUB_ATTR_RATIO } from '../../consts';
import { reduceCe } from '../../pubUtils/util';
// hero表内属性基础格式 // hero表内属性基础格式
export class CeAttrData { export class CeAttrData {
@@ -107,7 +108,7 @@ export class Attribute {
setByWarJson( attributes: {id: number, val: number}[], ratio: number = 1) { setByWarJson( attributes: {id: number, val: number}[], ratio: number = 1) {
for(let {id, val} of attributes) { for(let {id, val} of attributes) {
let attrName = getAtrrNameById(id); 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 ); return (heroFix + heroEquip + roleFix) * HERO_CE_RATIO + heroBase * ( HERO_CE_RATIO + heroRatio + roleRatio );
} }
private setSubAttrRatio() { private getRealSubAttr() {
return { return {
hit: this.hit / HERO_SUB_ATTR_RATIO / HERO_CE_RATIO / HERO_CE_RATIO, 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, 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 { return {
hp: this.hp / HERO_CE_RATIO / HERO_CE_RATIO, hp: this.hp / HERO_CE_RATIO / HERO_CE_RATIO,
atk: this.atk / 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() { public calCe() {
let { hp, atk, def, mdef } = this.setMainAttrRatio(); let { hp, atk, def, mdef } = this.getRealMainAttr();
let { cri, flee, damageIncrease, damageDecrease, damageCri } = this.setSubAttrRatio(); let { cri, flee, damageIncrease, damageDecrease, damageCri } = this.getRealSubAttr();
let putHit = CE_CONST.PUT_HIT / HERO_SUB_ATTR_RATIO; let putHit = CE_CONST.PUT_HIT / HERO_SUB_ATTR_RATIO;
let putAntCri = CE_CONST.PUT_ANT_CRI / HERO_SUB_ATTR_RATIO; let putAntCri = CE_CONST.PUT_ANT_CRI / HERO_SUB_ATTR_RATIO;
+3 -2
View File
@@ -213,8 +213,9 @@ export function getBossHpByWarId(warId: number) {
warInfo.forEach(hero => { warInfo.forEach(hero => {
let { attribute, dataId, relation, actorId } = hero; let { attribute, dataId, relation, actorId } = hero;
if (relation === 2) { if (relation === 2) {
let attrJson = new Attribute(); let newAttr = new Attribute();
attrJson.setByWarJson(attribute, 1); newAttr.setByWarJson(attribute, 1);
let attrJson = newAttr.getReduceAttributes();
const hp = attrJson.hp||0; const hp = attrJson.hp||0;
if (hp > 0) { if (hp > 0) {