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

This commit is contained in:
xinian
2026-02-17 22:56:55 +08:00
committed by cnb
parent 6b1a2c6f99
commit eee65f0f55
2 changed files with 30 additions and 15 deletions

View File

@@ -50,26 +50,41 @@ func (s *ShinyService) RandShiny(id uint32) *model.ColorfulSkin {
dbm_enable(s.Model).
Wheref(`bind_elf_ids @> ?::jsonb`, id).
Wheref(`jsonb_typeof(bind_elf_ids) = ?`, "array").Scan(&ret)
var rets []model.ColorfulSkin
var props []int
for _, v := range ret {
//print(v.ID)
rets = append(rets, v)
props = append(props, int(v.ElfProbability))
id := v.ID
if grand.Meet(int(v.ElfProbability), 1000) {
if cool.Config.ServerInfo.IsVip == 0 {
m := cool.DBM(s.Model).Where("id", id)
m.Increment("refresh_count", 1)
}
return &v
}
}
return nil
r, _ := utils.RandomByWeight(rets, props)
if cool.Config.ServerInfo.IsVip == 0 {
m := cool.DBM(s.Model).Where("id", id)
m.Increment("refresh_count", 1)
}
// for _, v := range ret {
// //print(v.ID)
// id := v.ID
// if grand.Meet(int(v.ElfProbability), 1000) {
// if cool.Config.ServerInfo.IsVip == 0 {
// m := cool.DBM(s.Model).Where("id", id)
// m.Increment("refresh_count", 1)
// }
// return &v
// }
// }
return &r
}
// 强制随机
func (s *ShinyService) FixShiny(id uint32) *model.ColorfulSkin {
var ret []model.ColorfulSkin