2025-12-01 23:31:48 +08:00
|
|
|
|
package model
|
|
|
|
|
|
|
|
|
|
|
|
import (
|
|
|
|
|
|
"blazing/cool"
|
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
const (
|
2026-01-19 18:51:56 +08:00
|
|
|
|
TableNamePetFusion = "config_fusion_pet" // 宠物融合配方表(主表)
|
2025-12-01 23:31:48 +08:00
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
// PetFusion 宠物融合配方主模型(核心配方规则)
|
|
|
|
|
|
type PetFusion struct {
|
|
|
|
|
|
*cool.Model // 嵌入通用Model(ID/创建时间/更新时间等)
|
|
|
|
|
|
|
2025-12-02 03:59:28 +08:00
|
|
|
|
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"`
|
2025-12-01 23:31:48 +08:00
|
|
|
|
|
|
|
|
|
|
// 关联:一个配方对应多个材料(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{})
|
|
|
|
|
|
}
|