All checks were successful
ci/woodpecker/push/my-first-workflow Pipeline was successful
feat(fight_boss): 优化BOSS战斗奖励逻辑并修复宠物等级突破100级限制 重构了handleMapBossFightRewards函数,将奖励逻辑分离到独立的处理函数中, 增加了shouldGrantBossWinBonus条件判断,确保只有满足条件时才发放胜利奖励。 同时修复了宠物等级系统,允许宠物等级突破100级限制但面板属性仍保持100级上限, 改进了经验获取和面板更新逻辑。 fix(item_use): 添加全能性格转化剂使用验证 添加了UniversalNatureItemID常量定义,增加对道具ID和性格配置的有效性验证, 确保只有正确的道具和性格类型才能被使用。 refactor(fight): 统一战斗结束原因处理逻辑 引入normalizeFightOverReason函数来标准化战斗结束原因, 统一了不同模块中的战斗结果映射逻辑,提高了代码一致性。 perf(pet): 优化宠物升级和经验计算性能 移除了等级100的硬性限制,在保证面板属性不超限的前提下允许宠物等级继续增长, 优化了经验分配和面板重新计算的逻辑流程。 ```
100 lines
2.7 KiB
Go
100 lines
2.7 KiB
Go
package controller
|
|
|
|
import (
|
|
"blazing/common/socket/errorcode"
|
|
"blazing/logic/service/common"
|
|
"blazing/logic/service/pet"
|
|
"blazing/logic/service/player"
|
|
"blazing/modules/player/model"
|
|
)
|
|
|
|
// GetPetInfo 获取精灵信息
|
|
func (h Controller) GetPetInfo(
|
|
data *GetPetInfoInboundInfo,
|
|
player *player.Player) (result *model.PetInfo,
|
|
err errorcode.ErrorCode) {
|
|
if slot, found := player.FindPetBagSlot(data.CatchTime); found {
|
|
if petInfo := slot.PetInfoPtr(); petInfo != nil {
|
|
result = petInfo
|
|
return result, 0
|
|
}
|
|
}
|
|
|
|
ret := player.Service.Pet.PetInfoOneByCatchTime(data.CatchTime)
|
|
if ret == nil {
|
|
return nil, errorcode.ErrorCodes.ErrPokemonNotExists
|
|
}
|
|
|
|
result = &ret.Data
|
|
return result, 0
|
|
}
|
|
|
|
// GetUserBagPetInfo 获取主背包和并列备用精灵列表
|
|
func (h Controller) GetUserBagPetInfo(
|
|
data *GetUserBagPetInfoInboundEmpty,
|
|
player *player.Player) (result *pet.GetUserBagPetInfoOutboundInfo,
|
|
err errorcode.ErrorCode) {
|
|
return player.GetUserBagPetInfo(), 0
|
|
}
|
|
|
|
// GetPetListInboundEmpty 定义请求或响应数据结构。
|
|
type GetPetListInboundEmpty struct {
|
|
Head common.TomeeHeader `cmd:"2303" struc:"skip"`
|
|
}
|
|
|
|
// GetPetList 获取当前主背包列表
|
|
func (h Controller) GetPetList(
|
|
data *GetPetListInboundEmpty,
|
|
player *player.Player) (result *pet.GetPetListOutboundInfo,
|
|
err errorcode.ErrorCode) {
|
|
return buildPetListOutboundInfo(player.Info.PetList), 0
|
|
}
|
|
|
|
// GetPetListFreeInboundEmpty 定义请求或响应数据结构。
|
|
type GetPetListFreeInboundEmpty struct {
|
|
Head common.TomeeHeader `cmd:"2320" struc:"skip"`
|
|
}
|
|
|
|
// GetPetReleaseList 获取仓库可放生列表
|
|
func (h Controller) GetPetReleaseList(
|
|
data *GetPetListFreeInboundEmpty,
|
|
player *player.Player) (result *pet.GetPetListOutboundInfo,
|
|
err errorcode.ErrorCode) {
|
|
|
|
return buildPetListOutboundInfo(player.WarehousePetList()), 0
|
|
}
|
|
|
|
// PlayerShowPet 精灵展示
|
|
func (h Controller) PlayerShowPet(
|
|
data *PetShowInboundInfo,
|
|
player *player.Player) (result *pet.PetShowOutboundInfo, err errorcode.ErrorCode) {
|
|
result = &pet.PetShowOutboundInfo{
|
|
UserID: data.Head.UserID,
|
|
CatchTime: data.CatchTime,
|
|
Flag: data.Flag,
|
|
}
|
|
|
|
if data.Flag == 0 {
|
|
player.SetPetDisplay(0, nil)
|
|
player.GetSpace().RefreshUserInfo(player)
|
|
defer player.GetSpace().Broadcast(player, data.Head.CMD, result)
|
|
return
|
|
}
|
|
|
|
slot, ok := player.FindPetBagSlot(data.CatchTime)
|
|
if !ok {
|
|
return nil, errorcode.ErrorCodes.ErrPokemonNotExists
|
|
}
|
|
|
|
currentPet := slot.PetInfoPtr()
|
|
if currentPet == nil {
|
|
return nil, errorcode.ErrorCodes.ErrPokemonNotExists
|
|
}
|
|
|
|
player.SetPetDisplay(data.Flag, currentPet)
|
|
player.GetSpace().RefreshUserInfo(player)
|
|
result = buildPetShowOutboundInfo(data.Head.UserID, data.Flag, currentPet)
|
|
defer player.GetSpace().Broadcast(player, data.Head.CMD, result)
|
|
return
|
|
}
|