薇薇安伤害计算

This commit is contained in:
UCPr 2025-05-30 00:28:39 +08:00
parent 297be2d481
commit 7ace8908ff
9 changed files with 240 additions and 53 deletions

View file

@ -110,6 +110,7 @@ export interface damage {
x?: (n: number) => void
}
/** ID 2 EN */
const elementType2element = (elementType: number) => elementEnum[[0, 1, 2, 3, -1, 4][elementType - 200]] as element
const subBaseValueData = {
@ -265,7 +266,7 @@ export class Calculator {
}, this)
const areas = {} as damage['areas']
if (skill.before) skill.before({ avatar: this.avatar, calc: this, usefulBuffs, skill, props, areas })
const isAnomaly = typeof anomalyEnum[skill.type as anomaly] === 'number'
const isAnomaly = typeof anomalyEnum[skill.type.slice(0, 2) as anomaly] === 'number'
if (!areas.BasicArea) {
let Multiplier = props.
if (!Multiplier) {
@ -273,7 +274,7 @@ export class Calculator {
Multiplier = skill.fixedMultiplier
} else if (isAnomaly) {
Multiplier = (
skill.type === '紊乱' ?
skill.type.startsWith('紊乱') ?
this.get_DiscoverMultiplier(skill) :
this.get_AnomalyMultiplier(skill, usefulBuffs, skill.name.includes('每') ? 1 : 0)
) || 0
@ -295,7 +296,7 @@ export class Calculator {
areas.AnomalyProficiencyArea ??= this.get_AnomalyProficiencyArea(skill, usefulBuffs)
areas.AnomalyBoostArea ??= this.get_AnomalyBoostArea(skill, usefulBuffs)
areas.LevelArea ??= this.get_LevelArea()
if (skill.type !== '紊乱') { // 紊乱暂无异常暴击区
if (!skill.type.startsWith('紊乱')) { // 紊乱暂无异常暴击区
props. ??= this.get_AnomalyCRITRate(skill, usefulBuffs)
props. ??= this.get_AnomalyCRITDMG(skill, usefulBuffs)
areas.CriticalArea ??= 1 + props.! * (props.! - 1)
@ -573,10 +574,21 @@ export class Calculator {
return Multiplier
}
get_AnomalyData(type: skill['type']) {
/** 获取角色自身**出伤**异常的异常数据 */
get_AnomalyData(): typeof AnomalyData[number]
/** 获取角色自身**指定**异常的异常数据 */
get_AnomalyData(anomaly: anomaly): typeof AnomalyData[number]
get_AnomalyData(anomaly?: anomaly) {
if (!anomaly) {
return AnomalyData.find(({ element_type, sub_element_type, multiplier }) =>
multiplier &&
element_type === this.avatar.element_type &&
sub_element_type === this.avatar.sub_element_type
)
}
let a = AnomalyData.filter(({ element_type }) => element_type === this.avatar.element_type)
if (type === '紊乱') a = a.filter(({ discover }) => discover)
else a = a.filter(({ name, multiplier }) => name === type && multiplier)
if (anomaly === '紊乱') a = a.filter(({ discover }) => discover)
else a = a.filter(({ name, multiplier }) => name === anomaly && multiplier)
if (a.length === 1) return a[0]
a = a.filter(({ sub_element_type }) => sub_element_type === this.avatar.sub_element_type)
return a[0]
@ -584,10 +596,10 @@ export class Calculator {
/** 获取属性异常倍率 */
get_AnomalyMultiplier(skill: skill, usefulBuffs: buff[], times = 0) {
const anomalyData = this.get_AnomalyData(skill.type)
const anomalyData = this.get_AnomalyData(skill?.type.slice(0, 2) as anomaly)
if (!anomalyData) return
let Multiplier = anomalyData.multiplier
if (anomalyData.duration && anomalyData.interval) {
if (times !== 1 && anomalyData.duration && anomalyData.interval) {
const AnomalyDuration = this.get_AnomalyDuration(skill, usefulBuffs, anomalyData.duration)
times ||= Math.floor((AnomalyDuration * 10) / (anomalyData.interval * 10))
Multiplier = anomalyData.multiplier * times
@ -598,7 +610,7 @@ export class Calculator {
/** 获取紊乱倍率 */
get_DiscoverMultiplier(skill: skill) {
const anomalyData = this.get_AnomalyData(skill.type)
const anomalyData = this.get_AnomalyData(skill?.type.slice(0, 2) as anomaly)
if (!anomalyData) return
const AnomalyDuration = this.get_AnomalyDuration({
...skill,