diff --git a/common/cool/service.go b/common/cool/service.go index 4dab99e3c..158cdfd5f 100644 --- a/common/cool/service.go +++ b/common/cool/service.go @@ -419,7 +419,8 @@ func (s *Service) ModifyAfter(ctx context.Context, method string, param g.MapStr // } - g.DB().GetCore().ClearCache(context.TODO(), s.Model.TableName()) + er1 := g.DB().GetCore().ClearCache(context.TODO(), s.Model.TableName()) + println(er1) return } diff --git a/help/查询是否连续包含.sql b/help/查询是否连续包含.sql new file mode 100644 index 000000000..329ef7e9e --- /dev/null +++ b/help/查询是否连续包含.sql @@ -0,0 +1,6 @@ +-- 查询 prop 数组包含 [212, 305] 这个连续子数组的记录 +SELECT * +FROM "config_pet_melee" +WHERE prop @> '[212, 305]'::jsonb + AND jsonb_typeof(prop) = 'array' +LIMIT 50; \ No newline at end of file diff --git a/logic/service/player/player.go b/logic/service/player/player.go index f25f71f43..081c305e0 100644 --- a/logic/service/player/player.go +++ b/logic/service/player/player.go @@ -14,6 +14,7 @@ import ( "blazing/modules/base/service" blservice "blazing/modules/blazing/service" + config "blazing/modules/config/service" "context" "github.com/antlabs/timer" @@ -49,31 +50,34 @@ type OgrePetInfo struct { } func (o *OgrePetInfo) RandSHiny(t int64) { - o.ShinyInfo = make([]data.GlowFilter, 1) - // 假设 t 是包含 ShinyInfo 字段的结构体,ShinyInfo 是 GlowFilter 类型的切片 - o.ShinyInfo[0] = data.GlowFilter{ - // 光晕颜色:白色(十六进制 0xFFFFFF),符合 uint32 类型 - Color: 65535, - // 透明度:0.8(0.0~1.0 范围内的合理值,float64 类型) - Alpha: 0.3, - // 水平模糊量:10(0~255 范围内,uint8 类型,略高于默认值6) - BlurX: 20, - // 垂直模糊量:10(与 BlurX 对称,uint8 类型) - BlurY: 20, - // 发光强度:8(0~255 范围内,uint8 类型,略高于默认值2) - Strength: 1, - // 滤镜应用次数:2(1~3 范围内,int 类型,非默认值1) - Quality: 2, - // 内侧发光:true(bool 类型,模拟开启内侧发光) - Inner: true, - // 挖空:false(bool 类型,保持默认逻辑) - Knockout: false, - // 颜色矩阵:标准 RGBA 矩阵(20个uint8,符合 [20]uint8 数组类型) - // 矩阵含义:R=100%、G=100%、B=100%、A=100%,无颜色偏移 + // o.ShinyInfo = make([]data.GlowFilter, 1) + // // 假设 t 是包含 ShinyInfo 字段的结构体,ShinyInfo 是 GlowFilter 类型的切片 + // o.ShinyInfo[0] = data.GlowFilter{ + // // 光晕颜色:白色(十六进制 0xFFFFFF),符合 uint32 类型 + // Color: 65535, + // // 透明度:0.8(0.0~1.0 范围内的合理值,float64 类型) + // Alpha: 0.3, + // // 水平模糊量:10(0~255 范围内,uint8 类型,略高于默认值6) + // BlurX: 20, + // // 垂直模糊量:10(与 BlurX 对称,uint8 类型) + // BlurY: 20, + // // 发光强度:8(0~255 范围内,uint8 类型,略高于默认值2) + // Strength: 1, + // // 滤镜应用次数:2(1~3 范围内,int 类型,非默认值1) + // Quality: 2, + // // 内侧发光:true(bool 类型,模拟开启内侧发光) + // Inner: true, + // // 挖空:false(bool 类型,保持默认逻辑) + // Knockout: false, + // // 颜色矩阵:标准 RGBA 矩阵(20个uint8,符合 [20]uint8 数组类型) + // // 矩阵含义:R=100%、G=100%、B=100%、A=100%,无颜色偏移 + // } + co := config.NewShinyService().Args(o.Id) + if co != nil { + o.ShinyInfo = append(o.ShinyInfo, *co) } - - o.ShinyInfo[0].ColorMatrixFilter = GenerateRandomOffspringMatrix().Get() + //o.ShinyInfo[0].ColorMatrixFilter = GenerateRandomOffspringMatrix().Get() //g.Dump(ttt.ShinyInfo) // ttt.Shiny = 0 //待确认是否刷新异色 } diff --git a/login/main.go b/login/main.go index a7428d57a..4ff86d590 100644 --- a/login/main.go +++ b/login/main.go @@ -27,6 +27,7 @@ func init() { } func main() { + // service.NewShinyService().Args(53) //player.TestPureMatrixSplit() // for _, i := range xmlres.ItemsMAP { diff --git a/modules/config/model/shiny.go b/modules/config/model/shiny.go index 5a0ef661f..e895e89e3 100644 --- a/modules/config/model/shiny.go +++ b/modules/config/model/shiny.go @@ -11,7 +11,7 @@ const ( // ColorfulSkin 炫彩皮肤核心配置模型(完整保留原有字段,仅更名适配) type ColorfulSkin struct { - *cool.Model `json:"-" gorm:"embedded"` // 嵌入通用Model(ID/创建时间/更新时间,不参与json序列化) + *cool.Model // 核心必填字段 Color string `gorm:"not null;default:'';comment:'炫彩皮肤颜色(唯一标识每条配置)'" json:"color" description:"炫彩皮肤颜色"` @@ -20,7 +20,7 @@ type ColorfulSkin struct { Author string `gorm:"not null;size:64;default:'';comment:'炫彩皮肤配置作者(创建人/配置者名称)'" json:"author" description:"作者"` RefreshCount uint32 `gorm:"not null;default:0;comment:'累计刷新次数(炫彩皮肤外观刷新次数统计)'" json:"refresh_count" description:"刷新次数"` UsageCount uint32 `gorm:"not null;default:0;comment:'累计使用次数(炫彩皮肤使用次数统计)'" json:"usage_count" description:"使用次数"` - BindElfIds []uint32 `gorm:"not null;type:json;default:'[]';comment:'绑定精灵ID数组,关联config_pet_boss表主键,空数组表示未绑定具体精灵'" json:"bind_elf_ids" description:"绑定精灵数组"` + BindElfIds []uint32 `gorm:"not null;type:jsonb;default:'[]';comment:'绑定精灵ID数组,关联config_pet_boss表主键,空数组表示未绑定具体精灵'" json:"bind_elf_ids" description:"绑定精灵数组"` //野生精灵概率 ElfProbability uint32 `gorm:"not null;default:0;comment:'野生精灵概率(0-10000)'" json:"elf_probability" description:"野生精灵概率"` diff --git a/modules/config/service/shiny.go b/modules/config/service/shiny.go index ce2d9da16..630bd9b02 100644 --- a/modules/config/service/shiny.go +++ b/modules/config/service/shiny.go @@ -1,11 +1,15 @@ package service import ( + "blazing/common/data" "blazing/cool" "blazing/modules/config/model" "context" + "encoding/json" + "github.com/gogf/gf/v2/database/gdb" "github.com/gogf/gf/v2/frame/g" + "github.com/gogf/gf/v2/util/grand" ) type ShinyService struct { @@ -26,3 +30,34 @@ func NewShinyService() *ShinyService { }, } } + +func (s *ShinyService) Args(id uint32) *data.GlowFilter { + var ret []model.ColorfulSkin + + // 执行 Raw SQL 并扫描返回值 + cool.DBM(s.Model).Wheref(`bind_elf_ids @> ?::jsonb`, id).Wheref(`jsonb_typeof(bind_elf_ids) = ?`, "array").Cache(gdb.CacheOption{ + // Duration: time.Hour, + + Force: false, + }).Scan(&ret) + + for _, v := range ret { + //print(v.ID) + + id := v.ID + + if grand.Meet(int(v.ElfProbability), 1000) { + var t data.GlowFilter + + r := json.Unmarshal([]byte(v.Color), &t) + if r == nil { + m := cool.DBM(s.Model).Where("id", id) + m.Increment("refresh_count", 1) + return &t + } + + } + } + + return nil +}