From f8ba7988d0f46e8dca303d5016260e49187df731 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=98=94=E5=BF=B5?= <1@72wo.cn> Date: Thu, 4 Dec 2025 00:26:49 +0800 Subject: [PATCH] =?UTF-8?q?```=20feat(pet):=20=E4=BC=98=E5=8C=96=E5=AE=A0?= =?UTF-8?q?=E7=89=A9=E8=9E=8D=E5=90=88=E9=94=99=E8=AF=AF=E7=A0=81=E5=B9=B6?= =?UTF-8?q?=E8=AE=B0=E5=BD=95=E5=8E=9F=E5=A7=8B=E6=8D=95=E8=8E=B7=E6=97=B6?= =?UTF-8?q?=E9=97=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 将宠物融合过程中的错误码从 ErrSystemBusy 细分为多个更具体的错误码, 如 ErrPokemonNotFusionReady、ErrPokemonNotFusionReady2 等,便于问题定位。 - 在融合成功后,新增记录主宠的旧捕捉时间(OldCatchTime)字段。 - 调整战斗捕捉逻辑,使用对手玩家的第一个宠物信息进行添加,并重置战斗结束原因。 refactor(service): 移除未使用的管理员会话结构体字段和清理部分冗余代码 - 注释掉 base_sys_user.go --- logic/controller/PET_FUSION.go | 11 +++++----- logic/service/fight/loop.go | 3 ++- .../base/controller/admin/base_sys_user.go | 1 + modules/base/service/base_sys_user.go | 2 +- modules/blazing/controller/admin/item.go | 22 +++++++++++++++++++ .../admin/{monster_get.go => pet.go} | 0 modules/blazing/service/item.go | 12 ++++++++++ modules/blazing/service/pet.go | 14 +++++++++--- modules/blazing/service/pet_fusion_service.go | 4 ++-- modules/blazing/service/user.go | 6 ++++- 10 files changed, 62 insertions(+), 13 deletions(-) create mode 100644 modules/blazing/controller/admin/item.go rename modules/blazing/controller/admin/{monster_get.go => pet.go} (100%) diff --git a/logic/controller/PET_FUSION.go b/logic/controller/PET_FUSION.go index 5453d228c..5569d25c7 100644 --- a/logic/controller/PET_FUSION.go +++ b/logic/controller/PET_FUSION.go @@ -18,24 +18,24 @@ func (h Controller) PetFusion(data *pet.C2S_PetFusion, c *player.Player) (result //防止同一只 if data.Mcatchtime == data.Auxcatchtime { - return result, errorcode.ErrorCodes.ErrSystemBusy + return result, errorcode.ErrorCodes.ErrPokemonNotFusionReady } _, Mcatchpetinfo, ok := c.FindPet(data.Mcatchtime) if !ok { - return result, errorcode.ErrorCodes.ErrSystemBusy + return result, errorcode.ErrorCodes.ErrPokemonNotFusionReady2 } if xmlres.PetMAP[int(Mcatchpetinfo.ID)].FuseMaster == 0 { - return result, errorcode.ErrorCodes.ErrSystemBusy + return result, errorcode.ErrorCodes.ErrPokemonNotFusionReady3 } _, Auxpetinfo, ok := c.FindPet(data.Auxcatchtime) if !ok { - return result, errorcode.ErrorCodes.ErrSystemBusy + return result, errorcode.ErrorCodes.ErrPokemonNotFusionReady2 } if xmlres.PetMAP[int(Auxpetinfo.ID)].FuseSub == 0 { - return result, errorcode.ErrorCodes.ErrSystemBusy + return result, errorcode.ErrorCodes.ErrPokemonNotFusionReady3 } ///性格生成 @@ -56,6 +56,7 @@ func (h Controller) PetFusion(data *pet.C2S_PetFusion, c *player.Player) (result dv2 := decimal.NewFromInt(1).Div(decimal.NewFromInt(3)).Mul(decimal.NewFromInt(int64(Auxpetinfo.Dv))) dv := dv1.Add(dv2).Add(decimal.NewFromInt(1)).IntPart() r := model.GenPetInfo(resid, int(dv), int(natureId), effect, -1, 1) + r.OldCatchTime = Mcatchpetinfo.CatchTime c.Service.Pet.PetAdd(r) c.Pet_del(Auxpetinfo.CatchTime) c.Pet_del(Mcatchpetinfo.CatchTime) diff --git a/logic/service/fight/loop.go b/logic/service/fight/loop.go index 789772a49..8d9245b81 100644 --- a/logic/service/fight/loop.go +++ b/logic/service/fight/loop.go @@ -72,12 +72,13 @@ func (f *FightC) battleLoop() { }) if f.Reason == info.BattleOverReason.Cacthok { - f.Our.Player.(*player.Player).Service.Pet.PetAdd(&f.Opp.CurrentPet.Info) + f.Our.Player.(*player.Player).Service.Pet.PetAdd(&f.Opp.Player.GetInfo().PetList[0]) f.Our.Player.SendPackCmd(2409, &info.CatchMonsterOutboundInfo{ CatchTime: uint32(f.Opp.CurrentPet.Info.CatchTime), PetId: uint32(f.Opp.CurrentPet.ID), }) + f.Reason = 0 //清空 } //f.Reason = info.BattleOverReason.PlayerCaptureSuccess diff --git a/modules/base/controller/admin/base_sys_user.go b/modules/base/controller/admin/base_sys_user.go index fca680e33..140f3c894 100644 --- a/modules/base/controller/admin/base_sys_user.go +++ b/modules/base/controller/admin/base_sys_user.go @@ -77,4 +77,5 @@ func (c *BaseSysUserController) GetSession(ctx context.Context, req *SessionReq) type SessionRes struct { UserID int `json:"userid"` Session string `json:"session"` + //Server model.ServerList `json:"server"` } diff --git a/modules/base/service/base_sys_user.go b/modules/base/service/base_sys_user.go index d018b302c..c6f927cac 100644 --- a/modules/base/service/base_sys_user.go +++ b/modules/base/service/base_sys_user.go @@ -308,7 +308,7 @@ func NewBaseSysUserService() *BaseSysUserService { Extend: func(ctx g.Ctx, m *gdb.Model) *gdb.Model { return m.Group(`base_sys_user.id`) }, - KeyWordField: []string{"username", "email"}, + KeyWordField: []string{"username", "email", "id"}, }, }, } diff --git a/modules/blazing/controller/admin/item.go b/modules/blazing/controller/admin/item.go new file mode 100644 index 000000000..4316095b2 --- /dev/null +++ b/modules/blazing/controller/admin/item.go @@ -0,0 +1,22 @@ +package admin + +import ( + "blazing/cool" + "blazing/modules/blazing/service" +) + +type ItemBagController struct { + *cool.Controller +} + +func init() { + var task_info_controller = &ItemBagController{ + &cool.Controller{ + Prefix: "/admin/sun/item", + Api: []string{"Delete", "Update", "Info", "List", "Page"}, + Service: service.NewItemService(0), //因为page已经过滤,所以这里需要改成0 + }, + } + // 注册路由 + cool.RegisterController(task_info_controller) +} diff --git a/modules/blazing/controller/admin/monster_get.go b/modules/blazing/controller/admin/pet.go similarity index 100% rename from modules/blazing/controller/admin/monster_get.go rename to modules/blazing/controller/admin/pet.go diff --git a/modules/blazing/service/item.go b/modules/blazing/service/item.go index 576641f49..4717e1430 100644 --- a/modules/blazing/service/item.go +++ b/modules/blazing/service/item.go @@ -3,6 +3,7 @@ package service import ( "blazing/cool" "blazing/modules/blazing/model" + "context" "github.com/gogf/gf/v2/frame/g" ) @@ -57,6 +58,17 @@ func NewItemService(id uint32) *ItemService { Service: &cool.Service{Model: model.NewPlayerBag(), UniqueKey: map[string]string{ "player_id": "角色名称不能重复", + }, PageQueryOp: &cool.QueryOp{ + Where: func(ctx context.Context) [][]interface{} { + var ( + //admin = cool.GetAdmin(ctx) + //userId = admin.UserId + ) + return [][]interface{}{ + // {"player_id", userId, true}, + // {"free", 0, true}, + } + }, }}, }, } diff --git a/modules/blazing/service/pet.go b/modules/blazing/service/pet.go index 9cd9d9b3d..0ab9e90cd 100644 --- a/modules/blazing/service/pet.go +++ b/modules/blazing/service/pet.go @@ -108,10 +108,18 @@ func NewPetService(userid uint32) *PetService { admin = cool.GetAdmin(ctx) userId = admin.UserId ) - return [][]interface{}{ - {"player_id", userId, true}, - {"free", 0, true}, + if userId != 10001 { + return [][]interface{}{ + {"player_id", userId, true}, + {"free", 0, true}, + } + } else { + return [][]interface{}{ + {"player_id", userId, true}, + {"free", 0, true}, + } } + }, }, }, diff --git a/modules/blazing/service/pet_fusion_service.go b/modules/blazing/service/pet_fusion_service.go index bd3466782..782ecf265 100644 --- a/modules/blazing/service/pet_fusion_service.go +++ b/modules/blazing/service/pet_fusion_service.go @@ -17,8 +17,8 @@ type PetFusionService struct { func NewPetFusionService() *PetFusionService { return &PetFusionService{ &cool.Service{ - Model: model.NewPetFusion(), // 绑定PetFusion模型 - + Model: model.NewPetFusion(), // 绑定PetFusion模型 + PageQueryOp: &cool.QueryOp{FieldEQ: []string{"is_enable", "main_pet_id", "sub_pet_id", "result_pet_id"}}, }, } } diff --git a/modules/blazing/service/user.go b/modules/blazing/service/user.go index 0084b2ce6..52be44860 100644 --- a/modules/blazing/service/user.go +++ b/modules/blazing/service/user.go @@ -33,6 +33,10 @@ func NewUserService(id uint32) *UserService { } func (s *BaseService) GModel(m cool.IModel) *gdb.Model { + if s.userid != 0 { + return cool.DBM(m).Where("player_id", s.userid) + } else { + return cool.DBM(m) + } - return cool.DBM(m).Where("player_id", s.userid) }