战力:计算
This commit is contained in:
@@ -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, ABI_TYPE_MAIN } from '../../consts';
|
import { HERO_CE_RATIO, getAtrrNameById, ABI_TYPE_MAIN } from '../../consts';
|
||||||
|
import { gameData } from '../../pubUtils/data';
|
||||||
import { decodeArrayListStr, reduceCe } from '../../pubUtils/util';
|
import { decodeArrayListStr, reduceCe } from '../../pubUtils/util';
|
||||||
|
|
||||||
// hero表内属性基础格式
|
// hero表内属性基础格式
|
||||||
@@ -84,17 +85,17 @@ export class AttributeCal {
|
|||||||
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 getRealAttrToMap() {
|
// private getRealAttrToMap() {
|
||||||
let newMap = new Map<number, number>();
|
// let newMap = new Map<number, number>();
|
||||||
for(let [id, val] of this.attrs) {
|
// for(let [id, val] of this.attrs) {
|
||||||
if(ABI_TYPE_MAIN.includes(id)) { // 主属性
|
// if(ABI_TYPE_MAIN.includes(id)) { // 主属性
|
||||||
newMap.set(id, val / HERO_CE_RATIO / HERO_CE_RATIO);
|
// newMap.set(id, val / HERO_CE_RATIO / HERO_CE_RATIO);
|
||||||
} else {
|
// } else {
|
||||||
newMap.set(id, val / HERO_SUB_ATTR_RATIO / HERO_CE_RATIO / HERO_CE_RATIO);
|
// newMap.set(id, val / HERO_SUB_ATTR_RATIO / HERO_CE_RATIO / HERO_CE_RATIO);
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
return newMap;
|
// return newMap;
|
||||||
}
|
// }
|
||||||
|
|
||||||
private getReduceAttrMap() {
|
private getReduceAttrMap() {
|
||||||
let newMap = new Map<number, number>();
|
let newMap = new Map<number, number>();
|
||||||
@@ -130,30 +131,11 @@ export class AttributeCal {
|
|||||||
|
|
||||||
// 战力计算
|
// 战力计算
|
||||||
public calCe() {
|
public calCe() {
|
||||||
let attrMap = this.getRealAttrToMap();
|
let ce = gameData.ceRatio.reduce((pre, cur) => {
|
||||||
let attrs = new Attribute();
|
let { type, val } = cur;
|
||||||
attrs.setByMap(attrMap);
|
return pre + val * (this.attrs.get(type)|| 0)
|
||||||
|
}, 0);
|
||||||
let { hp, atk, def, mdef, cri, flee, damageIncrease, damageDecrease, damageCri } = attrs;
|
return Math.floor(ce);
|
||||||
|
|
||||||
let putHit = CE_CONST.PUT_HIT / HERO_SUB_ATTR_RATIO;
|
|
||||||
let putAntCri = CE_CONST.PUT_ANT_CRI / HERO_SUB_ATTR_RATIO;
|
|
||||||
|
|
||||||
let hitRate = CE_CONST.HIT_RATE_BASE + putHit/2 - flee; // 命中率
|
|
||||||
if(hitRate > CE_CONST.HIT_RATE_MAX) hitRate = CE_CONST.HIT_RATE_MAX;
|
|
||||||
if(hitRate < CE_CONST.HIT_RATE_MIN) hitRate = CE_CONST.HIT_RATE_MIN;
|
|
||||||
let fleeRate = 1 - hitRate; // 格挡率
|
|
||||||
|
|
||||||
let criRate = CE_CONST.CRI_RATE_BASE + cri - putAntCri/2;
|
|
||||||
if(criRate > CE_CONST.CRI_RATE_MAX) criRate = CE_CONST.CRI_RATE_MAX;
|
|
||||||
if(criRate < CE_CONST.CRI_RATE_MIN) criRate = CE_CONST.CRI_RATE_MIN;
|
|
||||||
|
|
||||||
let criValue = CE_CONST.CRI_VALUE_BASE + damageCri;
|
|
||||||
|
|
||||||
let validHp = hp + (def + mdef) * 0.5 / ((1 - fleeRate * CE_CONST.FLEE_VALUE) * (1 - damageDecrease)); // 有效生命
|
|
||||||
let validAtk = atk * hitRate * ( 1 + criRate * criValue) * ( 1 + damageIncrease); // 有效输出
|
|
||||||
let ce = Math.floor(validHp * validAtk * HERO_CE_RATIO * HERO_CE_RATIO / 1000);
|
|
||||||
return ce > 0? ce: 1;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public calCelAndReduce() {
|
public calCelAndReduce() {
|
||||||
|
|||||||
+10
-1
@@ -223,7 +223,8 @@ export const gameData = {
|
|||||||
quenchRangeByQualityAndGrade: dicQuenchRangeByQualityAndGrade,
|
quenchRangeByQualityAndGrade: dicQuenchRangeByQualityAndGrade,
|
||||||
quenchConsume: dicQuenchConsume,
|
quenchConsume: dicQuenchConsume,
|
||||||
quenchByQuality: dicQuenchByQuality,
|
quenchByQuality: dicQuenchByQuality,
|
||||||
equipAttributeRatio: new Map<number, number>()
|
equipAttributeRatio: new Map<number, number>(),
|
||||||
|
ceRatio: new Array<{type: number, val: number}>()
|
||||||
};
|
};
|
||||||
|
|
||||||
// 在此提供一些原先在gamedata中提供的方法,以便更方便获取gameData数据
|
// 在此提供一些原先在gamedata中提供的方法,以便更方便获取gameData数据
|
||||||
@@ -673,6 +674,13 @@ function getHeroTransPiece() {
|
|||||||
gameData.heroTransPiece = newMap
|
gameData.heroTransPiece = newMap
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function getCeRatio() {
|
||||||
|
let arr = decodeArrayListStr(param.ATTRIBUTE.ATTRIBUTE_POWER);
|
||||||
|
gameData.ceRatio = arr.map(cur => {
|
||||||
|
return { type: parseInt(cur[0]), val: parseInt(cur[1]) }
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// 根据groupId获得当前大区名
|
// 根据groupId获得当前大区名
|
||||||
export function getServerGroupName(groupId: number) {
|
export function getServerGroupName(groupId: number) {
|
||||||
@@ -768,6 +776,7 @@ function parseDicParam() {
|
|||||||
getGachaTurntablePercent();
|
getGachaTurntablePercent();
|
||||||
getHeroTransPiece();
|
getHeroTransPiece();
|
||||||
parseComBtlLvRange();
|
parseComBtlLvRange();
|
||||||
|
getCeRatio();
|
||||||
}
|
}
|
||||||
|
|
||||||
// 加载json
|
// 加载json
|
||||||
|
|||||||
Reference in New Issue
Block a user