fix(fight): 修正空变更导致的潜在逻辑问题

This commit is contained in:
1
2025-12-02 02:50:20 +00:00
parent b000747536
commit e694848c0d
2 changed files with 17 additions and 3 deletions

View File

@@ -46,14 +46,23 @@ func (s *PetFusionService) Data(p1, p2 uint32) uint32 {
return uint32(v.ResultPetID)
}
}
//说明是失败,直接返回失败
if len(pet) > 0 {
return 0
}
var pets []model.PetFusion
m = cool.DBM(s.Model)
m.Where("is_enable", 1).Where("is_default", 1).Scan(&pets)
if len(pets) == 0 {
return 0
}
res := pets[grand.Intn(len(pets)-1)]
rr := grand.Intn(100)
if rr < int(res.Probability) {
return uint32(res.ResultPetID)
}
return uint32(pets[grand.Intn(len(pets)-1)].ID)
return 0
}