Close CPU tables as soon as every human player leaves

- When the last human presses leave on a CPU table (even mid-hand), the table
  is deleted right away instead of lingering with CPUs only; friends / cash-only
  tables keep the existing 30-minute idle cleanup
- Spectators still watching get a "テーブルが終了しました" notice, and the lobby
  updates immediately
- Don't show the "接続が切れました" banner when the page disconnects on purpose
  (closed or missing table)
- Test for the close condition; README notes the behavior

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
agomizi1cmandClaude Opus 5.5 committed 2026-10-17 17:03:58 +09:00
1 parent 0d3a054f0d
commit 02c8e76237
6 files changed
+63 -6

No files matched your search

+14 -2
View File
@@ -52,6 +52,7 @@
});
socket.on('disconnect', () => { $('conn-lost').hidden = false; });
socket.on('connect_error', () => { $('conn-lost').hidden = false; });
socket.on('table:closed', () => showNotFound(true));
socket.on('table:state', (s) => {
state = s;
pending = false;
@@ -90,11 +91,22 @@
render();
}
function showNotFound() {
// closed: プレイヤーが全員退席してテーブルが閉じられた
function showNotFound(closed) {
if (closed) {
$('not-found-title').textContent = 'テーブルが終了しました';
$('not-found-text').textContent = 'プレイヤーが全員退席したため、テーブルを閉じました。';
}
$('main').hidden = true;
$('action-bar').hidden = true;
$('not-found').hidden = false;
if (socket) socket.disconnect();
// 自分から切断するので「接続が切れました」は出さない
if (socket) {
socket.off('disconnect');
socket.off('connect_error');
socket.disconnect();
}
$('conn-lost').hidden = true;
}
const nameOf = (seat) => (state.seats[seat] ? state.seats[seat].name : '退席者');
+2 -2
View File
@@ -100,8 +100,8 @@
</div>
<div class="center-message" id="not-found" hidden>
<h2>テーブルが見つかりません</h2>
<p>終了したか、URLが間違っている可能性があります。</p>
<h2 id="not-found-title">テーブルが見つかりません</h2>
<p id="not-found-text">終了したか、URLが間違っている可能性があります。</p>
<a class="btn btn-blue" href="/">ロビーへ戻る</a>
</div>