From 2723b1871dce22b6aae4f096093777b1a3198d4f Mon Sep 17 00:00:00 2001 From: 1 <1@72wo.cn> Date: Sun, 23 Nov 2025 23:42:16 +0000 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=BF=AE=E5=A4=8D=E7=A9=BA=E6=8F=90?= =?UTF-8?q?=E4=BA=A4=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- logic/controller/fight_base.go | 2 +- logic/service/common/fight.go | 2 +- logic/service/fight/action.go | 11 ++++------- logic/service/fight/input/fight.go | 4 ++-- 4 files changed, 8 insertions(+), 11 deletions(-) diff --git a/logic/controller/fight_base.go b/logic/controller/fight_base.go index 7e53007c6..dab01cec6 100644 --- a/logic/controller/fight_base.go +++ b/logic/controller/fight_base.go @@ -23,7 +23,7 @@ func (h Controller) UseSkill(data *fight.UseSkillInInfo, c *player.Player) (resu if c.FightC == nil { return nil, errorcode.ErrorCodes.ErrBattleEnded } - c.FightC.UseSkill(c, int32(data.SkillId)) + c.FightC.UseSkill(c, (data.SkillId)) return nil, 0 } diff --git a/logic/service/common/fight.go b/logic/service/common/fight.go index 99e56f2e7..466397fa7 100644 --- a/logic/service/common/fight.go +++ b/logic/service/common/fight.go @@ -7,7 +7,7 @@ import ( type FightI interface { Over(c PlayerI, id info.EnumBattleOverReason) //逃跑 - UseSkill(c PlayerI, id int32) //使用技能 + UseSkill(c PlayerI, id uint32) //使用技能 GetCurrPET(c PlayerI) *info.BattlePetEntity //当前精灵 Ownerid() uint32 diff --git a/logic/service/fight/action.go b/logic/service/fight/action.go index 0f18ee451..74faa4a1f 100644 --- a/logic/service/fight/action.go +++ b/logic/service/fight/action.go @@ -94,7 +94,7 @@ func (f *FightC) ChangePet(c common.PlayerI, id uint32) { } // 玩家使用技能 -func (f *FightC) UseSkill(c common.PlayerI, id int32) { +func (f *FightC) UseSkill(c common.PlayerI, id uint32) { if f.closefight { cool.Loger.Debug(context.Background(), " 战斗chan已关闭") return @@ -108,12 +108,9 @@ func (f *FightC) UseSkill(c common.PlayerI, id int32) { if f.GetInputByPlayer(c, false).CurrentPet.Info.Hp <= 0 { return } - for _, v := range f.GetInputByPlayer(c, false).CurrentPet.Skills { - - if v != nil && v.ID == int(id) { - ret.SkillEntity = v - break - } + t, ok := f.GetInputByPlayer(c, false).CurrentPet.Skills[id] + if ok { + ret.SkillEntity = t } f.actionChan <- ret diff --git a/logic/service/fight/input/fight.go b/logic/service/fight/input/fight.go index 790f69753..d0461aa25 100644 --- a/logic/service/fight/input/fight.go +++ b/logic/service/fight/input/fight.go @@ -254,7 +254,7 @@ func (our *Input) GetAction(opp *Input) { // bestKillSkill = ks.skill // } // } - our.FightC.UseSkill(our.Player, int32(bestKillSkill.ID)) + our.FightC.UseSkill(our.Player, uint32(bestKillSkill.ID)) return } if len(allSkills) <= 0 { @@ -265,7 +265,7 @@ func (our *Input) GetAction(opp *Input) { randomIdx := grand.Intn(len(allSkills)) for i, v := range skills { if randomIdx == int(i) { - our.FightC.UseSkill(our.Player, int32(v.ID)) + our.FightC.UseSkill(our.Player, uint32(v.ID)) } }