This commit is contained in:
@@ -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
|
||||
|
||||
|
||||
Reference in New Issue
Block a user