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