summaryrefslogtreecommitdiff
path: root/schema.sql
diff options
context:
space:
mode:
authorTor Andersson <tor@ccxvii.net>2025-02-10 22:09:13 +0100
committerTor Andersson <tor@ccxvii.net>2025-02-12 12:05:30 +0100
commit4f123a7c8c8719491ddc4a497d37e99bb5dce549 (patch)
tree3a97a6f60689468428d0169e80967bc82783bc06 /schema.sql
parentb04c539731bac278eee8544a01c6413b88a088c7 (diff)
downloadserver-4f123a7c8c8719491ddc4a497d37e99bb5dce549.tar.gz
Support multi-active player states for 3p+ games.
Diffstat (limited to 'schema.sql')
-rw-r--r--schema.sql21
1 files changed, 15 insertions, 6 deletions
diff --git a/schema.sql b/schema.sql
index 20fd7e3..33cd32c 100644
--- a/schema.sql
+++ b/schema.sql
@@ -154,7 +154,9 @@ create view user_dynamic_view as
status = 1
and user_count = player_count
and players.user_id = users.user_id
- and active in ( 'Both', players.role )
+ -- and active in ( 'Both', players.role )
+ and ( active = 'Both' or instr(active, players.role) )
+
) + (
select
count(*)
@@ -510,13 +512,17 @@ create view player_view as
when 0 then
owner_id = user_id
when 1 then
- active in ( 'Both', role )
+ -- active in ( 'Both', role )
+ ( active = 'Both' or instr(active, role) )
else
0
end
) as is_active,
(
- case when active in ( 'Both', role ) then
+ case when
+ -- active in ( 'Both', role )
+ ( active = 'Both' or instr(active, role) )
+ then
clock - (julianday() - julianday(mtime))
else
clock
@@ -543,7 +549,8 @@ create view time_control_view as
join players using(game_id)
where
status = 1
- and active in ( 'Both', role )
+ -- and active in ( 'Both', role )
+ and ( active = 'Both' or instr(active, role) )
and clock - (julianday() - julianday(mtime)) < 0
;
@@ -888,7 +895,8 @@ begin
update players
set clock = clock - (julianday() - julianday(old.mtime))
where players.game_id = old.game_id
- and old.active in ( 'Both', players.role )
+ -- and old.active in ( 'Both', players.role )
+ and ( old.active = 'Both' or instr(old.active, players.role) )
;
end;
@@ -902,7 +910,8 @@ begin
user_id, old.game_id, (julianday() - julianday(old.mtime))
from players
where players.game_id = old.game_id
- and old.active in ( 'Both', players.role )
+ -- and old.active in ( 'Both', players.role )
+ and ( old.active = 'Both' or instr(old.active, players.role) )
;
end;