kku_item_chest_contents.sql 1.8 KB

12345678910111213141516171819202122232425
  1. -- 表 kku_item_chest_contents 的创建SQL
  2. DROP TABLE IF EXISTS `kku_item_chest_contents`;
  3. CREATE TABLE `kku_item_chest_contents` (
  4. `id` int NOT NULL AUTO_INCREMENT COMMENT '记录ID,主键',
  5. `chest_id` int NOT NULL COMMENT '宝箱物品ID,外键关联kku_item_items表',
  6. `item_id` int DEFAULT NULL COMMENT '可能获得的物品ID,外键关联kku_item_items表(与group_id二选一)',
  7. `group_id` int DEFAULT NULL COMMENT '物品组ID,外键关联kku_item_groups表(与item_id二选一)',
  8. `min_quantity` int DEFAULT '1' COMMENT '最小数量',
  9. `max_quantity` int DEFAULT '1' COMMENT '最大数量',
  10. `weight` decimal(5,3) NOT NULL COMMENT '权重,决定获取概率',
  11. `allow_duplicate` tinyint DEFAULT '0' COMMENT '是否允许在同一宝箱中重复掉落(0:不允许, 1:允许)',
  12. `pity_count` int DEFAULT '0' COMMENT '保底次数,当玩家连续未获得该内容达到次数后必定获得(0表示不启用保底)',
  13. `pity_weight_factor` float DEFAULT '1' COMMENT '保底权重因子,用于递增概率计算(默认1.0)',
  14. `created_at` timestamp NULL DEFAULT NULL COMMENT '创建时间',
  15. `updated_at` timestamp NULL DEFAULT NULL COMMENT '更新时间',
  16. PRIMARY KEY (`id`),
  17. KEY `idx_chest_id` (`chest_id`),
  18. KEY `idx_item_id` (`item_id`),
  19. KEY `idx_group_id` (`group_id`),
  20. KEY `idx_pity_count` (`pity_count`),
  21. CONSTRAINT `fk_chest_content_chest` FOREIGN KEY (`chest_id`) REFERENCES `kku_item_items` (`id`) ON DELETE CASCADE,
  22. CONSTRAINT `fk_chest_content_group` FOREIGN KEY (`group_id`) REFERENCES `kku_item_groups` (`id`) ON DELETE CASCADE,
  23. CONSTRAINT `fk_chest_content_item` FOREIGN KEY (`item_id`) REFERENCES `kku_item_items` (`id`) ON DELETE CASCADE
  24. ) ENGINE=InnoDB AUTO_INCREMENT=4 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci COMMENT='宝箱内容配置表';