This commit is contained in:
@@ -42,7 +42,7 @@ func (s *ShinyService) ModifyBefore(ctx context.Context, method string, param g.
|
||||
}
|
||||
return nil
|
||||
}
|
||||
func (s *ShinyService) RandShiny(id uint32) *data.GlowFilter {
|
||||
func (s *ShinyService) RandShiny(id uint32) *model.ColorfulSkin {
|
||||
var ret []model.ColorfulSkin
|
||||
|
||||
// 执行 Raw SQL 并扫描返回值
|
||||
@@ -57,24 +57,20 @@ func (s *ShinyService) RandShiny(id uint32) *data.GlowFilter {
|
||||
id := v.ID
|
||||
|
||||
if grand.Meet(int(v.ElfProbability), 1000) {
|
||||
var t data.GlowFilter
|
||||
|
||||
r := json.Unmarshal([]byte(v.Color), &t)
|
||||
if r == nil {
|
||||
if cool.Config.ServerInfo.IsVip == 0 {
|
||||
m := cool.DBM(s.Model).Where("id", id)
|
||||
m.Increment("refresh_count", 1)
|
||||
}
|
||||
|
||||
return &t
|
||||
if cool.Config.ServerInfo.IsVip == 0 {
|
||||
m := cool.DBM(s.Model).Where("id", id)
|
||||
m.Increment("refresh_count", 1)
|
||||
}
|
||||
|
||||
return &v
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
func (s *ShinyService) FixShiny(id uint32) *data.GlowFilter {
|
||||
func (s *ShinyService) FixShiny(id uint32) *model.ColorfulSkin {
|
||||
var ret []model.ColorfulSkin
|
||||
|
||||
// 执行 Raw SQL 并扫描返回值
|
||||
@@ -87,17 +83,26 @@ func (s *ShinyService) FixShiny(id uint32) *data.GlowFilter {
|
||||
}
|
||||
v := ret[grand.Intn(len(ret))]
|
||||
|
||||
var t data.GlowFilter
|
||||
|
||||
r := json.Unmarshal([]byte(v.Color), &t)
|
||||
if r == nil {
|
||||
if cool.Config.ServerInfo.IsVip == 0 {
|
||||
m := cool.DBM(s.Model).Where("id", v.ID)
|
||||
m.Increment("usage_count", 1)
|
||||
}
|
||||
|
||||
return &t
|
||||
if cool.Config.ServerInfo.IsVip == 0 {
|
||||
m := cool.DBM(s.Model).Where("id", v.ID)
|
||||
m.Increment("usage_count", 1)
|
||||
}
|
||||
|
||||
return &v
|
||||
|
||||
}
|
||||
func (s *ShinyService) GetShiny(id int) *data.GlowFilter {
|
||||
var ret []model.ColorfulSkin
|
||||
|
||||
// 执行 Raw SQL 并扫描返回值
|
||||
dbm(s.Model).
|
||||
Where("id", id).Scan(&ret)
|
||||
if len(ret) == 0 {
|
||||
return nil
|
||||
}
|
||||
v := ret[grand.Intn(len(ret))]
|
||||
|
||||
return &v.Color
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user