refactor(fight): 优化战斗逻辑代码结构,清理冗余代码

This commit is contained in:
1
2025-11-06 14:43:26 +00:00
parent b8a6aacaa9
commit 52921e36f0

View File

@@ -7,8 +7,6 @@ import (
"blazing/logic/service/pet"
"blazing/logic/service/player"
"github.com/samber/lo"
"blazing/modules/blazing/model"
"github.com/jinzhu/copier"
@@ -179,6 +177,12 @@ func (h Controller) SetPetSkill(data *pet.ChangeSkillInfo, c *player.Player) (re
return item.CatchTime == data.CatchTime
})
if ok {
_, _, ok := utils.FindWithIndex(onpet.SkillList, func(item model.SkillInfo) bool { //已经存在技能
return item.ID == data.ReplaceSkill
})
if ok {
return
}
for i := 0; i < len(onpet.SkillList); i++ {
if onpet.SkillList[i].ID == data.HasSkill {
onpet.SkillList[i].ID = data.ReplaceSkill
@@ -188,9 +192,9 @@ func (h Controller) SetPetSkill(data *pet.ChangeSkillInfo, c *player.Player) (re
}
}
onpet.SkillList = lo.UniqBy(onpet.SkillList, func(s model.SkillInfo) int {
return int(s.ID)
})
// onpet.SkillList = lo.UniqBy(onpet.SkillList, func(s model.SkillInfo) int {
// return int(s.ID)
// })
return &pet.ChangeSkillOutInfo{
CatchTime: data.CatchTime,
}, 0