From 0e6aab105bfd8f0bd17484ec8f51b291a3788c89 Mon Sep 17 00:00:00 2001 From: liuwei Date: Fri, 21 Feb 2025 16:33:46 +0800 Subject: [PATCH] =?UTF-8?q?feature=EF=BC=9A=E6=96=B0=E5=A2=9E=E7=BE=A4?= =?UTF-8?q?=E7=99=BE=E7=A7=91=E6=B8=B8=E6=88=8F=EF=BC=8C=E7=94=A8=E4=BA=8E?= =?UTF-8?q?=E4=BF=83=E8=BF=9B=E7=BE=A4=E6=B4=BB=E8=B7=83=E3=80=82=E5=8A=A0?= =?UTF-8?q?=E5=85=A5=E4=BA=86=E6=96=B0=E7=9A=84=E6=8C=87=E4=BB=A4=20=20?= =?UTF-8?q?=E5=8F=AF=E7=94=A8=EF=BC=9A/start,=20/tasks,=20/list,=20/answer?= =?UTF-8?q?=20[=E4=BB=BB=E5=8A=A1ID]=20[=E7=AD=94=E6=A1=88],=20/addgroup,?= =?UTF-8?q?=20/rank?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- game_task/game_task.sql | 46 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 46 insertions(+) create mode 100644 game_task/game_task.sql diff --git a/game_task/game_task.sql b/game_task/game_task.sql new file mode 100644 index 0000000..91fae4f --- /dev/null +++ b/game_task/game_task.sql @@ -0,0 +1,46 @@ +USE message_archive; + +CREATE TABLE t_encyclopedia_groups ( + group_id INT PRIMARY KEY, + created_at DATETIME DEFAULT CURRENT_TIMESTAMP +) ENGINE=InnoDB CHARACTER SET utf8mb4; + +CREATE TABLE t_encyclopedia_players ( + player_id INT NOT NULL, + group_id INT NOT NULL, + player_name VARCHAR(50) NOT NULL, + points INT DEFAULT 0, + created_at DATETIME DEFAULT CURRENT_TIMESTAMP, + PRIMARY KEY (player_id, group_id), + FOREIGN KEY (group_id) REFERENCES t_encyclopedia_groups(group_id) +) ENGINE=InnoDB CHARACTER SET utf8mb4; + +CREATE TABLE t_encyclopedia_active_tasks ( + active_task_id INT AUTO_INCREMENT PRIMARY KEY, + group_id INT NOT NULL, + question VARCHAR(255) NOT NULL, + answer VARCHAR(100) NOT NULL, + score INT NOT NULL, + description TEXT, + holder_id INT NOT NULL, + assigned_at DATETIME DEFAULT CURRENT_TIMESTAMP, + status ENUM('pending', 'completed') DEFAULT 'pending', + FOREIGN KEY (group_id) REFERENCES t_encyclopedia_groups(group_id), + FOREIGN KEY (holder_id, group_id) REFERENCES t_encyclopedia_players(player_id, group_id), + INDEX (group_id) +) ENGINE=InnoDB CHARACTER SET utf8mb4; + +CREATE TABLE t_encyclopedia_task_history ( + history_id INT AUTO_INCREMENT PRIMARY KEY, + group_id INT NOT NULL, + active_task_id INT NOT NULL, + player_id INT NOT NULL, + answer VARCHAR(100) NOT NULL, + is_correct BOOLEAN DEFAULT FALSE, + points_earned INT DEFAULT 0, + completed_at DATETIME DEFAULT CURRENT_TIMESTAMP, + FOREIGN KEY (group_id) REFERENCES t_encyclopedia_groups(group_id), + FOREIGN KEY (active_task_id) REFERENCES t_encyclopedia_active_tasks(active_task_id), + FOREIGN KEY (player_id, group_id) REFERENCES t_encyclopedia_players(player_id, group_id), + INDEX (group_id) +) ENGINE=InnoDB CHARACTER SET utf8mb4; \ No newline at end of file