From 758043c4275498c94eeed26213536052349dd449 Mon Sep 17 00:00:00 2001
From: Tor Andersson <tor@ccxvii.net>
Date: Sat, 1 Jul 2023 15:02:17 +0200
Subject: Add "snapshot" replay view during play.

Snapshots store game state without undo and only log length.
Combined with the final game state's log we can recreate the view
from any snapshot quickly.

Move replay code into separate script file, loaded only when used.

Prefix system "setup", "resign", and "restore" actions with a period.
---
 schema.sql | 10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)

(limited to 'schema.sql')

diff --git a/schema.sql b/schema.sql
index 95e2690..f959720 100644
--- a/schema.sql
+++ b/schema.sql
@@ -322,10 +322,17 @@ create table if not exists game_replay (
 	replay_id integer,
 	role text,
 	action text,
-	arguments json, -- numeric affinity is more compact for numbers
+	arguments json,
 	primary key (game_id, replay_id)
 ) without rowid;
 
+create table if not exists game_snap (
+	game_id integer,
+	snap_id integer,
+	state text,
+	primary key (game_id, snap_id)
+);
+
 create table if not exists game_notes (
 	game_id integer,
 	role text,
@@ -440,6 +447,7 @@ begin
 	delete from game_state where game_id = old.game_id;
 	delete from game_chat where game_id = old.game_id;
 	delete from game_replay where game_id = old.game_id;
+	delete from game_snap where game_id = old.game_id;
 	delete from game_notes where game_id = old.game_id;
 	delete from last_notified where game_id = old.game_id;
 	delete from unread_chats where game_id = old.game_id;
-- 
cgit v1.2.3

