1
All checks were successful
ci/woodpecker/push/my-first-workflow Pipeline was successful

This commit is contained in:
昔念
2026-04-15 22:42:56 +08:00
parent ee8b0a2182
commit 9f7fd83626
3 changed files with 11 additions and 15 deletions

View File

@@ -19,20 +19,13 @@ func (h Controller) SavePetBagOrder(
return nil, 0
}
// PetRetrieveFromWarehouse 领回仓库精灵
// PetRetrieveFromWarehouse 从放生仓库领回精灵
func (h Controller) PetRetrieveFromWarehouse(
data *PET_RETRIEVE, player *player.Player) (result *fight.NullOutboundInfo, err errorcode.ErrorCode) {
if _, ok := player.FindPetBagSlot(data.CatchTime); ok {
return nil, 0
if !player.Service.Pet.UpdateFree(data.CatchTime, 1, 0) {
return nil, errorcode.ErrorCodes.ErrPokemonIDMismatch
}
petInfo := player.Service.Pet.PetInfoOneByCatchTime(data.CatchTime)
if petInfo == nil {
return nil, 0
}
player.AddPetToAvailableBag(petInfo.Data)
return nil, 0
}

View File

@@ -48,9 +48,8 @@ func (h Controller) PetReleaseToWarehouse(
if inBag || inBackup || freeForbidden == 1 {
return nil, errorcode.ErrorCodes.ErrCannotReleaseNonWarehouse
}
if !player.Service.Pet.UpdateFree(data.CatchTime, 1) {
return nil, errorcode.ErrorCodes.ErrSystemError
if !player.Service.Pet.UpdateFree(data.CatchTime, 0, 1) {
return nil, errorcode.ErrorCodes.ErrCannotReleaseNonWarehouse
}
return nil, 0

View File

@@ -76,8 +76,12 @@ func (s *PetService) PetCount(flag int) int {
return ret
}
func (s *PetService) UpdateFree(catchTime, free uint32) bool {
res, err := s.dbm(s.Model).Where("catch_time", catchTime).Data("free", free).Update()
func (s *PetService) UpdateFree(catchTime, fromFree, toFree uint32) bool {
res, err := s.dbm(s.Model).
Where("catch_time", catchTime).
Where("free", fromFree).
Data("free", toFree).
Update()
if err != nil {
return false
}