优化语音觉醒的计算代码

This commit is contained in:
枫谷剑仙 2020-10-21 19:54:15 +08:00
parent b4d16bf7e2
commit 853b8526fc
1 changed files with 16 additions and 25 deletions

View File

@ -329,36 +329,27 @@ function calculateAbility(member, assist = null, solo = true, teamsCount = 1)
0;
//console.log("基础值:%d加蛋值%d觉醒x%d增加%d潜觉增加%d",n_base,n_plus,awokenCount,n_awoken,n_latent);
let reValue = n_base + n_plus + n_awoken + n_latent + (n_assist_base + n_assist_plus) * bonusScale[idx];
let reValueNoAwoken = Math.round(n_base + n_plus + (n_assist_base + n_assist_plus) * bonusScale[idx]);
let reValueNoAwoken = n_base + n_plus + (n_assist_base + n_assist_plus) * bonusScale[idx];
//觉醒生效时的倍率
reValue = Math.round(awokenScale[idx].reduce((previous,aw)=>{
function calculateAwokenScale(previous,aw)
{
const awokenCount = awokenList.filter(ak=>ak==aw.index).length; //每个倍率觉醒的数量
if (awokenCount>0)
{
return previous * Math.pow(aw.scale,awokenCount);
}
else
{
return previous;
}
},reValue));
return previous * Math.pow(aw.scale,awokenCount);
}
//觉醒无效时的倍率 —— 计算顺序可能不对,这里只作为初步设置
//觉醒生效时的协力、语音觉醒等的倍率
reValue = Math.round(awokenScale[idx].reduce(calculateAwokenScale,reValue));
//觉醒无效时的倍率 —— 语音觉醒的计算顺序可能不对,这里只作为初步设置
const awokenScale_noAwoken = awokenScale.map(arr=>arr.filter(obj=>obj.index == 63)); //筛选出在无觉醒情况下依然生效的倍率觉醒目前只有63语音觉醒
reValueNoAwoken = Math.round(awokenScale_noAwoken[idx].reduce((previous,aw)=>{
const awokenCount = awokenList.filter(ak=>ak==aw.index).length; //每个倍率觉醒的数量
if (awokenCount>0)
{
return previous * Math.pow(aw.scale,awokenCount);
}
else
{
return previous;
}
},reValueNoAwoken));
reValueNoAwoken = Math.round(awokenScale_noAwoken[idx].reduce(calculateAwokenScale,reValueNoAwoken));
if (idx<2 && reValue<1) reValue = 1; //HP和ATK最低为1
if (idx<2) //idx顺序为HP、ATK、RCV
{ //HP和ATK最低为1
reValue = Math.max(reValue,1);
reValueNoAwoken = Math.max(reValueNoAwoken,1);
}
return [reValue,reValueNoAwoken];
});
return abilitys;