Files
bl/modules/config/model/pet_gift.go
昔念 c9bc4be244 ```
feat: 添加ItemInfo结构体并重构抽蛋和任务系统

- 在common/data/color.go中添加ItemInfo结构体用于表示发放物品的信息
- 在common/utils/tomap.go中添加RandomSlice泛型函数用于从切片中随机选取元素
- 重构action_egg.go中的EggGamePlay功能,实现抽蛋逻辑和物品发放
- 更新fight_boss.go中使用新的ItemInfo结构体替换旧的model.ItemInfo
- 修改user_talk.go中获取物品数量的逻辑
- 更新user_task.go中任务完成逻辑使用新的ItemInfo结构体
- 在egg.go中更新抽蛋结果结构体使用ItemInfo
- 更新战斗奖励结构体使用ItemInfo
- 在player.go中添加学习力道具处理逻辑
- 重构任务系统使用新的ItemInfo结构体
- 移除旧的model.ItemInfo定义
- 更新宠物奖励配置模型添加成长值等字段
- 实现GetEgg方法用于获取扭蛋奖励
- 修复宠物融合材料服务中的道具验证逻辑
```
2025-12-26 20:38:08 +08:00

47 lines
2.0 KiB
Go
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

package model
import (
"blazing/cool"
)
// 表名常量定义精灵奖励表存储精灵BOSS/普通精灵对应的奖励配置:掉落物品/数量/概率/获取条件等)
const (
TableNamePetReward = "config_pet_reward" // 精灵奖励配置表(包含基础掉落/稀有奖励/VIP专属奖励/保底机制)
)
// PetReward 精灵奖励基础配置模型(核心存储结构,与数据库表字段一一对应)
type PetReward struct {
*cool.Model // 嵌入通用Model包含ID/创建时间/更新时间等通用字段保持与BossConfig一致
IsEnabled uint32 `gorm:"not null;default:0;comment:'是否启用0-禁用 1-启用)'" json:"is_enabled"`
MonID int32 `gorm:"not null;comment:'BOSS对应的精灵ID'" json:"mon_id"`
DV int32 `gorm:"not null;default:0;comment:'成长值'" json:"dv"`
Nature uint32 `gorm:"not null;default:0;comment:'BOSS属性-性格'" json:"nature"`
Effect uint32 `gorm:"not null;comment:'BOSS特性'" json:"effect"`
Lv int32 `gorm:"not null;comment:'BOSS等级LvHpMatchUser非0时此配置无效'" json:"lv"`
IsEgg uint32 `gorm:"not null;default:0;comment:'是否蛋'" json:"is_egg"` //奖励是否为扭蛋奖励
}
// 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{})
}