diff --git a/logic/service/fight/fightc.go b/logic/service/fight/fightc.go index df2fec00e..fe0271070 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 9070d50db..8c38a8bf9 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 {