```
feat(config): 添加炫彩皮肤配置服务和数据库查询功能 - 新增ShinyService服务,提供Args方法用于根据ID查询炫彩皮肤配置 - 修改ColorfulSkin模型,将BindElfIds字段的gorm类型从json改为jsonb以支持数组查询 - 移除ColorfulSkin模型中嵌入的cool.Model的json标签,优化序列化 - 实现基于JSONB数组查询的精灵绑定功能,支持概率随机和刷新计数统计 debug(common): 添加数据库缓存清除调试信息 - 在ModifyAfter方法中添加er1变量接收ClearCache返回值 - 使用println输出缓存清除结果,便于调试缓存机制 refactor(player): 重构玩家宠物异色信息生成逻辑 - 引入config服务包,通过配置动态生成宠物炫彩效果 - 注释掉原有的固定炫彩效果生成代码 - 添加条件判断,仅当配置存在时才
This commit is contained in:
@@ -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
|
return
|
||||||
}
|
}
|
||||||
|
|||||||
6
help/查询是否连续包含.sql
Normal file
6
help/查询是否连续包含.sql
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
-- 查询 prop 数组包含 [212, 305] 这个连续子数组的记录
|
||||||
|
SELECT *
|
||||||
|
FROM "config_pet_melee"
|
||||||
|
WHERE prop @> '[212, 305]'::jsonb
|
||||||
|
AND jsonb_typeof(prop) = 'array'
|
||||||
|
LIMIT 50;
|
||||||
@@ -14,6 +14,7 @@ import (
|
|||||||
"blazing/modules/base/service"
|
"blazing/modules/base/service"
|
||||||
|
|
||||||
blservice "blazing/modules/blazing/service"
|
blservice "blazing/modules/blazing/service"
|
||||||
|
config "blazing/modules/config/service"
|
||||||
"context"
|
"context"
|
||||||
|
|
||||||
"github.com/antlabs/timer"
|
"github.com/antlabs/timer"
|
||||||
@@ -49,31 +50,34 @@ type OgrePetInfo struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (o *OgrePetInfo) RandSHiny(t int64) {
|
func (o *OgrePetInfo) RandSHiny(t int64) {
|
||||||
o.ShinyInfo = make([]data.GlowFilter, 1)
|
// o.ShinyInfo = make([]data.GlowFilter, 1)
|
||||||
// 假设 t 是包含 ShinyInfo 字段的结构体,ShinyInfo 是 GlowFilter 类型的切片
|
// // 假设 t 是包含 ShinyInfo 字段的结构体,ShinyInfo 是 GlowFilter 类型的切片
|
||||||
o.ShinyInfo[0] = data.GlowFilter{
|
// o.ShinyInfo[0] = data.GlowFilter{
|
||||||
// 光晕颜色:白色(十六进制 0xFFFFFF),符合 uint32 类型
|
// // 光晕颜色:白色(十六进制 0xFFFFFF),符合 uint32 类型
|
||||||
Color: 65535,
|
// Color: 65535,
|
||||||
// 透明度:0.8(0.0~1.0 范围内的合理值,float64 类型)
|
// // 透明度:0.8(0.0~1.0 范围内的合理值,float64 类型)
|
||||||
Alpha: 0.3,
|
// Alpha: 0.3,
|
||||||
// 水平模糊量:10(0~255 范围内,uint8 类型,略高于默认值6)
|
// // 水平模糊量:10(0~255 范围内,uint8 类型,略高于默认值6)
|
||||||
BlurX: 20,
|
// BlurX: 20,
|
||||||
// 垂直模糊量:10(与 BlurX 对称,uint8 类型)
|
// // 垂直模糊量:10(与 BlurX 对称,uint8 类型)
|
||||||
BlurY: 20,
|
// BlurY: 20,
|
||||||
// 发光强度:8(0~255 范围内,uint8 类型,略高于默认值2)
|
// // 发光强度:8(0~255 范围内,uint8 类型,略高于默认值2)
|
||||||
Strength: 1,
|
// Strength: 1,
|
||||||
// 滤镜应用次数:2(1~3 范围内,int 类型,非默认值1)
|
// // 滤镜应用次数:2(1~3 范围内,int 类型,非默认值1)
|
||||||
Quality: 2,
|
// Quality: 2,
|
||||||
// 内侧发光:true(bool 类型,模拟开启内侧发光)
|
// // 内侧发光:true(bool 类型,模拟开启内侧发光)
|
||||||
Inner: true,
|
// Inner: true,
|
||||||
// 挖空:false(bool 类型,保持默认逻辑)
|
// // 挖空:false(bool 类型,保持默认逻辑)
|
||||||
Knockout: false,
|
// Knockout: false,
|
||||||
// 颜色矩阵:标准 RGBA 矩阵(20个uint8,符合 [20]uint8 数组类型)
|
// // 颜色矩阵:标准 RGBA 矩阵(20个uint8,符合 [20]uint8 数组类型)
|
||||||
// 矩阵含义:R=100%、G=100%、B=100%、A=100%,无颜色偏移
|
// // 矩阵含义: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)
|
//g.Dump(ttt.ShinyInfo)
|
||||||
// ttt.Shiny = 0 //待确认是否刷新异色
|
// ttt.Shiny = 0 //待确认是否刷新异色
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -27,6 +27,7 @@ func init() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
|
// service.NewShinyService().Args(53)
|
||||||
//player.TestPureMatrixSplit()
|
//player.TestPureMatrixSplit()
|
||||||
// for _, i := range xmlres.ItemsMAP {
|
// for _, i := range xmlres.ItemsMAP {
|
||||||
|
|
||||||
|
|||||||
@@ -11,7 +11,7 @@ const (
|
|||||||
|
|
||||||
// ColorfulSkin 炫彩皮肤核心配置模型(完整保留原有字段,仅更名适配)
|
// ColorfulSkin 炫彩皮肤核心配置模型(完整保留原有字段,仅更名适配)
|
||||||
type ColorfulSkin struct {
|
type ColorfulSkin struct {
|
||||||
*cool.Model `json:"-" gorm:"embedded"` // 嵌入通用Model(ID/创建时间/更新时间,不参与json序列化)
|
*cool.Model
|
||||||
|
|
||||||
// 核心必填字段
|
// 核心必填字段
|
||||||
Color string `gorm:"not null;default:'';comment:'炫彩皮肤颜色(唯一标识每条配置)'" json:"color" description:"炫彩皮肤颜色"`
|
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:"作者"`
|
Author string `gorm:"not null;size:64;default:'';comment:'炫彩皮肤配置作者(创建人/配置者名称)'" json:"author" description:"作者"`
|
||||||
RefreshCount uint32 `gorm:"not null;default:0;comment:'累计刷新次数(炫彩皮肤外观刷新次数统计)'" json:"refresh_count" 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:"使用次数"`
|
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:"野生精灵概率"`
|
ElfProbability uint32 `gorm:"not null;default:0;comment:'野生精灵概率(0-10000)'" json:"elf_probability" description:"野生精灵概率"`
|
||||||
|
|
||||||
|
|||||||
@@ -1,11 +1,15 @@
|
|||||||
package service
|
package service
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"blazing/common/data"
|
||||||
"blazing/cool"
|
"blazing/cool"
|
||||||
"blazing/modules/config/model"
|
"blazing/modules/config/model"
|
||||||
"context"
|
"context"
|
||||||
|
"encoding/json"
|
||||||
|
|
||||||
|
"github.com/gogf/gf/v2/database/gdb"
|
||||||
"github.com/gogf/gf/v2/frame/g"
|
"github.com/gogf/gf/v2/frame/g"
|
||||||
|
"github.com/gogf/gf/v2/util/grand"
|
||||||
)
|
)
|
||||||
|
|
||||||
type ShinyService struct {
|
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
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user