```
All checks were successful
ci/woodpecker/push/my-first-workflow Pipeline was successful

fix(config): 修复宠物蛋系统中概率计算错误

- 修正了EggService中宠物产出概率计算时错误使用的字段名
- 将pet.OutputMons修正为pet.Probs以正确累加等级权重

refactor(player): 优化金币列表服务参数处理逻辑

- 移除未使用的gconv导入包
- 简化ModifyBefore方法中的用户ID验证逻辑
- 统一设置
This commit is contained in:
昔念
2026-03-19 15:08:14 +08:00
parent b558f46d7a
commit baf0d1fc06
2 changed files with 2 additions and 7 deletions

View File

@@ -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.OutputMons[len(pet.OutputMons)-1] += int32(level)
pet.Probs[len(pet.OutputMons)-1] += int32(level)
t, _ := utils.RandomByWeight(pet.OutputMons, pet.Probs)
if pet.OutputMons[len(pet.OutputMons)-1] == int32(t) {
return uint32(t), true

View File

@@ -7,7 +7,6 @@ import (
"fmt"
"github.com/gogf/gf/v2/frame/g"
"github.com/gogf/gf/v2/util/gconv"
)
type GoldListService struct {
@@ -18,16 +17,12 @@ func (s *GoldListService) ModifyBefore(ctx context.Context, method string, param
admin := cool.GetAdmin(ctx)
userId := admin.UserId
s.userid = uint32(userId)
param["player_id"] = userId
if method == "Add" {
t, _ := s.dbm_fix(s.Model).Count()
if t > 0 {
return fmt.Errorf("不允许多挂单")
}
} else {
if userId != gconv.Uint(param["player_id"]) {
err = fmt.Errorf("修改失败")
}
}
return