feat(战力): 战力计算公式修改

This commit is contained in:
luying
2023-02-16 16:54:13 +08:00
parent 565b5f6869
commit 65b2b93ed3
3 changed files with 21 additions and 5 deletions

View File

@@ -15,7 +15,7 @@ export class CalCe {
originCes: Map<number, number> = new Map(); // hid => ce
resultCes: Map<number, number> = new Map(); // hid => ce
data: CalCeData;
attrsByHid: Map<number, { id: number, val: number, str: string }[]> = new Map();
attrsByHid: Map<number, { id: number, val: number, ceVal: number, str: string, ceStr: string }[]> = new Map();
originTopHeroCe: number;
constructor(roleId: string) {
@@ -41,25 +41,29 @@ export class CalCe {
}
public calHeroCe() {
let attrs = new Map<number, { id: number, val: number, str: string }[]>(); // hid => [{attrId, val}]
let attrs = new Map<number, { id: number, val: number, ceVal: number, str: string, ceStr: string }[]>(); // hid => [{attrId, val}]
for(let [hid ] of this.data.heroAttrsByHid) {
let lv = this.data.heroLv.get(hid)||1;
for(let attrId = ABI_TYPE.ABI_HP; attrId < ABI_TYPE.ABI_MAX; attrId++) {
if(!this.data.heroAttrs.has(`${hid}_${attrId}`) && !this.data.globalAttrs.has(attrId)) continue;
let { mainBase = 0, mainBaseUp = 0, subBase = 0, job = 0, starUp = 0, connect = 0, talent = 0, equipQuality = 0, equipStrength = 0, equipStar = 0, equipSuit = 0, jewel = 0, stone = 0, artifactLv = 0, artifactQuality = 0, artifactSeid = 0 } = this.data.heroAttrs.get(`${hid}_${attrId}`)||{};
let { school = 0, teraph = 0, title = 0, scroll = 0, skin = 0 } = this.data.getGlobalAttrById(attrId)||{};
let val = 0, str = '';
let val = 0, ceVal = 0, str = '', ceStr = '';
if(ABI_TYPE_MAIN.indexOf(attrId) != -1) {
// {[ hp1 + lv * hp2 ] * ( 1 + hp5 ) + [( hp6 + hp7 ) * ( 1 + hp8 )]} * ( 1 + hp9 ) + hp10 + hp11 + hp14
val = (( mainBase + job + lv * ( starUp + mainBaseUp ) ) * ( 1 + connect/100 ) + (( equipQuality + equipStrength ) * ( 1 + ( equipStar/100 + equipSuit/100 )))) * ( 1 + jewel/100 + school/100 + talent/100 + skin/100 + artifactSeid/100) + stone + teraph + title + scroll + artifactLv + artifactQuality;
ceVal = (( mainBase + job + lv * ( starUp + mainBaseUp ) ) * ( 1 + connect/100 ) + (( equipQuality + equipStrength ) * ( 1 + ( equipStar/100 + equipSuit/100 )))) * ( 1 + jewel/100 + school/100 + talent/100 + skin/100 + artifactSeid/100) + stone + teraph + title + scroll + artifactLv + artifactQuality;
str += `{[${mainBase}+${job}+${lv}*(${starUp}+${mainBaseUp})]* ( 1 + ${connect}/100) + [(${equipQuality}+${equipStrength}) * ( 1 + ${equipStar}/100+${equipSuit}/100)]} * (1+${jewel}/100+${school}/100+${talent}/100+${skin}/100+${artifactSeid}/100)+${stone}+${teraph}+${title}+${scroll}+${artifactLv}+${artifactQuality}`;
ceStr += `{[${mainBase}+${job}+${lv}*(${starUp}+${mainBaseUp})]* ( 1 + ${connect}/100) + [(${equipQuality}+${equipStrength}) * ( 1 + ${equipStar}/100+${equipSuit}/100)]} * (1+${jewel}/100+${school}/100+${talent}/100+${skin}/100+${artifactSeid}/100)+${stone}+${teraph}+${title}+${scroll}+${artifactLv}+${artifactQuality}`;
} else {
// attr1 + attr2 + attr4 + attr5 + attr6 + attr7 + attr9
val = subBase + job + teraph + school + title + jewel + equipStar;
ceVal = job + teraph + school + title + jewel + equipStar;
str += `${subBase}+${job}+${teraph}+${school}+${title}+${jewel}+${equipStar}`;
ceStr += `${job}+${teraph}+${school}+${title}+${jewel}+${equipStar}`;
}
if(!attrs.has(hid)) attrs.set(hid, []);
attrs.get(hid).push({ id: attrId, val, str });
attrs.get(hid).push({ id: attrId, val, ceVal, str, ceStr });
}
}
let result = new Map<number, number>();
@@ -67,7 +71,7 @@ export class CalCe {
let lv = this.data.heroLv.get(hid)||1;
let obj = new AttributeCal();
obj.setLv(lv);
obj.setByWarJson(arr);
obj.setByCeArr(arr);
let ce = obj.calCe();
this.resultCes.set(hid, ce);
result.set(hid, ce);

View File

@@ -63,6 +63,8 @@ export class SingleAttribute {
@prop({ required: true })
val: number; // 值
@prop({ required: true })
ceVal: number; // 值
@prop({ required: true })
str: string; // 公式
}

View File

@@ -22,6 +22,16 @@ export class AttributeCal {
}
}
public setByCeArr(attributes: {id: number, ceVal: number}[], ratio: number = 1) {
for(let {id, ceVal} of attributes) {
if(ABI_TYPE_MAIN.includes(id)) {
this.attrs.set(id, Math.floor(ceVal * ratio));
} else {
this.attrs.set(id, Math.floor(ceVal));
}
}
}
public setByMap( attributes: Map<number, number>, ratio: number = 1 ) {
for(let [id, val] of attributes) {
if(ABI_TYPE_MAIN.includes(id)) {