|
|
@@ -54,7 +54,7 @@ GameItems模块主要负责游戏内所有物品的管理,包括但不限于
|
|
|
| description | text | 物品描述 |
|
|
|
| category_id | int | 物品分类ID,外键关联item_categories表 |
|
|
|
| type | tinyint | 物品类型(用于区分可用操作,1:可使用, 2:可装备, 3:可合成, 4:可交任务, 5:可开启...) |
|
|
|
-| can_be_unique | tinyint | 是否可以成为单独属性物品(0:否, 1:是) |
|
|
|
+| is_unique | tinyint | 是否是单独属性物品(0:否,默认, 1:是) |
|
|
|
| rarity | tinyint | 稀有度(1:普通, 2:稀有, 3:史诗, 4:传说...) |
|
|
|
| icon | varchar | 物品图标路径 |
|
|
|
| max_stack | int | 最大堆叠数量 |
|
|
|
@@ -159,7 +159,7 @@ GameItems模块主要负责游戏内所有物品的管理,包括但不限于
|
|
|
| item_categories | parent_id | 普通索引 | 加速查询子分类 |
|
|
|
| item_categories | code | 唯一索引 | 确保分类编码唯一性 |
|
|
|
| items | type | 普通索引 | 加速按物品类型查询 |
|
|
|
-| items | can_be_unique | 普通索引 | 加速查询可成为单独属性的物品 |
|
|
|
+| items | is_unique | 普通索引 | 加速查询单独属性物品 |
|
|
|
| items | global_expire_at | 普通索引 | 加速过期物品查询 |
|
|
|
| item_instances | id | 主键 | 唯一物品ID主键索引 |
|
|
|
| item_instances | item_id | 普通索引 | 加速根据基础物品查询唯一物品 |
|
|
|
@@ -167,8 +167,13 @@ GameItems模块主要负责游戏内所有物品的管理,包括但不限于
|
|
|
| item_users | user_id, item_id | 复合索引 | 加速用户统一属性物品查询 |
|
|
|
| item_users | user_id, instance_id | 复合索引 | 加速用户单独属性物品查询 |
|
|
|
| item_users | expire_at | 普通索引 | 加速过期物品查询 |
|
|
|
+| item_groups | id | 主键 | 物品组ID主键索引 |
|
|
|
+| item_groups | code | 唯一索引 | 确保物品组编码唯一性 |
|
|
|
+| item_group_items | group_id | 普通索引 | 加速查询物品组内容 |
|
|
|
+| item_group_items | item_id | 普通索引 | 加速查询物品所属物品组 |
|
|
|
| item_chest_contents | chest_id | 普通索引 | 加速宝箱内容查询 |
|
|
|
| item_chest_contents | item_id | 普通索引 | 加速物品在宝箱中的查询 |
|
|
|
+| item_chest_contents | group_id | 普通索引 | 加速查询物品组在宝箱中的配置 |
|
|
|
| item_chest_contents | is_unique | 普通索引 | 加速查询生成唯一物品的宝箱配置 |
|
|
|
| item_chest_contents | pity_count | 普通索引 | 加速查询启用保底的宝箱内容 |
|
|
|
|
|
|
@@ -188,9 +193,13 @@ graph TD
|
|
|
Category["item_categories<br>物品分类"] -->|"1:N"| Item
|
|
|
Category -->|"1:N"| Category
|
|
|
|
|
|
+ ItemGroup["item_groups<br>物品组"] --- GroupItems{"item_group_items<br>物品组内容"}
|
|
|
+ GroupItems -->|"N:1"| Item
|
|
|
+
|
|
|
subgraph "宝箱系统"
|
|
|
ChestItem["Item<br>(宝箱分类)"] -->|"1:N"| ChestConfig["item_chest_contents<br>宝箱配置"]
|
|
|
- ChestConfig -->|"N:1"| ItemDrop["Item<br>掉落物品"]
|
|
|
+ ChestConfig -->|"item_id"| ItemDrop["Item<br>掉落物品"]
|
|
|
+ ChestConfig -->|"group_id"| ItemGroup
|
|
|
ChestConfig -->|"is_unique=1"| InstanceItem
|
|
|
|
|
|
ChestConfig -->|"pity_count>0"| HasPity["(启用保底)"]
|
|
|
@@ -203,8 +212,8 @@ graph TD
|
|
|
classDef junction fill:#bbf,stroke:#33f,stroke-width:2px;
|
|
|
classDef virtual fill:#dfd,stroke:#383,stroke-width:1px;
|
|
|
|
|
|
- class User,Item,InstanceItem,ChestItem,ItemDrop,Category entity;
|
|
|
- class UserItems,ChestConfig,PityCounter junction;
|
|
|
+ class User,Item,InstanceItem,ChestItem,ItemDrop,Category,ItemGroup entity;
|
|
|
+ class UserItems,ChestConfig,PityCounter,GroupItems junction;
|
|
|
class HasPity virtual;
|
|
|
```
|
|
|
|
|
|
@@ -213,8 +222,9 @@ graph TD
|
|
|
- **InstanceItem 与 Item**:多对一关系,每个单独属性物品都关联到一个基础物品模板
|
|
|
- **Category 与 Item**:一对多关系,每个物品属于一个分类
|
|
|
- **Category 与 Category**:一对多关系,实现分类的层级结构
|
|
|
+- **ItemGroup 与 Item**:多对多关系,通过 item_group_items 表实现物品组与物品的关联
|
|
|
- **宝箱物品与掉落物品**:属于宝箱分类的Item与 item_chest_contents 表是一对多关系
|
|
|
-- **item_chest_contents 与物品**:可以配置生成统一属性物品或单独属性物品(通过is_unique字段控制)
|
|
|
+- **item_chest_contents 与物品/物品组**:可以配置单个物品或物品组作为奖励,并可以生成单独属性物品(通过is_unique字段控制)
|
|
|
- **宝箱内容保底**:宝箱内容配置通过 pity_count 字段直接定义保底次数
|
|
|
- **用户与宝箱内容保底**:用户通过 item_pity_times 表记录对每个宝箱内容的尝试次数
|
|
|
|
|
|
@@ -229,7 +239,7 @@ graph TD
|
|
|
1. **物品类型分离**
|
|
|
- `item_categories`表实现物品分类的层级结构,支持无限层级的分类
|
|
|
- `items`表存储统一属性物品,属性以JSON格式存储,并关联到分类
|
|
|
- - `items`表中的`can_be_unique`字段标记该物品是否可以成为单独属性物品
|
|
|
+ - `items`表中的`is_unique`字段标记该物品是否是单独属性物品
|
|
|
- `item_instances`表存储单独属性物品,属性以JSON格式存储
|
|
|
- 每个单独属性物品都关联到一个基础物品模板
|
|
|
|
|
|
@@ -241,12 +251,12 @@ graph TD
|
|
|
3. **宝箱生成机制**
|
|
|
- 宝箱可以配置生成统一属性物品或单独属性物品
|
|
|
- 通过`item_chest_contents`表中的`is_unique`字段控制生成类型
|
|
|
- - 只有`items`表中`can_be_unique`为1的物品才能生成单独属性物品实例
|
|
|
+ - 只有`items`表中`is_unique`为1的物品才能生成单独属性物品实例
|
|
|
|
|
|
#### 实现要点
|
|
|
|
|
|
1. **单独属性物品创建流程**
|
|
|
- - 获取基础物品信息,并检查`can_be_unique`是否为1
|
|
|
+ - 获取基础物品信息,并检查`is_unique`是否为1
|
|
|
- 生成随机属性(展示属性和数值属性)
|
|
|
- 创建单独属性物品实例记录
|
|
|
- 将物品实例关联到用户
|
|
|
@@ -393,6 +403,7 @@ graph TD
|
|
|
|
|
|
- 每个宝箱类型物品在`numeric_attributes`字段中定义了`min_drop_count`和`max_drop_count`属性,而不是使用独立字段
|
|
|
- 宝箱物品属于特定的分类(在item_categories表中定义)
|
|
|
+- 宝箱内容可以配置单个物品或物品组,物品组可以包含多个物品并根据权重随机选择
|
|
|
- 系统在打开宝箱时会随机决定实际掉落的物品数量
|
|
|
- 可以通过`item_chest_contents`表中的`allow_duplicate`字段控制物品是否可以在同一宝箱中重复掉落
|
|
|
|