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

@@ -8,7 +8,6 @@ import (
"github.com/gogf/gf/v2/util/gconv"
"github.com/jinzhu/copier"
"github.com/mohae/deepcopy"
)
type Input struct {
@@ -27,9 +26,9 @@ type Input struct {
func NewInput(c common.FightI, p common.PlayerI) *Input {
ret := &Input{FightC: c, Player: p}
t := ret.GetDamageEffect(0)
ret.AddEffect(deepcopy.Copy(t).(Effect)) //添加默认基类,实现继承
p.SetFightC(c) //给玩家设置战斗容器
t, _ := Geteffect(4000000)
ret.AddEffect(t) //添加默认基类,实现继承
p.SetFightC(c) //给玩家设置战斗容器
return ret
}

View File

@@ -35,7 +35,7 @@ type Effect interface {
IsHit(opp *Input, skill *info.SkillEntity) //闪避率计算,,实际上是修改命中的判断
TakeHit(opp *Input, skill *info.SkillEntity) //闪避率计算,,实际上是修改命中的判断
//() bool // 暴击伤害结算后触发
OnSkill(opp *Input, skill *info.SkillEntity) //闪避率计算,,实际上是修改命中的判断
// OnHit() bool // 技能命中时触发
// OnMiss() bool // 技能未命中时触发
// AfterAttacked() bool // 被攻击后触发(受击判定)
@@ -88,7 +88,7 @@ func InitSkillEffect(id int, t Effect) {
NodeM[id+1000000] = t
}
func (c *Input) geteffect(id int) (Effect, bool) {
func Geteffect(id int) (Effect, bool) {
//todo 获取前GetEffect
ret, ok := NodeM[id]
@@ -99,16 +99,7 @@ func (c *Input) geteffect(id int) (Effect, bool) {
return nil, false
//todo 获取后GetEffect
}
func (c *Input) GetSkillEffect(id int) (Effect, bool) {
ret, ok := c.geteffect(id)
if ok {
//todo 获取前GetEffect
return ret, ok
//todo 获取后GetEffect
}
return nil, false
}
func InitPropEffect(id int, t Effect) {
NodeM[id+2000000] = t
@@ -142,7 +133,8 @@ func InitDamageEffect(id int, t Effect) {
// 1为红伤
func (c *Input) GetDamageEffect(id int) Effect {
ret, ok := c.geteffect(id + 1000000)
ret, ok := Geteffect(id + 1000000)
if ok {
//todo 获取前GetEffect
return ret
@@ -157,7 +149,7 @@ func InitStatusEffect(id int, t Effect) {
}
func (c *Input) GetStatusEffect(id int) (Effect, bool) {
ret, ok := c.geteffect(id + 3000000)
ret, ok := Geteffect(id + 3000000)
if ok {
//todo 获取前GetEffect
return ret, true