diff --git a/modules/config/service/shiny.go b/modules/config/service/shiny.go index f2a372e3..ca59eb0e 100644 --- a/modules/config/service/shiny.go +++ b/modules/config/service/shiny.go @@ -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 diff --git a/modules/player/model/pet.go b/modules/player/model/pet.go index db049c6a..851296eb 100644 --- a/modules/player/model/pet.go +++ b/modules/player/model/pet.go @@ -224,7 +224,7 @@ func (pet *PetInfo) RandShiny() { // ttt.Shiny = 0 //待确认是否刷新异色 } -// 强制选色 +// 强制选色,这个是给熔炉用的 func (pet *PetInfo) FixShiny() { co := service.NewShinyService().FixShiny(pet.ID)