From 23027ccfde502f969d5c2bf2f91456c5ca9800b4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=98=94=E5=BF=B5?= <12574910+72wo@users.noreply.github.com> Date: Mon, 30 Mar 2026 21:03:00 +0800 Subject: [PATCH] =?UTF-8?q?```=20feat(game):=20=E5=AE=8C=E5=96=84=E5=AE=A0?= =?UTF-8?q?=E7=89=A9=E8=9E=8D=E5=90=88=E9=80=BB=E8=BE=91=E5=92=8C=E9=87=8E?= =?UTF-8?q?=E5=A4=96BOSS=E6=88=98=E6=96=97=E6=9C=BA=E5=88=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 在玩家挑战野外BOSS时添加新的ger变量控制捕捉状态 - 当BOSS被标记为已捕捉(isCapture==1)时同步设置ger为-1 - 将怪物等级参数改为使用ger变量传递 - 重构宠物融合服务的数据处理逻辑 - 优化融合结果的权重随机算法 - 添加默认融合配置的查询方法 - 统一错误处理和返回值逻辑 ``` --- logic/controller/fight_boss野怪和地图怪.go | 4 +- modules/config/service/pet_fusion_service.go | 56 ++++++++++++-------- 2 files changed, 37 insertions(+), 23 deletions(-) diff --git a/logic/controller/fight_boss野怪和地图怪.go b/logic/controller/fight_boss野怪和地图怪.go index 82b949ddb..4eae9927b 100644 --- a/logic/controller/fight_boss野怪和地图怪.go +++ b/logic/controller/fight_boss野怪和地图怪.go @@ -49,8 +49,10 @@ func (Controller) PlayerFightBoss(data1 *fight.ChallengeBossInboundInfo, p *play return nil, errorcode.ErrorCodes.ErrPokemonNotExists } dv := 24 + ger := 0 if bosinfo[0].IsCapture == 1 { dv = -1 + ger = -1 } for i, bm := range bosinfo { @@ -59,7 +61,7 @@ func (Controller) PlayerFightBoss(data1 *fight.ChallengeBossInboundInfo, p *play -1, 0, //野怪没特性 - int(bm.Lv), nil, 0) + int(bm.Lv), nil, ger) monster.CatchTime = uint32(i) monster.ConfigBoss(bm.PetBaseConfig) effects := service.NewEffectService().Args(bm.Effect) diff --git a/modules/config/service/pet_fusion_service.go b/modules/config/service/pet_fusion_service.go index 18a870dc8..cb6d496d6 100644 --- a/modules/config/service/pet_fusion_service.go +++ b/modules/config/service/pet_fusion_service.go @@ -35,6 +35,23 @@ func (s *PetFusionService) Data(p1, p2, rand uint32) uint32 { pet := s.getData(p1, p2) + if pet != 0 { + + return uint32(pet) + //说明是失败,直接返回失败 + } else { + + pets := s.def() + + //到这里相当于直接失败 + return pets + } + +} +func (s *PetFusionService) getData(p1, p2 uint32) uint32 { + + var pet []model.PetFusion //一个特性应该是唯一的,但是我们要获取默认随机特性 + dbm_enable(s.Model).Where("main_pet_id", p1).Wheref(`sub_pet_ids @> ARRAY[?]::integer[]`, p2).Scan(&pet) if len(pet) != 0 { var pets, props []int @@ -46,34 +63,29 @@ func (s *PetFusionService) Data(p1, p2, rand uint32) uint32 { t, _ := utils.RandomByWeight(pets, props) return uint32(t) //说明是失败,直接返回失败 - } else { - - pets := s.def() - res := pets[grand.Intn(len(pets))] - rr := grand.Intn(100) - if rr < int(res.Probability+int32(rand)) { - return uint32(res.ResultPetID) - } - //到这里相当于直接失败 - return 0 } - -} -func (s *PetFusionService) getData(p1, p2 uint32) []model.PetFusion { - - var pet []model.PetFusion //一个特性应该是唯一的,但是我们要获取默认随机特性 - dbm_enable(s.Model).Where("main_pet_id", p1).Wheref(`sub_pet_ids @> ARRAY[?]::integer[]`, p2).Scan(&pet) - - return pet + return 0 } -func (s *PetFusionService) def() []model.PetFusion { +func (s *PetFusionService) def() uint32 { - var pets []model.PetFusion - dbm_enable(s.Model).Where("is_default", 1).Scan(&pets) + var pet []model.PetFusion + dbm_enable(s.Model).Where("is_default", 1).Scan(&pet) + if len(pet) != 0 { + var pets, props []int + + for _, v := range pet { + pets = append(pets, int(v.ResultPetID)) + props = append(props, int(v.Probability)) + + } + t, _ := utils.RandomByWeight(pets, props) + return uint32(t) + //说明是失败,直接返回失败 + } + return 0 - return pets // return ret.Interface().([]model.PetFusion) }