From a524e651aac5deffc9c0e634d6abd43b42ec4f43 Mon Sep 17 00:00:00 2001 From: 1 <1@72wo.cn> Date: Tue, 23 Sep 2025 17:57:27 +0000 Subject: [PATCH] =?UTF-8?q?refactor(fight/effect):=20=E9=87=8D=E6=9E=84?= =?UTF-8?q?=E6=95=88=E6=9E=9C=E8=8E=B7=E5=8F=96=E9=80=BB=E8=BE=91=EF=BC=8C?= =?UTF-8?q?=E5=B0=86deepcopy=E6=93=8D=E4=BD=9C=E7=A7=BB=E8=87=B3Input?= =?UTF-8?q?=E7=BB=93=E6=9E=84=E4=BD=93=E6=96=B9=E6=B3=95=E4=B8=AD=E5=B9=B6?= =?UTF-8?q?=E4=BC=98=E5=8C=96=E6=95=88=E6=9E=9C=E5=A4=84=E7=90=86=E6=B5=81?= =?UTF-8?q?=E7=A8=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- logic/service/fight/fightc.go | 11 +++--- logic/service/fight/input/nodemanger.go | 49 +++++++++++++++++++------ 2 files changed, 43 insertions(+), 17 deletions(-) diff --git a/logic/service/fight/fightc.go b/logic/service/fight/fightc.go index df2fec00..fe027107 100644 --- a/logic/service/fight/fightc.go +++ b/logic/service/fight/fightc.go @@ -12,7 +12,6 @@ import ( "time" "github.com/jinzhu/copier" - "github.com/mohae/deepcopy" ) type FightC struct { @@ -373,20 +372,20 @@ func (f *FightC) parseskill(attacker, defender *input.Input, id *SelectSkillActi temparg := id.Skill.SideEffectArgS for _, v := range id.Skill.SideEffectS { - t, ok := input.NodeM[v+1000000] + t, ok := attacker.GetSkillEffect(v) if ok { //获取成功 args := xmlres.EffectArgs[v] - eff := deepcopy.Copy(t).(input.Effect) - eff.SetArgs(temparg[:args]) //设置入参 + + t.SetArgs(temparg[:args]) //设置入参 temparg = temparg[args:] if t.GetOwner() { //如果取反,说明是给对方添加的回合效果 //实际上,owner永远为反,说明是对方给我添加的 - defender.AddEffect(eff) + defender.AddEffect(t) } else { - attacker.AddEffect(eff) + attacker.AddEffect(t) } } diff --git a/logic/service/fight/input/nodemanger.go b/logic/service/fight/input/nodemanger.go index 9070d50d..8c38a8bf 100644 --- a/logic/service/fight/input/nodemanger.go +++ b/logic/service/fight/input/nodemanger.go @@ -2,8 +2,11 @@ package input import ( "blazing/logic/service/fight/info" + "blazing/modules/blazing/model" "reflect" + + "github.com/mohae/deepcopy" ) type Effect interface { @@ -85,6 +88,27 @@ func InitSkillEffect(id int, t Effect) { NodeM[id+1000000] = t } +func (c *Input) geteffect(id int) (Effect, bool) { + + //todo 获取前GetEffect + ret, ok := NodeM[id] + if ok { + eff := deepcopy.Copy(ret).(Effect) + return eff, ok + } + 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 @@ -118,12 +142,13 @@ func InitDamageEffect(id int, t Effect) { // 1为红伤 func (c *Input) GetDamageEffect(id int) Effect { - - //todo 获取前GetEffect - ret, _ := NodeM[id+4000000] - - return ret - //todo 获取后GetEffect + ret, ok := c.geteffect(id + 1000000) + if ok { + //todo 获取前GetEffect + return ret + //todo 获取后GetEffect + } + return nil } func InitStatusEffect(id int, t Effect) { @@ -132,12 +157,14 @@ func InitStatusEffect(id int, t Effect) { } func (c *Input) GetStatusEffect(id int) (Effect, bool) { + ret, ok := c.geteffect(id + 3000000) + if ok { + //todo 获取前GetEffect + return ret, true + //todo 获取后GetEffect + } + return nil, false - //todo 获取前GetEffect - ret, ok := NodeM[id+3000000] - - return ret, ok - //todo 获取后GetEffect } func (c *Input) GetCurrAttr(id int) *model.PetInfo {