🐞 fix(战力): pvp等机器人数据的战力生成修改为新算法
This commit is contained in:
@@ -5,6 +5,7 @@ import { ATTRIBUTE } from '../../pubUtils/dicParam';
|
||||
|
||||
export class AttributeCal {
|
||||
attrs: Map<number, number> = new Map<number, number>();
|
||||
ceAttrs: Map<number, number> = new Map<number, number>();
|
||||
ce?: number = 0;
|
||||
lv: number = 1;
|
||||
|
||||
@@ -12,12 +13,19 @@ export class AttributeCal {
|
||||
this.lv = lv;
|
||||
}
|
||||
|
||||
public setByWarJson(attributes: {id: number, val: number}[], ratio: number = 1) {
|
||||
public setByWarJson(hid: number, attributes: {id: number, val: number}[], ratio: number = 1) {
|
||||
let dicHero = gameData.hero.get(hid);
|
||||
let dicJob = gameData.job.get(dicHero?.jobid);
|
||||
for(let {id, val} of attributes) {
|
||||
if(ABI_TYPE_MAIN.includes(id)) {
|
||||
this.attrs.set(id, Math.floor(val * ratio));
|
||||
this.ceAttrs.set(id, Math.floor(val * ratio));
|
||||
} else {
|
||||
this.attrs.set(id, Math.floor(val));
|
||||
let baseSubAttr = dicJob?.baseSubAttr?.find(cur => cur.id == id);
|
||||
let result = val - (baseSubAttr?.val||0);
|
||||
if(result < 0) result = 0;
|
||||
this.ceAttrs.set(id, Math.floor(result));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -25,19 +33,26 @@ 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));
|
||||
this.ceAttrs.set(id, Math.floor(ceVal * ratio));
|
||||
} else {
|
||||
this.attrs.set(id, Math.floor(ceVal));
|
||||
this.ceAttrs.set(id, Math.floor(ceVal));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public setByMap( attributes: Map<number, number>, ratio: number = 1 ) {
|
||||
public setByMap(hid: number, attributes: Map<number, number>, ratio: number = 1 ) {
|
||||
let dicHero = gameData.hero.get(hid);
|
||||
let dicJob = gameData.job.get(dicHero?.jobid);
|
||||
for(let [id, val] of attributes) {
|
||||
if(ABI_TYPE_MAIN.includes(id)) {
|
||||
this.attrs.set(id, Math.floor(val * ratio));
|
||||
this.ceAttrs.set(id, Math.floor(val * ratio));
|
||||
} else {
|
||||
this.attrs.set(id, Math.floor(val));
|
||||
let baseSubAttr = dicJob?.baseSubAttr?.find(cur => cur.id == id);
|
||||
let result = val - (baseSubAttr?.val||0);
|
||||
if(result < 0) result = 0;
|
||||
this.ceAttrs.set(id, Math.floor(result));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -83,13 +98,13 @@ export class AttributeCal {
|
||||
if(calType == 3) {
|
||||
return 0
|
||||
} else {
|
||||
return pre + val * (this.attrs.get(type)|| 0)
|
||||
return pre + val * (this.ceAttrs.get(type)|| 0)
|
||||
}
|
||||
} else {
|
||||
if(calType == 2) {
|
||||
return 0
|
||||
} else {
|
||||
return pre + val * (this.attrs.get(type)|| 0) * this.lv / ATTRIBUTE.ATTRIBUTE_POWER_DIVISOR;
|
||||
return pre + val * (this.ceAttrs.get(type)|| 0) * this.lv / ATTRIBUTE.ATTRIBUTE_POWER_DIVISOR;
|
||||
}
|
||||
}
|
||||
}, 0);
|
||||
|
||||
Reference in New Issue
Block a user