2026-04-03 00:02:51 +08:00
|
|
|
package controller
|
|
|
|
|
|
|
|
|
|
import (
|
|
|
|
|
"blazing/common/data/xmlres"
|
|
|
|
|
"blazing/common/socket/errorcode"
|
|
|
|
|
"blazing/logic/service/fight"
|
|
|
|
|
"blazing/logic/service/pet"
|
|
|
|
|
"blazing/logic/service/player"
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
// PetReleaseToWarehouse 将精灵从仓库包中放生
|
|
|
|
|
func (h Controller) PetReleaseToWarehouse(
|
2026-04-05 07:24:36 +08:00
|
|
|
data *PET_ROWEI, player *player.Player) (result *fight.NullOutboundInfo, err errorcode.ErrorCode) {
|
2026-04-03 00:02:51 +08:00
|
|
|
_, _, inBag := player.FindPet(data.CatchTime)
|
2026-04-05 05:47:25 +08:00
|
|
|
_, _, inBackup := player.FindBackupPet(data.CatchTime)
|
2026-04-03 00:02:51 +08:00
|
|
|
freeForbidden := xmlres.PetMAP[int(data.ID)].FreeForbidden
|
|
|
|
|
if inBag || inBackup || freeForbidden == 1 {
|
|
|
|
|
return nil, errorcode.ErrorCodes.ErrCannotReleaseNonWarehouse
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if !player.Service.Pet.UpdateFree(data.CatchTime, 1) {
|
|
|
|
|
return nil, errorcode.ErrorCodes.ErrSystemError
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return nil, 0
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// PetOneCure 单体治疗
|
|
|
|
|
func (h Controller) PetOneCure(
|
2026-04-05 07:24:36 +08:00
|
|
|
data *PetOneCureInboundInfo, player *player.Player) (result *pet.PetOneCureOutboundInfo, err errorcode.ErrorCode) {
|
2026-04-03 00:02:51 +08:00
|
|
|
if player.IsArenaHealLocked() {
|
|
|
|
|
return result, errorcode.ErrorCodes.ErrChampionCannotHeal
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
_, currentPet, ok := player.FindPet(data.CatchTime)
|
|
|
|
|
if ok {
|
|
|
|
|
defer currentPet.Cure()
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return &pet.PetOneCureOutboundInfo{
|
|
|
|
|
CatchTime: data.CatchTime,
|
|
|
|
|
}, 0
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// PetFirst 精灵首发
|
|
|
|
|
func (h Controller) PetFirst(
|
2026-04-05 07:24:36 +08:00
|
|
|
data *PetDefaultInboundInfo, player *player.Player) (result *pet.PetDefaultOutboundInfo, err errorcode.ErrorCode) {
|
2026-04-03 00:02:51 +08:00
|
|
|
if player.IsArenaSwitchLocked() {
|
|
|
|
|
return result, errorcode.ErrorCodes.ErrChampionCannotSwitch
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
result = &pet.PetDefaultOutboundInfo{}
|
|
|
|
|
index, _, ok := player.FindPet(data.CatchTime)
|
|
|
|
|
if ok && index != 0 {
|
|
|
|
|
player.Info.PetList[index], player.Info.PetList[0] = player.Info.PetList[0], player.Info.PetList[index]
|
|
|
|
|
result.IsDefault = 1
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return result, 0
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// SetPetExp 设置宠物经验
|
|
|
|
|
func (h Controller) SetPetExp(
|
2026-04-05 07:24:36 +08:00
|
|
|
data *PetSetExpInboundInfo,
|
2026-04-03 00:02:51 +08:00
|
|
|
player *player.Player) (result *pet.PetSetExpOutboundInfo, err errorcode.ErrorCode) {
|
|
|
|
|
_, currentPet, found := player.FindPet(data.CatchTime)
|
|
|
|
|
if !found || currentPet.Level >= 100 {
|
|
|
|
|
return &pet.PetSetExpOutboundInfo{Exp: player.Info.ExpPool}, errorcode.ErrorCodes.ErrSystemError
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
player.AddPetExp(currentPet, data.Exp)
|
|
|
|
|
return &pet.PetSetExpOutboundInfo{Exp: player.Info.ExpPool}, 0
|
|
|
|
|
}
|