🐞 fix(战力): pvp等机器人数据的战力生成修改为新算法

This commit is contained in:
luying
2023-02-17 14:26:31 +08:00
parent b0e0c83fcd
commit 52701f7e11
8 changed files with 64 additions and 29 deletions

View File

@@ -198,9 +198,9 @@ export async function matchRobots(scale: number, myCe: number, robotCe: number,
let allCe = 0;
for(let json of dicWarJson) {
if(json.relation == 2) {
const { attribute, enemyCount } = json;
const { actorId, attribute, enemyCount } = json;
let { attribute: newAttribute, ce } = getRobotAttribute(attribute, enemyCount, lv, myCe, robotCe, scale);
let { attribute: newAttribute, ce } = getRobotAttribute(actorId, attribute, enemyCount, lv, myCe, robotCe, scale);
enemyObj.enemies.push({...json, skinId: json.actorId, attribute: newAttribute, lv, ce});
allCe += ce;
}
@@ -276,24 +276,24 @@ export async function getResetRemainCnt(curTime: Date, roleId: string, role?: Ro
* @param enemyCe 出兵表对手战力
* @param ratio 系数
*/
export function getRobotAttribute(mainAttrs: { id: number, val: number }[], enemyCount: number, lv: number, ce: number, enemyCe: number, ratio: number) {
export function getRobotAttribute(hid: number, mainAttrs: { id: number, val: number }[], enemyCount: number, lv: number, ce: number, enemyCe: number, ratio: number) {
let _lv = Math.floor(lv * ratio)
let newAttribute = new AttributeCal();
newAttribute.setLv(_lv);
let dicExpeditionSubAttr = gameData.expeditionSubAttr.get(_lv);
if(!dicExpeditionSubAttr) dicExpeditionSubAttr = gameData.expeditionSubAttr.get('max');
newAttribute.setByWarJson(dicExpeditionSubAttr.attribute); // 次级属性
newAttribute.setByWarJson(hid, dicExpeditionSubAttr.attribute); // 次级属性
let subAttrCe = newAttribute.calSubAttrCe() * enemyCount;
if(ce * ratio > subAttrCe) {
let mainAttrCe = ce * ratio - subAttrCe;
newAttribute.setByWarJson(mainAttrs, mainAttrCe / enemyCe);
newAttribute.setByWarJson(hid, mainAttrs, mainAttrCe / enemyCe);
let attrArr = newAttribute.getAttributesToString();
let newCe = newAttribute.calCe();
return { attribute: attrArr, ce: newCe };
} else {
newAttribute = new AttributeCal();
newAttribute.setByWarJson(mainAttrs, ce * ratio / enemyCe);
newAttribute.setByWarJson(hid, mainAttrs, ce * ratio / enemyCe);
let attrArr = newAttribute.getAttributesToString();
let newCe = newAttribute.calCe();
return { attribute: attrArr, ce: newCe };

View File

@@ -180,11 +180,11 @@ export async function removeBossRank(guildCode: string, roleId: string) {
await BossInstanceModel.removeBossRank(guildCode, roleId);
}
function getBossSubAttrCe(secondAttrLevel: number, bossLevel: number) {
function getBossSubAttrCe(hid: number, secondAttrLevel: number, bossLevel: number) {
let newAttribute = new AttributeCal();
newAttribute.setLv(bossLevel);
let subAttr = gameData.towerPvpSubAttr.get(secondAttrLevel);
if(subAttr) newAttribute.setByWarJson(subAttr.secondAtr);
if(subAttr) newAttribute.setByWarJson(hid, subAttr.secondAtr);
let newCe = newAttribute.calCe();
return newCe;
}
@@ -218,7 +218,7 @@ export async function getBossHp(serverId: number, guildCode: string, dicBossBase
}
if(playerCnt == 0) return { ratio: 1, bossHp: zoomInDamage(minBossHp) };
let subCe = getBossSubAttrCe(dicWar.secondAttrLevel, bossLv)
let subCe = getBossSubAttrCe(actorId, dicWar.secondAttrLevel, bossLv)
console.log(`getBossHp activeCe ${activeCe} playerCnt ${playerCnt} subCe ${subCe}`);
let B = (activeCe/playerCnt/6 - subCe)/GUILDACTIVITY.GATEACTIVITY_ENEMYCE;
let bossBaseHp = B * hp;

View File

@@ -524,7 +524,7 @@ export async function getHeroesAttributes(roleId: string) {
let cal = new AttributeCal();
let heroAttr = heroAttrs.find(cur => cur.hid == hid);
if(heroAttr) cal.setLv(heroAttr.lv);
cal.setByWarJson(attrs);
cal.setByWarJson(hid, attrs);
attrByHid.set(hid, cal);
}
return attrByHid;

View File

@@ -418,9 +418,9 @@ export function getRobotAttribute(hid: number, posRatio: number, score: number)
let newAttribute = new AttributeCal();
newAttribute.setLv(difficultRatio.enemyLv);
newAttribute.setByMap(dicHero.baseAbilityArr, difficultRatio.value / 10000 * posRatio);
newAttribute.setByMap(hid, dicHero.baseAbilityArr, difficultRatio.value / 10000 * posRatio);
let subAttr = gameData.towerPvpSubAttr.get(difficultRatio.secondAttrLevel);
if(subAttr) newAttribute.setByWarJson(subAttr.secondAtr);
if(subAttr) newAttribute.setByWarJson(hid, subAttr.secondAtr);
let attrArr = newAttribute.getAttributesToString();
let newCe = newAttribute.calCe();
return { attribute: attrArr, ce: newCe, lv: difficultRatio.enemyLv };

View File

@@ -88,7 +88,7 @@ export class CalCe {
let lv = this.data.heroLv.get(hid)||1;
let obj = new AttributeCal();
obj.setLv(lv);
obj.setByWarJson(arr);
obj.setByWarJson(hid, arr);
return obj.calCe();
}

View File

@@ -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);

View File

@@ -416,7 +416,7 @@ export function getBossHpByWarId(warId: number) {
let { attribute, dataId, relation, actorId } = hero;
if (relation === 2) {
let newAttr = new AttributeCal();
newAttr.setByWarJson(attribute, 1);
newAttr.setByWarJson(actorId, attribute, 1);
let attrJson = newAttr.getAttributes();
const hp = attrJson.hp || 0;

View File

@@ -2641,7 +2641,7 @@
},
{
"jobid": 14,
"name": "载具",
"name": "军械",
"grade": 1,
"isPlayer": 0,
"unlockLevel": 1,
@@ -2652,7 +2652,7 @@
"atkid": 1,
"seid": "&",
"effect": 0,
"info": "用于运输人、物的设备",
"info": "用于特殊作用的军用器械",
"trainingConsume": "&",
"upGradeConsume": "&",
"attr": "1&0|2&0|4&0|5&0",
@@ -2816,7 +2816,7 @@
"trainingConsume": "&",
"upGradeConsume": "&",
"attr": "&",
"baseAttr": "&",
"baseAttr": "9&100000|10&5000|11&10000|18&50000|28&50000",
"talentPoint": 0
},
{
@@ -2836,7 +2836,7 @@
"trainingConsume": "&",
"upGradeConsume": "&",
"attr": "&",
"baseAttr": "&",
"baseAttr": "9&100000|10&5000|11&10000|18&50000|28&50000",
"talentPoint": 0
},
{
@@ -2856,7 +2856,7 @@
"trainingConsume": "&",
"upGradeConsume": "&",
"attr": "&",
"baseAttr": "&",
"baseAttr": "9&100000|10&5000|11&10000|18&50000|28&50000",
"talentPoint": 0
},
{
@@ -2876,7 +2876,7 @@
"trainingConsume": "&",
"upGradeConsume": "&",
"attr": "&",
"baseAttr": "&",
"baseAttr": "9&100000|10&5000|11&10000|18&50000|28&50000",
"talentPoint": 0
},
{
@@ -2896,7 +2896,7 @@
"trainingConsume": "&",
"upGradeConsume": "&",
"attr": "&",
"baseAttr": "&",
"baseAttr": "9&100000|10&5000|11&10000|18&50000|28&50000",
"talentPoint": 1
},
{
@@ -2916,7 +2916,7 @@
"trainingConsume": "&",
"upGradeConsume": "&",
"attr": "&",
"baseAttr": "&",
"baseAttr": "9&100000|10&5000|11&10000|18&50000|28&50000",
"talentPoint": 0
},
{
@@ -2936,7 +2936,27 @@
"trainingConsume": "&",
"upGradeConsume": "&",
"attr": "&",
"baseAttr": "&",
"baseAttr": "9&100000|10&5000|11&10000|18&50000|28&50000",
"talentPoint": 0
},
{
"jobid": 29,
"name": "载具",
"grade": 1,
"isPlayer": 0,
"unlockLevel": 1,
"job_class": 29,
"type": 1,
"imgid": 10,
"spe": 2,
"atkid": 1,
"seid": "&",
"effect": 0,
"info": "用于运输人、物的设备",
"trainingConsume": "&",
"upGradeConsume": "&",
"attr": "1&0|2&0|4&0|5&0",
"baseAttr": "9&100000|10&5000|11&10000|18&50000|28&50000",
"talentPoint": 0
}
]