2025-11-25 12:29:50 +08:00
|
|
|
|
package controller
|
|
|
|
|
|
|
|
|
|
|
|
import (
|
|
|
|
|
|
"blazing/common/data/xmlres"
|
|
|
|
|
|
"blazing/common/socket/errorcode"
|
|
|
|
|
|
"blazing/common/utils"
|
|
|
|
|
|
"blazing/logic/service/fight"
|
|
|
|
|
|
"blazing/logic/service/pet"
|
|
|
|
|
|
"blazing/logic/service/player"
|
|
|
|
|
|
"blazing/modules/blazing/model"
|
|
|
|
|
|
)
|
|
|
|
|
|
|
2025-12-23 10:46:17 +08:00
|
|
|
|
// SetPetSkill 设置宠物技能,消耗50赛尔豆
|
2025-11-25 12:29:50 +08:00
|
|
|
|
func (h Controller) SetPetSkill(data *pet.ChangeSkillInfo, c *player.Player) (result *pet.ChangeSkillOutInfo, err errorcode.ErrorCode) {
|
2025-12-23 10:46:17 +08:00
|
|
|
|
const setSkillCost = 50
|
|
|
|
|
|
|
|
|
|
|
|
if !c.UseCoins(setSkillCost) {
|
|
|
|
|
|
return nil, errorcode.ErrorCodes.ErrSunDouInsufficient10016
|
2025-11-25 12:29:50 +08:00
|
|
|
|
}
|
2025-12-23 10:46:17 +08:00
|
|
|
|
|
|
|
|
|
|
c.Info.Coins -= setSkillCost
|
|
|
|
|
|
|
2025-11-25 12:29:50 +08:00
|
|
|
|
_, onpet, ok := c.FindPet(data.CatchTime)
|
2025-11-25 16:36:55 +08:00
|
|
|
|
if !ok {
|
2025-12-23 10:46:17 +08:00
|
|
|
|
return nil, errorcode.ErrorCodes.ErrSystemBusy
|
2025-11-25 16:36:55 +08:00
|
|
|
|
}
|
2025-12-23 10:46:17 +08:00
|
|
|
|
|
|
|
|
|
|
// 检查要替换的技能是否已存在
|
|
|
|
|
|
_, _, exists := utils.FindWithIndex(onpet.SkillList, func(item model.SkillInfo) bool {
|
2025-11-26 15:25:10 +08:00
|
|
|
|
return item.ID == data.ReplaceSkill
|
|
|
|
|
|
})
|
2025-12-23 10:46:17 +08:00
|
|
|
|
if exists {
|
|
|
|
|
|
return nil, errorcode.ErrorCodes.ErrSystemBusy
|
2025-11-26 15:25:10 +08:00
|
|
|
|
}
|
2025-12-23 10:46:17 +08:00
|
|
|
|
|
|
|
|
|
|
// 查找要学习的技能并替换
|
|
|
|
|
|
_, hasSkill, ok := utils.FindWithIndex(onpet.SkillList, func(item model.SkillInfo) bool {
|
2025-11-25 16:36:55 +08:00
|
|
|
|
return item.ID == data.HasSkill
|
|
|
|
|
|
})
|
2025-11-26 15:25:10 +08:00
|
|
|
|
if ok {
|
2025-12-23 10:46:17 +08:00
|
|
|
|
hasSkill.ID = data.ReplaceSkill
|
|
|
|
|
|
hasSkill.PP = uint32(xmlres.SkillMap[int(hasSkill.ID)].MaxPP)
|
2025-11-25 12:29:50 +08:00
|
|
|
|
}
|
2025-12-23 10:46:17 +08:00
|
|
|
|
|
2025-11-25 12:29:50 +08:00
|
|
|
|
return &pet.ChangeSkillOutInfo{
|
|
|
|
|
|
CatchTime: data.CatchTime,
|
|
|
|
|
|
}, 0
|
|
|
|
|
|
}
|
2025-12-23 10:46:17 +08:00
|
|
|
|
|
|
|
|
|
|
// SkillSort 排序宠物技能,消耗50赛尔豆
|
|
|
|
|
|
func (h Controller) SkillSort(data *pet.C2S_Skill_Sort, c *player.Player) (result *fight.NullOutboundInfo, err errorcode.ErrorCode) {
|
|
|
|
|
|
const skillSortCost = 50
|
|
|
|
|
|
|
|
|
|
|
|
if !c.UseCoins(skillSortCost) {
|
|
|
|
|
|
return nil, errorcode.ErrorCodes.ErrSunDouInsufficient10016
|
2025-11-25 12:29:50 +08:00
|
|
|
|
}
|
2025-12-23 10:46:17 +08:00
|
|
|
|
|
|
|
|
|
|
c.Info.Coins -= skillSortCost
|
|
|
|
|
|
|
2025-11-25 12:29:50 +08:00
|
|
|
|
_, onpet, ok := c.FindPet(data.CapTm)
|
|
|
|
|
|
if ok {
|
2025-12-23 10:46:17 +08:00
|
|
|
|
var newSkillList []model.SkillInfo
|
|
|
|
|
|
for _, skillID := range data.Skill {
|
|
|
|
|
|
_, skill, found := utils.FindWithIndex(onpet.SkillList, func(item model.SkillInfo) bool {
|
|
|
|
|
|
return item.ID == skillID
|
2025-11-25 12:29:50 +08:00
|
|
|
|
})
|
2025-12-23 10:46:17 +08:00
|
|
|
|
if found {
|
|
|
|
|
|
newSkillList = append(newSkillList, *skill)
|
2025-11-25 12:29:50 +08:00
|
|
|
|
}
|
|
|
|
|
|
}
|
2025-12-23 10:46:17 +08:00
|
|
|
|
onpet.SkillList = newSkillList
|
2025-11-25 12:29:50 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
return nil, 0
|
|
|
|
|
|
}
|