```
Some checks failed
ci/woodpecker/push/my-first-workflow Pipeline failed

feat(game): 完善宠物融合逻辑和野外BOSS战斗机制

- 在玩家挑战野外BOSS时添加新的ger变量控制捕捉状态
- 当BOSS被标记为已捕捉(isCapture==1)时同步设置ger为-1
- 将怪物等级参数改为使用ger变量传递
- 重构宠物融合服务的数据处理逻辑
- 优化融合结果的权重随机算法
- 添加默认融合配置的查询方法
- 统一错误处理和返回值逻辑
```
This commit is contained in:
昔念
2026-03-30 21:03:00 +08:00
parent 023128be25
commit 23027ccfde
2 changed files with 37 additions and 23 deletions

View File

@@ -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)

View File

@@ -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)
}