fix(config): 修复宠物概率计算中的数组索引错误 - 修正了EggService.GetResult方法中对pet.Probs数组的索引访问 - 将原来的pet.Probs[len(pet.OutputMons)-1]改为pet.Probs[len(pet.Probs)-1] - 确保数组边界安全,避免潜在的运行时panic ```
This commit is contained in:
@@ -43,7 +43,7 @@ func (s *EggService) GetResult(m, f, level uint32) (uint32, bool) {
|
||||
md.Wheref(`male_pet_ids @> ARRAY[?]::integer[]`, m).
|
||||
Wheref(`female_pet_ids @> ARRAY[?]::integer[]`, f).Scan(&pet)
|
||||
if pet != nil {
|
||||
pet.Probs[len(pet.OutputMons)-1] += int32(level)
|
||||
pet.Probs[len(pet.Probs)-1] += int32(level)
|
||||
t, _ := utils.RandomByWeight(pet.OutputMons, pet.Probs)
|
||||
if pet.OutputMons[len(pet.OutputMons)-1] == int32(t) {
|
||||
return uint32(t), true
|
||||
|
||||
Reference in New Issue
Block a user