refactor(fight/effect): 重构技能伤害计算逻辑,将伤害处理移至Effect0.OnSkill方法并优化效果调用流程

This commit is contained in:
1
2025-09-23 18:35:23 +00:00
parent a524e651aa
commit 5a023ccd1c
6 changed files with 55 additions and 40 deletions

View File

@@ -22,6 +22,28 @@ func (this *Effect0) UseSkill(opp *input.Input) bool {
return true
}
// 使用技能时
func (e *Effect0) OnSkill(opp *input.Input, skill *info.SkillEntity) {
spower := skill.CalculatePower(opp.CurrentPet)
damage := e.Input.GetDamageEffect(0)
damage.Stack(int(spower.IntPart()))
e.Input.Exec(func(t input.Effect) bool { //计算暴击率加成
t.IsCrit(opp, skill)
e.Input.AttackValue.IsCritical = skill.Crit
return e.Input.AttackValue.IsCritical == 0
})
if e.Input.AttackValue.IsCritical == 1 {
damage.Stack(int(spower.IntPart() * 2)) //暴击翻倍
}
if uint32(damage.Stack()) > opp.CurrentPet.Info.Hp {
opp.CurrentPet.Info.Hp = 0
} else {
opp.CurrentPet.Info.Hp = opp.CurrentPet.Info.Hp - uint32(damage.Stack())
}
}
func (this *Effect0) IsCrit(opp *input.Input, skill *info.SkillEntity) {
skill.Crit = 0
CritRate := utils.Max(skill.CritRate, 1)