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)) } }