feat(data): 重构颜色矩阵处理逻辑,将GlowFilter和相关功能迁移到common/data包
This commit is contained in:
7
modules/config/blazing.go
Normal file
7
modules/config/blazing.go
Normal file
@@ -0,0 +1,7 @@
|
||||
package blazing
|
||||
|
||||
import (
|
||||
_ "blazing/modules/config/controller"
|
||||
_ "blazing/modules/config/model"
|
||||
_ "blazing/modules/config/service"
|
||||
)
|
||||
22
modules/config/controller/admin/boss.go
Normal file
22
modules/config/controller/admin/boss.go
Normal file
@@ -0,0 +1,22 @@
|
||||
package admin
|
||||
|
||||
import (
|
||||
"blazing/cool"
|
||||
"blazing/modules/config/service"
|
||||
)
|
||||
|
||||
type BossController struct {
|
||||
*cool.Controller
|
||||
}
|
||||
|
||||
func init() {
|
||||
var task_info_controller = &BossController{
|
||||
&cool.Controller{
|
||||
Prefix: "/admin/monster/boss",
|
||||
Api: []string{"Add", "Delete", "Update", "Info", "List", "Page"},
|
||||
Service: service.NewBossService(),
|
||||
},
|
||||
}
|
||||
// 注册路由
|
||||
cool.RegisterController(task_info_controller)
|
||||
}
|
||||
40
modules/config/controller/admin/effec.go
Normal file
40
modules/config/controller/admin/effec.go
Normal file
@@ -0,0 +1,40 @@
|
||||
package admin
|
||||
|
||||
import (
|
||||
"blazing/cool"
|
||||
_ "blazing/logic/service/fight/boss"
|
||||
"blazing/logic/service/fight/input"
|
||||
"blazing/modules/config/service"
|
||||
|
||||
"context"
|
||||
|
||||
"github.com/gogf/gf/v2/frame/g"
|
||||
)
|
||||
|
||||
type EffectController struct {
|
||||
*cool.Controller
|
||||
}
|
||||
|
||||
func init() {
|
||||
var task_info_controller = &EffectController{
|
||||
&cool.Controller{
|
||||
Prefix: "/admin/monster/effect",
|
||||
Api: []string{"Add", "Delete", "Update", "Info", "List", "Page"},
|
||||
Service: service.NewEffectService(),
|
||||
},
|
||||
}
|
||||
// 注册路由
|
||||
cool.RegisterController(task_info_controller)
|
||||
}
|
||||
|
||||
type EffIDReq struct {
|
||||
g.Meta `path:"/effid" method:"GET"`
|
||||
}
|
||||
|
||||
func (c *EffectController) GetSession(ctx context.Context, req *EffIDReq) (res *cool.BaseRes, err error) {
|
||||
res = &cool.BaseRes{}
|
||||
res.Data = input.GeteffectIDs(input.EffectType.NewSel)
|
||||
|
||||
return
|
||||
|
||||
}
|
||||
22
modules/config/controller/admin/melee.go
Normal file
22
modules/config/controller/admin/melee.go
Normal file
@@ -0,0 +1,22 @@
|
||||
package admin
|
||||
|
||||
import (
|
||||
"blazing/cool"
|
||||
"blazing/modules/config/service"
|
||||
)
|
||||
|
||||
type MeleeController struct {
|
||||
*cool.Controller
|
||||
}
|
||||
|
||||
func init() {
|
||||
var task_info_controller = &MeleeController{
|
||||
&cool.Controller{
|
||||
Prefix: "/admin/monster/melee",
|
||||
Api: []string{"Add", "Delete", "Update", "Info", "List", "Page"},
|
||||
Service: service.NewMELEEService(),
|
||||
},
|
||||
}
|
||||
// 注册路由
|
||||
cool.RegisterController(task_info_controller)
|
||||
}
|
||||
22
modules/config/controller/admin/monster_refresh.go
Normal file
22
modules/config/controller/admin/monster_refresh.go
Normal file
@@ -0,0 +1,22 @@
|
||||
package admin
|
||||
|
||||
import (
|
||||
"blazing/cool"
|
||||
"blazing/modules/config/service"
|
||||
)
|
||||
|
||||
type TaskInfoController struct {
|
||||
*cool.Controller
|
||||
}
|
||||
|
||||
func init() {
|
||||
var task_info_controller = &TaskInfoController{
|
||||
&cool.Controller{
|
||||
Prefix: "/admin/monster/refresh",
|
||||
Api: []string{"Add", "Delete", "Update", "Info", "List", "Page"},
|
||||
Service: service.NewMonsterService(),
|
||||
},
|
||||
}
|
||||
// 注册路由
|
||||
cool.RegisterController(task_info_controller)
|
||||
}
|
||||
24
modules/config/controller/admin/pet_fusion_controller.go
Normal file
24
modules/config/controller/admin/pet_fusion_controller.go
Normal file
@@ -0,0 +1,24 @@
|
||||
package admin
|
||||
|
||||
import (
|
||||
"blazing/cool"
|
||||
"blazing/modules/config/service"
|
||||
)
|
||||
|
||||
// PetFusionController 宠物融合配方主表Admin控制器(对应/admin/pet/fusion路由)
|
||||
type PetFusionController struct {
|
||||
*cool.Controller
|
||||
}
|
||||
|
||||
func init() {
|
||||
// 初始化控制器,配置路由前缀、支持的API、绑定Service
|
||||
var petFusionController = &PetFusionController{
|
||||
&cool.Controller{
|
||||
Prefix: "/admin/pet/fusion", // 路由前缀(按模块分类:宠物-融合配方)
|
||||
Api: []string{"Add", "Delete", "Update", "Info", "List", "Page"}, // 支持的基础CRUD接口
|
||||
Service: service.NewPetFusionService(), // 绑定主表Service
|
||||
},
|
||||
}
|
||||
// 注册控制器到框架
|
||||
cool.RegisterController(petFusionController)
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
package admin
|
||||
|
||||
import (
|
||||
"blazing/cool"
|
||||
"blazing/modules/config/service"
|
||||
)
|
||||
|
||||
// PetFusionMaterialController 宠物融合材料子表Admin控制器(对应/admin/pet/fusion/material路由)
|
||||
type PetFusionMaterialController struct {
|
||||
*cool.Controller
|
||||
}
|
||||
|
||||
func init() {
|
||||
// 初始化控制器,配置路由前缀、支持的API、绑定Service
|
||||
var petFusionMaterialController = &PetFusionMaterialController{
|
||||
&cool.Controller{
|
||||
Prefix: "/admin/pet/fusionmaterial", // 路由前缀(主表路由+子表名,层级清晰)
|
||||
Api: []string{"Add", "Delete", "Update", "Info", "List", "Page"}, // 支持的基础CRUD接口
|
||||
Service: service.PetFusionMaterialServiceIns, // 绑定子表Service
|
||||
},
|
||||
}
|
||||
// 注册控制器到框架
|
||||
cool.RegisterController(petFusionMaterialController)
|
||||
}
|
||||
22
modules/config/controller/admin/talk.go
Normal file
22
modules/config/controller/admin/talk.go
Normal file
@@ -0,0 +1,22 @@
|
||||
package admin
|
||||
|
||||
import (
|
||||
"blazing/cool"
|
||||
"blazing/modules/config/service"
|
||||
)
|
||||
|
||||
type TalkConfigController struct {
|
||||
*cool.Controller
|
||||
}
|
||||
|
||||
func init() {
|
||||
var task_info_controller = &TalkConfigController{
|
||||
&cool.Controller{
|
||||
Prefix: "/admin/sun/talkconfig",
|
||||
Api: []string{"Add", "Delete", "Update", "Info", "List", "Page"},
|
||||
Service: service.NewTalkConfigService(),
|
||||
},
|
||||
}
|
||||
// 注册路由
|
||||
cool.RegisterController(task_info_controller)
|
||||
}
|
||||
5
modules/config/controller/controller.go
Normal file
5
modules/config/controller/controller.go
Normal file
@@ -0,0 +1,5 @@
|
||||
package controller
|
||||
|
||||
import (
|
||||
_ "blazing/modules/config/controller/admin"
|
||||
)
|
||||
3
modules/config/go.mod
Normal file
3
modules/config/go.mod
Normal file
@@ -0,0 +1,3 @@
|
||||
module blazing/modules/config
|
||||
|
||||
go 1.25.0
|
||||
43
modules/config/model/boss_effect.go
Normal file
43
modules/config/model/boss_effect.go
Normal file
@@ -0,0 +1,43 @@
|
||||
package model
|
||||
|
||||
import (
|
||||
"blazing/cool"
|
||||
)
|
||||
|
||||
// 表名常量(遵循现有命名规范)
|
||||
const TableNamePlayerPetSpecialEffect = "player_pet_special_effect"
|
||||
|
||||
// PlayerPetSpecialEffect 精灵特效表(仅包含XML中指定的4个核心字段)
|
||||
// 对应XML中的<NewSeIdx>节点:Idx、Stat、Eid、Args
|
||||
type PlayerPetSpecialEffect struct {
|
||||
*cool.Model // 嵌入基础Model(包含主键、创建/更新时间等通用字段)
|
||||
|
||||
// 严格对应XML的4个核心字段
|
||||
SeIdx uint32 `gorm:"not null;uniqueIndex:idx_se_idx;comment:'精灵特效索引(XML中的Idx)'" json:"se_idx"`
|
||||
//Stat uint32 `gorm:"not null;default:0;comment:'精灵特效状态(XML中的Stat)'" json:"stat"`
|
||||
Eid uint32 `gorm:"not null;index:idx_eid;comment:'精灵特效Eid(XML中的Eid)'" json:"eid"`
|
||||
Args []int `gorm:"type:json;comment:'精灵特效参数(XML中的Args)'" json:"args"`
|
||||
Desc string `gorm:"type:varchar(255);default:'';comment:'精灵特效描述(XML中的Desc)'" json:"desc"`
|
||||
}
|
||||
|
||||
// TableName 指定表名(遵循现有规范)
|
||||
func (*PlayerPetSpecialEffect) TableName() string {
|
||||
return TableNamePlayerPetSpecialEffect
|
||||
}
|
||||
|
||||
// GroupName 指定表分组(默认分组,与现有Item表一致)
|
||||
func (*PlayerPetSpecialEffect) GroupName() string {
|
||||
return "default"
|
||||
}
|
||||
|
||||
// NewPlayerPetSpecialEffect 创建精灵特效表实例(初始化基础Model)
|
||||
func NewPlayerPetSpecialEffect() *PlayerPetSpecialEffect {
|
||||
return &PlayerPetSpecialEffect{
|
||||
Model: cool.NewModel(),
|
||||
}
|
||||
}
|
||||
|
||||
// init 程序启动时自动创建表(与现有Item表的初始化逻辑一致)
|
||||
func init() {
|
||||
cool.CreateTable(&PlayerPetSpecialEffect{})
|
||||
}
|
||||
48
modules/config/model/boss_pet.go
Normal file
48
modules/config/model/boss_pet.go
Normal file
@@ -0,0 +1,48 @@
|
||||
package model
|
||||
|
||||
import (
|
||||
"blazing/common/data"
|
||||
"blazing/cool"
|
||||
)
|
||||
|
||||
const (
|
||||
TableNameBossConfig = "config_pet_boss" // BOSS配置表(全量包含基础/奖励/护盾/捕捉/特效/世界野怪/地图费用/战斗通用逻辑)
|
||||
)
|
||||
|
||||
// BossConfig BOSS配置模型(覆盖所有补充的配置项:GBTL/非VIP费用/首场景/战斗通用逻辑)
|
||||
type BossConfig struct {
|
||||
*cool.Model // 嵌入通用Model(包含ID/创建时间/更新时间等通用字段)
|
||||
PetBaseConfig
|
||||
// ISboss uint32 `gorm:"not null;default:0;comment:'是否是Boss'" json:"is_boss"`
|
||||
|
||||
// ISgift uint32 `gorm:"not null;default:0;comment:'是否是礼物'" json:"is_gif"`
|
||||
}
|
||||
|
||||
// BossConfigEX 扩展BOSS配置模型(用于前端/业务层的数组格式解析)
|
||||
type BossConfigEX struct {
|
||||
BossConfig
|
||||
Color data.GlowFilter `json:"color"`
|
||||
}
|
||||
|
||||
// TableName 指定BossConfig对应的数据库表名
|
||||
func (*BossConfig) TableName() string {
|
||||
return TableNameBossConfig
|
||||
}
|
||||
|
||||
// GroupName 指定表所属的分组(保持和怪物刷新表一致)
|
||||
func (*BossConfig) GroupName() string {
|
||||
return "default"
|
||||
}
|
||||
|
||||
// NewBossConfig 创建一个新的BossConfig实例(初始化通用Model字段+所有默认值)
|
||||
|
||||
func NewBossConfig() *BossConfig {
|
||||
return &BossConfig{
|
||||
Model: cool.NewModel(),
|
||||
}
|
||||
}
|
||||
|
||||
// init 程序启动时自动创建/同步boss_config表结构
|
||||
func init() {
|
||||
cool.CreateTable(&BossConfig{})
|
||||
}
|
||||
48
modules/config/model/fusion_material.go
Normal file
48
modules/config/model/fusion_material.go
Normal file
@@ -0,0 +1,48 @@
|
||||
package model
|
||||
|
||||
import "blazing/cool"
|
||||
|
||||
const (
|
||||
TableNamePetFusionMaterial = "pet_fusion_material" // 宠物融合材料表(子表)
|
||||
)
|
||||
|
||||
// PetFusionMaterial 融合材料模型(与配方主表一对一关联)
|
||||
type PetFusionMaterial struct {
|
||||
*cool.Model // 嵌入通用Model(ID/创建时间/更新时间等)
|
||||
|
||||
// 4个材料ID(对应XML ItemGroup的Idx=1-4,无材料填0)
|
||||
Material1 uint32 `gorm:"not null;comment:'材料1ID(如400030)'" json:"material1"`
|
||||
Material2 uint32 `gorm:"not null;comment:'材料2ID(如400030)'" json:"material2"`
|
||||
Material3 uint32 `gorm:"not null;comment:'材料3ID(如400028)'" json:"material3"`
|
||||
Material4 uint32 `gorm:"not null;comment:'材料4ID(如400030)'" json:"material4"`
|
||||
|
||||
// 4个特性ID(对应XML MaterialGroup的特性索引,4-4对应)
|
||||
Trait1Idx uint32 `gorm:"not null;comment:'特性1索引(如1008)'" json:"trait1_idx"`
|
||||
Trait2Idx uint32 `gorm:"not null;comment:'特性2索引(如1018)'" json:"trait2_idx"`
|
||||
Trait3Idx uint32 `gorm:"not null;comment:'特性3索引(如1023)'" json:"trait3_idx"`
|
||||
Trait4Idx uint32 `gorm:"not null;comment:'特性4索引(如1031)'" json:"trait4_idx"`
|
||||
|
||||
IsEnable int32 `gorm:"not null;default:1;comment:'是否启用该组合(1:启用,0:禁用)'" json:"is_enable"`
|
||||
}
|
||||
|
||||
// TableName 指定子表名
|
||||
func (*PetFusionMaterial) TableName() string {
|
||||
return TableNamePetFusionMaterial
|
||||
}
|
||||
|
||||
// GroupName 表分组(与主表一致)
|
||||
func (*PetFusionMaterial) GroupName() string {
|
||||
return "default"
|
||||
}
|
||||
|
||||
// NewPetFusionMaterial 创建材料实例
|
||||
func NewPetFusionMaterial() *PetFusionMaterial {
|
||||
return &PetFusionMaterial{
|
||||
Model: cool.NewModel(),
|
||||
}
|
||||
}
|
||||
|
||||
// init 初始化子表结构
|
||||
func init() {
|
||||
cool.CreateTable(&PetFusionMaterial{})
|
||||
}
|
||||
47
modules/config/model/fusion_pet.go
Normal file
47
modules/config/model/fusion_pet.go
Normal file
@@ -0,0 +1,47 @@
|
||||
package model
|
||||
|
||||
import (
|
||||
"blazing/cool"
|
||||
)
|
||||
|
||||
const (
|
||||
TableNamePetFusion = "pet_fusion" // 宠物融合配方表(主表)
|
||||
)
|
||||
|
||||
// PetFusion 宠物融合配方主模型(核心配方规则)
|
||||
type PetFusion struct {
|
||||
*cool.Model // 嵌入通用Model(ID/创建时间/更新时间等)
|
||||
|
||||
MainPetID int32 `gorm:"not null;comment:'主宠物ID(如:尼尔)'" json:"main_pet_id"`
|
||||
SubPetID int32 `gorm:"not null;comment:'副宠物ID(如:闪皮)'" json:"sub_pet_id"`
|
||||
Probability int32 `gorm:"not null;comment:'融合成功率(百分比,如80代表80%)'" json:"probability"`
|
||||
ResultPetID int32 `gorm:"not null;comment:'融合结果宠物ID(如:卡鲁、闪尼)'" json:"result_pet_id"`
|
||||
Remark string `gorm:"type:varchar(255);default:'';comment:'融合配方备注(如:尼尔+闪皮=闪尼)'" json:"remark"`
|
||||
IsEnable int32 `gorm:"not null;default:1;comment:'是否启用(1:启用,0:禁用)'" json:"is_enable"`
|
||||
IsDefault int32 `gorm:"not null;default:0;comment:'是否默认配方(1:默认配方,0:非默认;所有配方不匹配时随机选默认配方)'" json:"is_default"`
|
||||
|
||||
// 关联:一个配方对应多个材料(gorm 一对多关联,查询时可预加载)
|
||||
//Materials []*PetFusionMaterial `gorm:"foreignKey:PetFusionID;references:ID" json:"materials,omitempty"`
|
||||
}
|
||||
|
||||
// TableName 指定主表名
|
||||
func (*PetFusion) TableName() string {
|
||||
return TableNamePetFusion
|
||||
}
|
||||
|
||||
// GroupName 表分组(与原逻辑一致)
|
||||
func (*PetFusion) GroupName() string {
|
||||
return "default"
|
||||
}
|
||||
|
||||
// NewPetFusion 创建主表实例
|
||||
func NewPetFusion() *PetFusion {
|
||||
return &PetFusion{
|
||||
Model: cool.NewModel(),
|
||||
}
|
||||
}
|
||||
|
||||
// init 初始化主表结构
|
||||
func init() {
|
||||
cool.CreateTable(&PetFusion{})
|
||||
}
|
||||
57
modules/config/model/item_gift.go
Normal file
57
modules/config/model/item_gift.go
Normal file
@@ -0,0 +1,57 @@
|
||||
package model
|
||||
|
||||
import (
|
||||
"blazing/cool"
|
||||
)
|
||||
|
||||
// 表名常量定义:物品奖励表(存储物品奖励的核心配置信息)
|
||||
const (
|
||||
TableNameItemGift = "item_gift" // 物品奖励配置表(包含物品关联、数量、启用状态、扭蛋标识及备注信息)
|
||||
)
|
||||
|
||||
// ItemGift 物品奖励基础配置模型(与数据库表 item_gift 字段一一对应,核心存储结构)
|
||||
type ItemGift struct {
|
||||
*cool.Model // 嵌入通用Model(包含ID/创建时间/更新时间等通用字段,保持与现有模型一致性)
|
||||
|
||||
// 核心业务字段(按需求实现:物品id、备注、是否启用、是否为扭蛋、物品数量)
|
||||
ItemID uint32 `gorm:"not null;default:0;comment:'物品ID,关联物品配置表主键'" json:"item_id"`
|
||||
Remark string `gorm:"size:512;default:'';comment:'物品奖励备注说明(如使用场景、特殊说明等)'" json:"remark"`
|
||||
IsEnabled uint32 `gorm:"not null;default:1;comment:'是否启用(0-禁用 1-启用)'" json:"is_enabled"`
|
||||
IsGacha uint32 `gorm:"not null;default:0;comment:'是否为扭蛋物品(0-否 1-是)'" json:"is_gacha"`
|
||||
ItemCount uint32 `gorm:"not null;default:1;comment:'物品奖励数量'" json:"item_count"`
|
||||
}
|
||||
|
||||
// ItemGiftEX 物品奖励扩展配置模型(用于前端/业务层复杂数据展示,非数据库存储字段)
|
||||
type ItemGiftEX struct {
|
||||
ItemGift // 嵌入基础物品奖励模型
|
||||
ItemName string `json:"item_name"` // 物品名称(前端展示用,关联物品表查询得到)
|
||||
ItemIcon string `json:"item_icon"` // 物品图标路径(前端展示用,非数据库存储字段)
|
||||
StatusDesc string `json:"status_desc"` // 启用状态描述(如"启用"/"禁用",前端展示用)
|
||||
GachaDesc string `json:"gacha_desc"` // 扭蛋标识描述(如"扭蛋专属"/"普通物品",前端展示用)
|
||||
}
|
||||
|
||||
// TableName 指定ItemGift对应的数据库表名(遵循现有代码规范)
|
||||
func (*ItemGift) TableName() string {
|
||||
return TableNameItemGift
|
||||
}
|
||||
|
||||
// GroupName 指定表所属的分组(与现有BossConfig、PetReward保持一致,统一为default分组)
|
||||
func (*ItemGift) GroupName() string {
|
||||
return "default"
|
||||
}
|
||||
|
||||
// NewItemGift 创建一个新的ItemGift实例(初始化通用Model字段+默认值,与现有实例创建逻辑一致)
|
||||
func NewItemGift() *ItemGift {
|
||||
return &ItemGift{
|
||||
Model: cool.NewModel(), // 初始化通用Model字段(ID/创建时间/更新时间等)
|
||||
// 字段默认值与gorm tag中default配置保持一致
|
||||
IsEnabled: 1,
|
||||
IsGacha: 0,
|
||||
ItemCount: 1,
|
||||
}
|
||||
}
|
||||
|
||||
// init 程序启动时自动创建/同步item_gift表结构(与现有表同步逻辑保持一致)
|
||||
func init() {
|
||||
cool.CreateTable(&ItemGift{})
|
||||
}
|
||||
55
modules/config/model/monster_refresh.go
Normal file
55
modules/config/model/monster_refresh.go
Normal file
@@ -0,0 +1,55 @@
|
||||
package model
|
||||
|
||||
import (
|
||||
"blazing/cool"
|
||||
)
|
||||
|
||||
const (
|
||||
TableNameMonsterRefresh = "monster_refresh" // 怪物刷新规则表(地图-精灵等级-刷新脚本配置)
|
||||
)
|
||||
|
||||
// MonsterRefresh 怪物刷新规则模型(对应前端配置的地图/精灵/等级/脚本配置)
|
||||
type MonsterRefresh struct {
|
||||
*cool.Model // 嵌入通用Model(包含ID/创建时间/更新时间等通用字段)
|
||||
|
||||
MapID int32 `gorm:"not null;comment:'地图ID'" json:"map_id"`
|
||||
MonsterID string `gorm:"not null;comment:'精灵ID,填0为填充数组'" json:"monster_id"`
|
||||
MinLevel int32 `gorm:"not null;comment:'精灵最低等级'" json:"min_level"`
|
||||
MaxLevel int32 `gorm:"not null;comment:'精灵最高等级'" json:"max_level"`
|
||||
FixPos int32 `gorm:"not null;comment:'固定位置刷新(0:随机位置,没有固定位置的时候就会取一个随机位置,如果没有随机位置就不刷新,1-9:固定位置)'" json:"fix_pos"`
|
||||
Script string `gorm:"type:text;not null;comment:'刷新脚本(JS格式,对应前端编辑器配置)'" json:"value"`
|
||||
|
||||
// 以下为原模型保留的异色相关字段(前端暂未配置,如需移除可删除)
|
||||
ShinyID string `gorm:"not null;comment:'异色唯一标识ID'" json:"shiny_id"`
|
||||
// ShinyFilter string `gorm:"type:text;not null;comment:'异色滤镜效果(文本描述或配置参数)'" json:"shiny_filter"`
|
||||
// ShinyEffect string `gorm:"type:text;not null;comment:'异色光效效果(文本描述或配置参数)'" json:"shiny_effect"`
|
||||
// TODO: 增加ruffle的显示异色效果(如需保留则完善,无需则删除)
|
||||
}
|
||||
|
||||
type MonsterRefreshEX struct {
|
||||
MonsterRefresh
|
||||
MonsterID []uint32 `json:"monster_id"`
|
||||
ShinyID []uint32 `json:"shiny_id"`
|
||||
}
|
||||
|
||||
// TableName 指定MonsterRefresh对应的数据库表名
|
||||
func (*MonsterRefresh) TableName() string {
|
||||
return TableNameMonsterRefresh
|
||||
}
|
||||
|
||||
// GroupName 指定表所属的分组(保持和参考示例一致)
|
||||
func (*MonsterRefresh) GroupName() string {
|
||||
return "default"
|
||||
}
|
||||
|
||||
// NewMonsterRefresh 创建一个新的MonsterRefresh实例(初始化通用Model)
|
||||
func NewMonsterRefresh() *MonsterRefresh {
|
||||
return &MonsterRefresh{
|
||||
Model: cool.NewModel(),
|
||||
}
|
||||
}
|
||||
|
||||
// init 初始化表结构(程序启动时自动创建/同步表)
|
||||
func init() {
|
||||
cool.CreateTable(&MonsterRefresh{})
|
||||
}
|
||||
106
modules/config/model/pet_base.go
Normal file
106
modules/config/model/pet_base.go
Normal file
@@ -0,0 +1,106 @@
|
||||
package model
|
||||
|
||||
import (
|
||||
"blazing/cool"
|
||||
)
|
||||
|
||||
const (
|
||||
TableNameMeleeConfig = "config_pet_melee" // BOSS配置表(全量包含基础/奖励/护盾/捕捉/特效/世界野怪/地图费用/战斗通用逻辑)
|
||||
)
|
||||
|
||||
// PetBaseConfig BOSS配置模型(覆盖所有补充的配置项:GBTL/非VIP费用/首场景/战斗通用逻辑)
|
||||
type PetBaseConfig struct {
|
||||
*cool.Model // 嵌入通用Model(包含ID/创建时间/更新时间等通用字段)
|
||||
|
||||
// ===================== 基础配置 =====================
|
||||
//BossID int32 `gorm:"not null;comment:'BOSS唯一标识ID'" json:"boss_id"`
|
||||
//MapID int32 `gorm:"not null;comment:'BOSS所在地图ID'" json:"map_id"`
|
||||
// InitX int32 `gorm:"not null;default:0;comment:'BOSS初始X坐标(对应玩家登陆坐标逻辑)'" json:"init_x"`
|
||||
// InitY int32 `gorm:"not null;default:0;comment:'BOSS初始Y坐标(对应玩家登陆坐标逻辑)'" json:"init_y"`
|
||||
// BossVisible int32 `gorm:"not null;default:0;comment:'BOSS是否可见(0:不可见,1:可见)'" json:"boss_visible"`
|
||||
// AppearTime string `gorm:"not null;comment:'BOSS出现时间(格式示例:0 23,空格分隔的时间点)'" json:"appear_time"`
|
||||
// Name string `gorm:"not null;comment:'BOSS名称'" json:"name"`
|
||||
// NonVipCost int32 `gorm:"not null;default:0;comment:'非VIP用户进地图需支付的赛尔豆(VIP用户免费,默认0)'" json:"non_vip_cost"`
|
||||
// PrimaryScene int32 `gorm:"not null;default:0;comment:'首场景标识(0:非首场景地图;n>0:第n星系的星球且是首场景,默认0)'" json:"primary_scene"`
|
||||
|
||||
// ===================== 战斗核心属性(BossMon节点) =====================
|
||||
MonID int32 `gorm:"not null;comment:'BOSS对应的精灵ID'" json:"mon_id"`
|
||||
Hp int32 `gorm:"not null;comment:'BOSS血量值(LvHpMatchUser非0时此配置无效)'" json:"hp"`
|
||||
Lv int32 `gorm:"not null;comment:'BOSS等级(LvHpMatchUser非0时此配置无效)'" json:"lv"`
|
||||
// ===================== BOSS属性(Boss_prop) =====================
|
||||
Prop []uint32 `gorm:"type:jsonb;not null;default:'[]';comment:'BOSS属性'" json:"prop"`
|
||||
Nature uint32 `gorm:"not null;default:0;comment:'BOSS属性-性格'" json:"nature"`
|
||||
SKill []uint32 `gorm:"type:jsonb;not null;default:'[]';comment:'BOSS技能'" json:"skill"`
|
||||
Effect []uint32 `gorm:"type:jsonb;not null;default:'[]';comment:'BOSS特性'" json:"effect"`
|
||||
Color string `gorm:"comment:'BOSS颜色'" json:"color"`
|
||||
IsEnable uint32 `gorm:"not null;default:0;comment:'是否启用'" json:"is_enable"`
|
||||
Desc *string `gorm:"comment:'BOSS描述'" json:"desc"`
|
||||
|
||||
// ISMELEE uint32 `gorm:"not null;default:0;comment:'是否乱斗配置'" json:"is_melee"`
|
||||
// // ===================== BOSS奖励规则(Boss_bonus) =====================
|
||||
// BonusProbability int32 `gorm:"not null;default:0;comment:'打赢BOSS给奖励概率-分子(值域:0-1000,默认0)'" json:"bonus_probability"`
|
||||
// BonusTotalProbability int32 `gorm:"not null;default:1000;comment:'打赢BOSS给奖励概率-分母(值域:1000,默认1000)'" json:"bonus_total_probability"`
|
||||
// BonusMonsterProbability int32 `gorm:"not null;default:0;comment:'给精灵奖励比例(值域:0-1000,默认0;物品奖励比例=分母-此值)'" json:"bonus_monster_probability"`
|
||||
// BonusID int32 `gorm:"not null;comment:'奖励ID(必配,有效BonusID)'" json:"bonus_id"`
|
||||
// MonBonusOutID int32 `gorm:"not null;comment:'精灵奖励ID(必配,有效精灵BonusID,奖精灵时生效)'" json:"mon_bonus_out_id"`
|
||||
// ItemBonusOutID int32 `gorm:"not null;comment:'物品奖励ID(必配,有效物品BonusID,奖物品时生效)'" json:"item_bonus_out_id"`
|
||||
|
||||
// NewSeIdxs string `gorm:"type:text;not null;default:'0';comment:'新特效idx(值域:1-2000,0无特效,对应conf/new_se.xml,空格分隔列表)'" json:"new_se_idxs"`
|
||||
|
||||
// // ===================== BOSS护盾属性 =====================
|
||||
// Shield int32 `gorm:"not null;default:0;comment:'BOSS护盾Hp(如蘑菇怪,默认0)'" json:"shield"`
|
||||
// MaxAccLostShield int32 `gorm:"not null;default:0;comment:'护盾变化通知AS的阈值(默认0)'" json:"max_acc_lost_shield"`
|
||||
// ShieldRecoverTime int32 `gorm:"not null;default:0;comment:'护盾恢复时间间隔(默认0)'" json:"shield_recover_time"`
|
||||
|
||||
// // ===================== BOSS对战/捕捉规则 =====================
|
||||
// BossCatchable int32 `gorm:"not null;default:0;comment:'BOSS是否可被捕捉(0:否,1:是,默认0)'" json:"boss_catchable"`
|
||||
// BossFinOnce int32 `gorm:"not null;default:0;comment:'拥有后是否不能再打(0:否,1:是,默认0)'" json:"boss_fin_once"`
|
||||
// BossFinTaskWay int32 `gorm:"not null;default:0;comment:'完成任务方式(0:正常+捕捉;1:仅正常;2:仅捕捉,默认0)'" json:"boss_fin_task_way"`
|
||||
// PkFlag int32 `gorm:"not null;default:0;comment:'是否单精灵对战(0:否,1:是,默认0)'" json:"pk_flag"`
|
||||
// LvHpMatchUser int32 `gorm:"not null;default:0;comment:'等级血量匹配用户(0:无效;2:低5级;3:高2级;4:高5级;5:低10级;6:低5级且HP4倍;7:同等级且HP2.5倍)'" json:"lv_hp_match_user"`
|
||||
// //VipOnly int32 `gorm:"not null;default:0;comment:'仅VIP可打(0:否,1:是,默认0)'" json:"vip_only"`
|
||||
|
||||
// // ===================== 世界野怪变身配置 =====================
|
||||
// WorldWildProb int32 `gorm:"not null;default:0;comment:'变身世界野怪概率分子(值域:0-1000,默认0)'" json:"world_wild_prob"`
|
||||
// WorldWildMonId int32 `gorm:"not null;default:0;comment:'变身世界野怪的精灵ID(默认0)'" json:"world_wild_mon_id"`
|
||||
// WorldWildMonLv int32 `gorm:"not null;default:0;comment:'变身世界野怪的等级(默认0)'" json:"world_wild_mon_lv"`
|
||||
// WorldWildStart int32 `gorm:"not null;default:0;comment:'世界野怪出现起始时间(值域:0-23,默认0)'" json:"world_wild_start"`
|
||||
// WorldWildEnd int32 `gorm:"not null;default:23;comment:'世界野怪出现终止时间(值域:0-23,默认23)'" json:"world_wild_end"`
|
||||
|
||||
// // ===================== 战斗开始/结束通用逻辑配置 =====================
|
||||
// // 支持battle_mode_vs_boss battle_mode_no_region_boss,战斗协议2411、41129
|
||||
// TimeFlag int32 `gorm:"not null;default:0;comment:'战斗时间判断标识(关联activity_config_pool.xml,默认0)'" json:"time_flag"`
|
||||
// DailyKey string `gorm:"not null;default:'';comment:'战斗每天挑战次数key(为空则不限制次数)'" json:"daily_key"`
|
||||
// MaxTimes int32 `gorm:"not null;default:0;comment:'每天挑战上限(非0生效,默认0)'" json:"max_times"`
|
||||
// VipMaxTimes int32 `gorm:"not null;default:0;comment:'VIP每天挑战上限(非0生效,0时等于MaxTimes,默认0)'" json:"vip_max_times"`
|
||||
// WinBonusId int32 `gorm:"not null;default:0;comment:'战斗成功输出奖励ID(对应no_wait_bonus.xml,默认0)'" json:"win_bonus_id"`
|
||||
// WinOutId int32 `gorm:"not null;default:0;comment:'战斗成功输出奖励OutID(对应no_wait_bonus.xml,默认0)'" json:"win_out_id"`
|
||||
// FailBonusId int32 `gorm:"not null;default:0;comment:'战斗失败输出奖励ID(对应no_wait_bonus.xml,默认0)'" json:"fail_bonus_id"`
|
||||
// FailOutId int32 `gorm:"not null;default:0;comment:'战斗失败输出奖励OutID(对应no_wait_bonus.xml,默认0)'" json:"fail_out_id"`
|
||||
// BitSet string `gorm:"type:text;not null;default:'';comment:'战斗成功bitset限制条件(默认空)'" json:"bit_set"`
|
||||
}
|
||||
|
||||
// MeleeConfigEX 扩展BOSS配置模型(用于前端/业务层的数组格式解析)
|
||||
|
||||
// TableName 指定MeleeConfig对应的数据库表名
|
||||
func (*PetBaseConfig) TableName() string {
|
||||
return TableNameMeleeConfig
|
||||
}
|
||||
|
||||
// GroupName 指定表所属的分组(保持和怪物刷新表一致)
|
||||
func (*PetBaseConfig) GroupName() string {
|
||||
return "default"
|
||||
}
|
||||
|
||||
// NewMeleeConfig 创建一个新的MeleeConfig实例(初始化通用Model字段+所有默认值)
|
||||
|
||||
func NewMeettConfig() *PetBaseConfig {
|
||||
return &PetBaseConfig{
|
||||
Model: cool.NewModel(),
|
||||
}
|
||||
}
|
||||
|
||||
// init 程序启动时自动创建/同步boss_config表结构
|
||||
func init() {
|
||||
cool.CreateTable(&PetBaseConfig{})
|
||||
}
|
||||
50
modules/config/model/pet_gift.go
Normal file
50
modules/config/model/pet_gift.go
Normal file
@@ -0,0 +1,50 @@
|
||||
package model
|
||||
|
||||
import (
|
||||
"blazing/cool"
|
||||
)
|
||||
|
||||
// 表名常量定义:精灵奖励表(存储精灵BOSS/普通精灵对应的奖励配置:掉落物品/数量/概率/获取条件等)
|
||||
const (
|
||||
TableNamePetReward = "config_pet_reward" // 精灵奖励配置表(包含基础掉落/稀有奖励/VIP专属奖励/保底机制)
|
||||
)
|
||||
|
||||
// PetReward 精灵奖励基础配置模型(核心存储结构,与数据库表字段一一对应)
|
||||
type PetReward struct {
|
||||
*cool.Model // 嵌入通用Model(包含ID/创建时间/更新时间等通用字段,保持与BossConfig一致)
|
||||
|
||||
PetBaseConfig
|
||||
ISegg uint32 `gorm:"not null;default:0;comment:'是否蛋'" json:"is_egg"` //奖励是否为扭蛋奖励
|
||||
}
|
||||
|
||||
// PetRewardEX 精灵奖励扩展配置模型(用于前端/业务层的复杂数据解析,继承基础模型)
|
||||
type PetRewardEX struct {
|
||||
PetReward // 嵌入基础精灵奖励模型
|
||||
RewardName string `json:"reward_name"` // 奖励名称(前端展示用,非数据库存储字段)
|
||||
RewardIcon string `json:"reward_icon"` // 奖励图标路径(前端展示用,非数据库存储字段)
|
||||
DropRateDesc string `json:"drop_rate_desc"` // 掉落概率描述(如"10%概率获取",前端展示用)
|
||||
}
|
||||
|
||||
// TableName 指定PetReward对应的数据库表名(遵循现有代码规范)
|
||||
func (*PetReward) TableName() string {
|
||||
return TableNamePetReward
|
||||
}
|
||||
|
||||
// GroupName 指定表所属的分组(与BossConfig保持一致,统一为default分组)
|
||||
func (*PetReward) GroupName() string {
|
||||
return "default"
|
||||
}
|
||||
|
||||
// NewPetReward 创建一个新的PetReward实例(初始化通用Model字段+所有字段默认值,与NewBossConfig保持一致)
|
||||
func NewPetReward() *PetReward {
|
||||
return &PetReward{
|
||||
Model: cool.NewModel(), // 初始化通用Model字段(ID/创建时间/更新时间等)
|
||||
// 可根据需要设置其他字段的默认值,此处保持与gorm tag中default一致
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
// init 程序启动时自动创建/同步精灵奖励表结构(与BossConfig的表同步逻辑一致)
|
||||
func init() {
|
||||
cool.CreateTable(&PetReward{})
|
||||
}
|
||||
38
modules/config/model/server_list.go
Normal file
38
modules/config/model/server_list.go
Normal file
@@ -0,0 +1,38 @@
|
||||
package model
|
||||
|
||||
import (
|
||||
"blazing/cool"
|
||||
)
|
||||
|
||||
const TableNameServerList = "server_list"
|
||||
|
||||
// ServerList mapped from table <server_list>
|
||||
type ServerList struct {
|
||||
*cool.Model
|
||||
OnlineID uint16 `gorm:"column:online_id;comment:'在线ID';uniqueIndex" json:"online_id"`
|
||||
//IP string `gorm:"type:varchar(16);comment:'服务器IP'" json:"ip"`
|
||||
Port uint16 `gorm:"comment:'端口号,通常是小整数'" json:"port"`
|
||||
//IsOpen bool `gorm:"default:true;not null;comment:'服务器是否开启,默认为开启状态'" json:"is_open"`
|
||||
}
|
||||
|
||||
// TableName ServerList's table name
|
||||
func (*ServerList) TableName() string {
|
||||
return TableNameServerList
|
||||
}
|
||||
|
||||
// GroupName ServerList's table group
|
||||
func (*ServerList) GroupName() string {
|
||||
return "default"
|
||||
}
|
||||
|
||||
// NewServerList create a new ServerList
|
||||
func NewServerList() *ServerList {
|
||||
return &ServerList{
|
||||
Model: cool.NewModel(),
|
||||
}
|
||||
}
|
||||
|
||||
// init 创建表
|
||||
func init() {
|
||||
cool.CreateTable(&ServerList{})
|
||||
}
|
||||
40
modules/config/model/user_sign.go
Normal file
40
modules/config/model/user_sign.go
Normal file
@@ -0,0 +1,40 @@
|
||||
package model
|
||||
|
||||
import (
|
||||
"blazing/cool"
|
||||
)
|
||||
|
||||
// 表名常量(遵循现有命名规范:小写+下划线)
|
||||
const TableNameSignIn = "player_sign_in"
|
||||
|
||||
// SignIn 签到记录表
|
||||
// 核心字段:签到完成状态、状压签到进度、签到奖励脚本
|
||||
type SignIn struct {
|
||||
*cool.Model // 嵌入基础Model(包含主键、创建/更新时间等通用字段)
|
||||
SignInID uint32 `gorm:"not null;index:idx_sign_in_id;comment:'签到活动ID'" json:"sign_in_id"`
|
||||
Status uint32 `gorm:"not null;default:0;comment:'签到状态(0-未完成 1-已完成)'" json:"status"`
|
||||
//传入用户名,签到天数,给予奖励,这个搭配里程碑表实现
|
||||
RewardScript string `gorm:"type:varchar(512);default:'';comment:'签到奖励脚本(执行奖励发放的脚本内容)'" json:"reward_script"`
|
||||
}
|
||||
|
||||
// TableName 指定表名(遵循现有规范)
|
||||
func (*SignIn) TableName() string {
|
||||
return TableNameSignIn
|
||||
}
|
||||
|
||||
// GroupName 指定表分组(默认分组,与现有Item表/精灵特效表一致)
|
||||
func (*SignIn) GroupName() string {
|
||||
return "default"
|
||||
}
|
||||
|
||||
// NewSignIn 创建签到记录表实例(初始化基础Model)
|
||||
func NewSignIn() *SignIn {
|
||||
return &SignIn{
|
||||
Model: cool.NewModel(),
|
||||
}
|
||||
}
|
||||
|
||||
// init 程序启动时自动创建表(与现有PlayerPetSpecialEffect表的初始化逻辑一致)
|
||||
func init() {
|
||||
cool.CreateTable(&SignIn{})
|
||||
}
|
||||
55
modules/config/model/user_talk.go
Normal file
55
modules/config/model/user_talk.go
Normal file
@@ -0,0 +1,55 @@
|
||||
package model
|
||||
|
||||
import (
|
||||
"blazing/cool" // 沿用你项目中已有的基础Model包
|
||||
)
|
||||
|
||||
// 表名常量(遵循项目现有命名规范)
|
||||
const TableNameMineralCollectionConfig = "mineral_collection_config"
|
||||
|
||||
// MineralCollectionConfig 挖矿/采集/采摘矿产配置表Model定义
|
||||
// 字段完全匹配数据表结构,包含最小/最大产出核心字段
|
||||
type MineralCollectionConfig struct {
|
||||
*cool.Model // 嵌入基础Model,包含id(主键)、createTime、updateTime等通用字段
|
||||
|
||||
// MapID 矿产所在地图ID
|
||||
MapID uint32 `gorm:"column:map_id;not null;index:idx_mineral_collection_config_map_id;comment:矿产所在地图ID" json:"map_id"`
|
||||
Type uint32 `gorm:"column:type;not null;index:idx_mineral_collection_config_type;comment:类型" json:"type"`
|
||||
|
||||
// DailyCollectCount 每日可采集次数
|
||||
DailyCollectCount uint32 `gorm:"column:daily_collect_count;not null;comment:每日可采集次数" json:"daily_collect_count"`
|
||||
|
||||
// ItemID 物品编号(对应道具系统ID)
|
||||
ItemID uint32 `gorm:"column:item_id; not null;index:idx_mineral_collection_config_item_id;comment:物品编号(对应道具系统ID)" json:"item_id"`
|
||||
// ItemMinCount 单次采集最小产出数量
|
||||
ItemMinCount uint32 `gorm:"column:item_min_count;not null;comment:单次采集最小产出数量" json:"item_min_count"`
|
||||
// ItemMaxCount 单次采集最大产出数量
|
||||
ItemMaxCount uint32 `gorm:"column:item_max_count;not null;comment:单次采集最大产出数量" json:"item_max_count"`
|
||||
// Description 矿产描述
|
||||
Description string `gorm:"column:description;type:varchar(128); comment:矿产描述" json:"description"`
|
||||
}
|
||||
|
||||
// TableName 指定数据表名(必须匹配数据库表名,遵循项目规范)
|
||||
func (*MineralCollectionConfig) TableName() string {
|
||||
return TableNameMineralCollectionConfig
|
||||
}
|
||||
|
||||
// GroupName 指定表分组(与项目现有表保持一致,默认分组)
|
||||
func (*MineralCollectionConfig) GroupName() string {
|
||||
return "default"
|
||||
}
|
||||
|
||||
// NewMineralCollectionConfig 创建挖矿配置表实例(初始化基础Model)
|
||||
// 保证通用字段(createTime/updateTime)被正确初始化
|
||||
func NewMineralCollectionConfig() *MineralCollectionConfig {
|
||||
return &MineralCollectionConfig{
|
||||
Model: cool.NewModel(), // 调用基础Model的初始化方法
|
||||
}
|
||||
}
|
||||
|
||||
// init 程序启动时自动创建数据表(与项目现有表初始化逻辑一致)
|
||||
// 若项目有统一的表初始化入口,可将此逻辑迁移至对应位置
|
||||
func init() {
|
||||
// 自动创建表(不存在则创建,已存在则不操作)
|
||||
cool.CreateTable(&MineralCollectionConfig{})
|
||||
}
|
||||
18
modules/config/service/boss.go
Normal file
18
modules/config/service/boss.go
Normal file
@@ -0,0 +1,18 @@
|
||||
package service
|
||||
|
||||
import (
|
||||
"blazing/cool"
|
||||
"blazing/modules/blazing/model"
|
||||
)
|
||||
|
||||
type BossService struct {
|
||||
*cool.Service
|
||||
}
|
||||
|
||||
func NewBossService() *BossService {
|
||||
return &BossService{
|
||||
&cool.Service{
|
||||
Model: model.NewBossConfig(),
|
||||
},
|
||||
}
|
||||
}
|
||||
35
modules/config/service/effect.go
Normal file
35
modules/config/service/effect.go
Normal file
@@ -0,0 +1,35 @@
|
||||
package service
|
||||
|
||||
import (
|
||||
"blazing/cool"
|
||||
"blazing/modules/config/model"
|
||||
|
||||
"github.com/gogf/gf/v2/database/gdb"
|
||||
)
|
||||
|
||||
type EffectService struct {
|
||||
*cool.Service
|
||||
}
|
||||
|
||||
func (s *EffectService) Args(id uint32) (int, []int) {
|
||||
m := cool.DBM(s.Model).Where("se_idx", id).Cache(gdb.CacheOption{
|
||||
//Duration: time.Hour,
|
||||
|
||||
Force: false,
|
||||
})
|
||||
var tt model.PlayerPetSpecialEffect
|
||||
m.Scan(&tt)
|
||||
|
||||
return int(tt.Eid), tt.Args
|
||||
|
||||
}
|
||||
func NewEffectService() *EffectService {
|
||||
return &EffectService{
|
||||
&cool.Service{
|
||||
|
||||
Model: model.NewPlayerPetSpecialEffect(),
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
var Effects = NewEffectService()
|
||||
29
modules/config/service/melee.go
Normal file
29
modules/config/service/melee.go
Normal file
@@ -0,0 +1,29 @@
|
||||
package service
|
||||
|
||||
import (
|
||||
"blazing/cool"
|
||||
"blazing/modules/blazing/model"
|
||||
)
|
||||
|
||||
type MELEEService struct {
|
||||
*cool.Service
|
||||
}
|
||||
|
||||
func NewMELEEService() *MELEEService {
|
||||
return &MELEEService{
|
||||
&cool.Service{
|
||||
Model: model.NewMeettConfig(),
|
||||
},
|
||||
}
|
||||
}
|
||||
func (s *MELEEService) Def() []model.MeleeConfig {
|
||||
|
||||
var pets []model.MeleeConfig
|
||||
m := cool.DBM(s.Model)
|
||||
|
||||
m.OrderRandom().Limit(3).Scan(&pets)
|
||||
|
||||
return pets
|
||||
// return ret.Interface().([]model.PetFusion)
|
||||
|
||||
}
|
||||
98
modules/config/service/monster_refresh.go
Normal file
98
modules/config/service/monster_refresh.go
Normal file
@@ -0,0 +1,98 @@
|
||||
package service
|
||||
|
||||
import (
|
||||
"blazing/cool"
|
||||
"blazing/modules/config/model"
|
||||
|
||||
"fmt"
|
||||
"strconv"
|
||||
"time"
|
||||
|
||||
"github.com/dop251/goja"
|
||||
"github.com/gogf/gf/v2/database/gdb"
|
||||
"github.com/gogf/gf/v2/frame/g"
|
||||
"github.com/gogf/gf/v2/util/gconv"
|
||||
)
|
||||
|
||||
type MonsterService struct {
|
||||
*cool.Service
|
||||
}
|
||||
|
||||
func NewMonsterService() *MonsterService {
|
||||
return &MonsterService{
|
||||
&cool.Service{
|
||||
Model: model.NewMonsterRefresh(),
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
func (s *MonsterService) ModifyAfter(ctx g.Ctx, method string, param g.MapStrAny) (err error) {
|
||||
|
||||
gconv.String(param["map_id"])
|
||||
cool.DBM(s.Model).Cache((gdb.CacheOption{
|
||||
Duration: -1,
|
||||
Name: model.TableNameMonsterRefresh + gconv.String(param["map_id"]),
|
||||
Force: false,
|
||||
}))
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func (s *MonsterService) GetId(mapid uint32) []model.MonsterRefresh {
|
||||
|
||||
m := cool.DBM(s.Model).Where("map_id", mapid).Cache(
|
||||
gdb.CacheOption{
|
||||
Duration: time.Hour,
|
||||
Name: model.TableNameMonsterRefresh + strconv.Itoa(int(mapid)),
|
||||
Force: false,
|
||||
},
|
||||
)
|
||||
var tt []model.MonsterRefresh
|
||||
m.Scan(&tt)
|
||||
|
||||
// for _, v := range tt {
|
||||
|
||||
// if v.MapID == int32(mapid) {
|
||||
// return uint32(v.MonsterID)
|
||||
|
||||
// }
|
||||
|
||||
// }
|
||||
return tt
|
||||
|
||||
}
|
||||
func Test_kick() {
|
||||
const SCRIPT = `
|
||||
function shouldRefresh(userId, day, dayOfWeek, hour, minute) {
|
||||
return true;
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
`
|
||||
t, _ := goja.Compile("test.js", SCRIPT, false)
|
||||
vm := goja.New()
|
||||
_, err := vm.RunProgram(t)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
sum, ok := goja.AssertFunction(vm.Get("shouldRefresh"))
|
||||
if !ok {
|
||||
panic("Not a function")
|
||||
}
|
||||
|
||||
res, err := sum(
|
||||
goja.Undefined(),
|
||||
vm.ToValue(1),
|
||||
vm.ToValue(time.Now().Day()),
|
||||
vm.ToValue(time.Now().Weekday()),
|
||||
vm.ToValue(time.Now().Hour()),
|
||||
vm.ToValue(time.Now().Minute()),
|
||||
)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
fmt.Println(res)
|
||||
// Output: 42
|
||||
}
|
||||
90
modules/config/service/pet_fusion_material_service.go
Normal file
90
modules/config/service/pet_fusion_material_service.go
Normal file
@@ -0,0 +1,90 @@
|
||||
package service
|
||||
|
||||
import (
|
||||
"blazing/cool"
|
||||
|
||||
"blazing/modules/config/model"
|
||||
"blazing/modules/dict/service"
|
||||
"strings"
|
||||
|
||||
"github.com/gogf/gf/v2/database/gdb"
|
||||
"github.com/gogf/gf/v2/frame/g"
|
||||
"github.com/gogf/gf/v2/util/gconv"
|
||||
"github.com/gogf/gf/v2/util/grand"
|
||||
)
|
||||
|
||||
// PetFusionMaterialService 宠物融合材料子表Service(对应pet_fusion_material表)
|
||||
type PetFusionMaterialService struct {
|
||||
*cool.Service // 嵌入通用Service(继承基础CRUD方法)
|
||||
}
|
||||
|
||||
var PetFusionMaterialServiceIns = NewPetFusionMaterialService()
|
||||
|
||||
// NewPetFusionMaterialService 创建PetFusionMaterialService实例
|
||||
func NewPetFusionMaterialService() *PetFusionMaterialService {
|
||||
return &PetFusionMaterialService{
|
||||
&cool.Service{
|
||||
Model: model.NewPetFusionMaterial(), // 绑定PetFusionMaterial模型(默认参数占位)
|
||||
//Cache: gcache.New(),
|
||||
// PageQueryOp: &cool.QueryOp{KeyWordField: []string{"material1", "material2", "material3", "material4"}},
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
// 获取融合材料的特性,返回两个值,一个是指定的特性,另一个是如果配方没找到的情况下,默认的配置
|
||||
func (s *PetFusionMaterialService) Data(Material1 [4]uint32) uint32 {
|
||||
|
||||
cacheKey := strings.Join(gconv.Strings(Material1[:]), ":")
|
||||
println(cacheKey, "获取融合id")
|
||||
fusions := service.DictInfoServiceS.GetData("fusion")
|
||||
|
||||
for _, v := range Material1 {
|
||||
if v < 10000 {
|
||||
//使用过小的道具
|
||||
return 0
|
||||
}
|
||||
_, ok := fusions[v]
|
||||
if !ok {
|
||||
//todo使用了非法材料
|
||||
return 0
|
||||
}
|
||||
|
||||
}
|
||||
m := cool.DBM(s.Model)
|
||||
|
||||
var effect *model.PetFusionMaterial //一个特性应该是唯一的,但是我们要获取默认随机特性
|
||||
condition := g.Map{
|
||||
"material1": Material1[0],
|
||||
"material2": Material1[1],
|
||||
"material3": Material1[2],
|
||||
"material4": Material1[3],
|
||||
"is_enable": 1,
|
||||
}
|
||||
m.Where(condition).Cache(gdb.CacheOption{
|
||||
// Duration: time.Hour,
|
||||
|
||||
Force: false,
|
||||
}).Scan(&effect)
|
||||
//这时候有可能效果是空的,那么这时候就再次查询默认的特性,保证每次必会生成一个数据库有的特性
|
||||
//也许这个时候的特性配方就是随机从数据库中查找一个特性
|
||||
|
||||
if effect == nil {
|
||||
effect2s := service.DictInfoServiceS.GetData("effect")
|
||||
for _, v := range effect2s {
|
||||
return gconv.Uint32(v.Value)
|
||||
}
|
||||
|
||||
}
|
||||
r := grand.Intn(4)
|
||||
switch r {
|
||||
case 0:
|
||||
return effect.Trait1Idx
|
||||
case 1:
|
||||
return effect.Trait2Idx
|
||||
case 2:
|
||||
return effect.Trait3Idx
|
||||
case 3:
|
||||
return effect.Trait4Idx
|
||||
}
|
||||
return 0
|
||||
}
|
||||
92
modules/config/service/pet_fusion_service.go
Normal file
92
modules/config/service/pet_fusion_service.go
Normal file
@@ -0,0 +1,92 @@
|
||||
package service
|
||||
|
||||
import (
|
||||
"blazing/cool"
|
||||
"blazing/modules/config/model"
|
||||
|
||||
"github.com/alpacahq/alpacadecimal"
|
||||
"github.com/gogf/gf/v2/database/gdb"
|
||||
"github.com/gogf/gf/v2/frame/g"
|
||||
"github.com/gogf/gf/v2/util/grand"
|
||||
)
|
||||
|
||||
// PetFusionService 宠物融合配方主表Service(对应pet_fusion表)
|
||||
type PetFusionService struct {
|
||||
*cool.Service // 嵌入通用Service(继承基础CRUD方法)
|
||||
}
|
||||
|
||||
var PetFusionServiceS = NewPetFusionService()
|
||||
|
||||
// NewPetFusionService 创建PetFusionService实例
|
||||
func NewPetFusionService() *PetFusionService {
|
||||
return &PetFusionService{
|
||||
&cool.Service{
|
||||
Model: model.NewPetFusion(), // 绑定PetFusion模型
|
||||
//Cache: gcache.New(),
|
||||
PageQueryOp: &cool.QueryOp{FieldEQ: []string{"is_enable", "main_pet_id", "sub_pet_id", "result_pet_id"}},
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
//获取主副精灵融合的id,如果不存在,那就给一个保底的id
|
||||
|
||||
func (s *PetFusionService) Data(p1, p2, rand uint32) uint32 {
|
||||
rand = uint32(alpacadecimal.NewFromInt(int64(rand)).Mul(alpacadecimal.NewFromFloat(0.5)).IntPart())
|
||||
|
||||
pet := s.getData(p1, p2)
|
||||
for _, v := range pet {
|
||||
|
||||
rr := grand.Intn(100)
|
||||
if rr < int(v.Probability+int32(rand)) {
|
||||
return uint32(v.ResultPetID)
|
||||
}
|
||||
}
|
||||
//说明是失败,直接返回失败
|
||||
if len(pet) > 0 {
|
||||
return 0
|
||||
}
|
||||
pets := s.def()
|
||||
res := pets[grand.Intn(len(pets)-1)]
|
||||
rr := grand.Intn(100)
|
||||
if rr < int(res.Probability+int32(rand)) {
|
||||
return uint32(res.ResultPetID)
|
||||
}
|
||||
//到这里相当于直接失败
|
||||
return 0
|
||||
|
||||
}
|
||||
func (s *PetFusionService) getData(p1, p2 uint32) []model.PetFusion {
|
||||
//cacheKey := strings.Join([]string{fmt.Sprintf("%d", p1), fmt.Sprintf("%d", p2)}, ":")
|
||||
m := cool.DBM(s.Model)
|
||||
|
||||
var pet []model.PetFusion //一个特性应该是唯一的,但是我们要获取默认随机特性
|
||||
condition := g.Map{
|
||||
"main_pet_id": p1,
|
||||
"sub_pet_id": p2,
|
||||
"is_enable": 1,
|
||||
// "hits between ? and ?" : g.Slice{1, 10},
|
||||
// "exp > 0" : nil,
|
||||
// "category" : g.Slice{100, 200},
|
||||
}
|
||||
m.Where(condition).Cache(gdb.CacheOption{
|
||||
// Duration: time.Hour,
|
||||
|
||||
Force: false,
|
||||
}).Scan(&pet)
|
||||
return pet
|
||||
|
||||
}
|
||||
func (s *PetFusionService) def() []model.PetFusion {
|
||||
|
||||
var pets []model.PetFusion
|
||||
m := cool.DBM(s.Model)
|
||||
m.Where("is_enable", 1).Where("is_default", 1).Cache(gdb.CacheOption{
|
||||
// Duration: time.Hour,
|
||||
|
||||
Force: false,
|
||||
}).Scan(&pets)
|
||||
|
||||
return pets
|
||||
// return ret.Interface().([]model.PetFusion)
|
||||
|
||||
}
|
||||
35
modules/config/service/talkconfig.go
Normal file
35
modules/config/service/talkconfig.go
Normal file
@@ -0,0 +1,35 @@
|
||||
package service
|
||||
|
||||
import (
|
||||
"blazing/cool"
|
||||
"blazing/modules/config/model"
|
||||
|
||||
"github.com/gogf/gf/v2/database/gdb"
|
||||
)
|
||||
|
||||
type TalkConfigService struct {
|
||||
*cool.Service
|
||||
}
|
||||
|
||||
var TalkConfigServiceS = NewTalkConfigService()
|
||||
|
||||
func NewTalkConfigService() *TalkConfigService {
|
||||
return &TalkConfigService{
|
||||
|
||||
Service: &cool.Service{Model: model.NewMineralCollectionConfig()},
|
||||
// Cache: gcache.New()},
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
func (s *TalkConfigService) GetCache(flag int) []model.MineralCollectionConfig {
|
||||
|
||||
var config []model.MineralCollectionConfig
|
||||
cool.DBM(s.Model).Where("type", flag).Cache(gdb.CacheOption{
|
||||
// Duration: time.Hour,
|
||||
|
||||
Force: false,
|
||||
}).Scan(&config)
|
||||
return config
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user