74 lines
2.2 KiB
Go
74 lines
2.2 KiB
Go
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(
|
|
data *pet.PET_ROWEI, player *player.Player) (result *fight.NullOutboundInfo, err errorcode.ErrorCode) {
|
|
_, _, inBag := player.FindPet(data.CatchTime)
|
|
_, _, inBackup := findBackupPet(player, data.CatchTime)
|
|
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(
|
|
data *pet.PetOneCureInboundInfo, player *player.Player) (result *pet.PetOneCureOutboundInfo, err errorcode.ErrorCode) {
|
|
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(
|
|
data *pet.PetDefaultInboundInfo, player *player.Player) (result *pet.PetDefaultOutboundInfo, err errorcode.ErrorCode) {
|
|
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(
|
|
data *pet.PetSetExpInboundInfo,
|
|
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
|
|
}
|