feat(game): 完善宠物融合逻辑和野外BOSS战斗机制 - 在玩家挑战野外BOSS时添加新的ger变量控制捕捉状态 - 当BOSS被标记为已捕捉(isCapture==1)时同步设置ger为-1 - 将怪物等级参数改为使用ger变量传递 - 重构宠物融合服务的数据处理逻辑 - 优化融合结果的权重随机算法 - 添加默认融合配置的查询方法 - 统一错误处理和返回值逻辑 ```
This commit is contained in:
@@ -49,8 +49,10 @@ func (Controller) PlayerFightBoss(data1 *fight.ChallengeBossInboundInfo, p *play
|
|||||||
return nil, errorcode.ErrorCodes.ErrPokemonNotExists
|
return nil, errorcode.ErrorCodes.ErrPokemonNotExists
|
||||||
}
|
}
|
||||||
dv := 24
|
dv := 24
|
||||||
|
ger := 0
|
||||||
if bosinfo[0].IsCapture == 1 {
|
if bosinfo[0].IsCapture == 1 {
|
||||||
dv = -1
|
dv = -1
|
||||||
|
ger = -1
|
||||||
}
|
}
|
||||||
for i, bm := range bosinfo {
|
for i, bm := range bosinfo {
|
||||||
|
|
||||||
@@ -59,7 +61,7 @@ func (Controller) PlayerFightBoss(data1 *fight.ChallengeBossInboundInfo, p *play
|
|||||||
-1,
|
-1,
|
||||||
0, //野怪没特性
|
0, //野怪没特性
|
||||||
|
|
||||||
int(bm.Lv), nil, 0)
|
int(bm.Lv), nil, ger)
|
||||||
monster.CatchTime = uint32(i)
|
monster.CatchTime = uint32(i)
|
||||||
monster.ConfigBoss(bm.PetBaseConfig)
|
monster.ConfigBoss(bm.PetBaseConfig)
|
||||||
effects := service.NewEffectService().Args(bm.Effect)
|
effects := service.NewEffectService().Args(bm.Effect)
|
||||||
|
|||||||
@@ -35,6 +35,23 @@ func (s *PetFusionService) Data(p1, p2, rand uint32) uint32 {
|
|||||||
|
|
||||||
pet := s.getData(p1, p2)
|
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 {
|
if len(pet) != 0 {
|
||||||
var pets, props []int
|
var pets, props []int
|
||||||
|
|
||||||
@@ -46,34 +63,29 @@ func (s *PetFusionService) Data(p1, p2, rand uint32) uint32 {
|
|||||||
t, _ := utils.RandomByWeight(pets, props)
|
t, _ := utils.RandomByWeight(pets, props)
|
||||||
return uint32(t)
|
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
|
return 0
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s *PetFusionService) def() uint32 {
|
||||||
|
|
||||||
|
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
|
||||||
|
|
||||||
}
|
|
||||||
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
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
func (s *PetFusionService) def() []model.PetFusion {
|
|
||||||
|
|
||||||
var pets []model.PetFusion
|
|
||||||
dbm_enable(s.Model).Where("is_default", 1).Scan(&pets)
|
|
||||||
|
|
||||||
return pets
|
|
||||||
// return ret.Interface().([]model.PetFusion)
|
// return ret.Interface().([]model.PetFusion)
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user