diff --git a/common/utils/emap.go b/common/utils/emap.go index 56e05ccdd..b3994bf91 100644 --- a/common/utils/emap.go +++ b/common/utils/emap.go @@ -34,7 +34,8 @@ type OrderedMap[K comparable, V any] struct { // NewOrderedMap 创建一个新的泛型有序Map func NewOrderedMap[K comparable, V any]() *OrderedMap[K, V] { return &OrderedMap[K, V]{ - hash: &maphash.Hash{}, + hash: &maphash.Hash{}, + hashTable: make(map[uint64]*MapEntry[K, V]), } } diff --git a/logic/service/fight/fightc.go b/logic/service/fight/fightc.go index 14e4cbd24..70e0f24ba 100644 --- a/logic/service/fight/fightc.go +++ b/logic/service/fight/fightc.go @@ -373,23 +373,19 @@ func (f *FightC) parseskill(attacker, defender *input.Input, id *SelectSkillActi temparg := id.Skill.SideEffectArgS for _, v := range id.Skill.SideEffectS { - t, ok := input.Geteffect(v + 1000000) + t := input.GetSkillEffect(v) - if ok { //获取成功 + args := xmlres.EffectArgs[v] - args := xmlres.EffectArgs[v] + t.Effect.SetArgs(temparg[:args]...) //设置入参 - t.SetArgs(temparg[:args]...) //设置入参 - - temparg = temparg[args:] - if t.GetOwner() { //如果取反,说明是给对方添加的回合效果 - //实际上,owner永远为反,说明是对方给我添加的 - - defender.AddEffect(defender.GetSkillEffect(v)) - } else { - attacker.AddEffect(attacker.GetSkillEffect(v)) - } + temparg = temparg[args:] + if t.Effect.GetOwner() { //如果取反,说明是给对方添加的回合效果 + //实际上,owner永远为反,说明是对方给我添加的 + defender.AddEffect(t) + } else { + attacker.AddEffect(t) } } diff --git a/logic/service/fight/input/input.go b/logic/service/fight/input/input.go index 0721c8aad..12c22850d 100644 --- a/logic/service/fight/input/input.go +++ b/logic/service/fight/input/input.go @@ -27,10 +27,11 @@ type Input struct { func NewInput(c common.FightI, p common.PlayerI) *Input { ret := &Input{FightC: c, Player: p} - t := ret.GetDamageEffect(0) + ret.Effects = utils.NewOrderedMap[int, Effect]() + t := GetDamageEffect(0) ret.AddEffect(t) //添加默认基类,实现继承 p.SetFightC(c) //给玩家设置战斗容器 - ret.Effects = utils.NewOrderedMap[int, Effect]() + return ret } @@ -72,7 +73,7 @@ func (i *Input) GetStatusBonus() float64 { maxBonus := 1.0 // 默认无状态倍率 for statusIdx := 0; statusIdx < 20; statusIdx++ { - t, ok := i.GetStatusEffect(statusIdx) + t, ok := GetStatusEffect(statusIdx) // 检查状态是否存在(数组中值为1表示存在该状态) if ok && t.Stack() > 0 { diff --git a/logic/service/fight/input/nodemanger.go b/logic/service/fight/input/nodemanger.go index 214e19fe6..f3ec8b01b 100644 --- a/logic/service/fight/input/nodemanger.go +++ b/logic/service/fight/input/nodemanger.go @@ -79,7 +79,7 @@ var NodeM = make(map[int]Effect, 0) func InitSkillEffect(id int, t Effect) { - NodeM[id+1000000] = t + NodeM[id+1000000-1] = t } func Geteffect(id int) (Effect, bool) { @@ -95,7 +95,7 @@ func Geteffect(id int) (Effect, bool) { func InitPropEffect(id int, t Effect) { - NodeM[id+2000000] = t + NodeM[id+2000000-1] = t } // * battle_lv: atk(0), def(1), sp_atk(2), sp_def(3), spd(4), accuracy(5) @@ -125,11 +125,11 @@ func (c *Input) GetProp(id int, istue bool) int { } func InitDamageEffect(id int, t Effect) { - NodeM[id+4000000] = t + NodeM[id+4000000-1] = t } // 1为红伤 -func (c *Input) GetDamageEffect(id int) *EffectID { +func GetDamageEffect(id int) *EffectID { id1 := id + 4000000 ret, ok := Geteffect(id1) if ok { @@ -142,7 +142,17 @@ func (c *Input) GetDamageEffect(id int) *EffectID { } return &EffectID{} } -func (c *Input) GetSkillEffect(id int) *EffectID { + +func (c *Input) GetDamageEffect(id int) int { + id1 := id + 4000000 + rer, ok := c.Effects.Load(id1) + if ok { + return rer.Stack() + } + + return 0 +} +func GetSkillEffect(id int) *EffectID { id1 := id + 1000000 ret, ok := Geteffect(id1) if ok { @@ -161,7 +171,7 @@ type EffectID struct { Effect Effect } -func (c *Input) GetPropEffect(id int) Effect { +func GetPropEffect(id int) Effect { ret, ok := Geteffect(id + 2000000) if ok { @@ -173,10 +183,10 @@ func (c *Input) GetPropEffect(id int) Effect { } func InitStatusEffect(id int, t Effect) { - NodeM[id+3000000] = t + NodeM[id+3000000-1] = t } -func (c *Input) GetStatusEffect(id int) (Effect, bool) { +func GetStatusEffect(id int) (Effect, bool) { ret, ok := Geteffect(id + 3000000) if ok { //todo 获取前GetEffect @@ -186,6 +196,11 @@ func (c *Input) GetStatusEffect(id int) (Effect, bool) { return nil, false } +func (c *Input) GetStatusEffect(id int) (Effect, bool) { + rer, ok := c.Effects.Load(id + 3000000) + + return rer, ok +} func (c *Input) GetCurrAttr(id int) *model.PetInfo { //todo 获取前GetEffect