Feature: public rooms, mobile UX, reconnection, and gameplay fixes
Rooms & lobby
- Rename docker-compose.yml → compose.yml
- Public/Private toggle on room creation; public rooms assign random seats
to prevent team collusion
- GET /api/rooms API — lists open public rooms; Join tab shows live list
with one-tap join
- Room creator: swap any two seats by tapping (select-to-swap UI); ▶ Start
Game button force-starts with bots filling empty seats
Reconnection
- Session moved from sessionStorage → localStorage (survives browser close)
- Socket handlers split: socket.once for one-shot callbacks, persistent
socket.on('connect') for auto-rejoin on network drops
- Server rejoin accepts userId match as fallback (cross-device rejoin for
authenticated users); re-issues token on success
- Server emits hasActiveGame on connect so auth'd users on a new device are
pulled back into their game automatically
- Explicit leave nulls seat/token/userIds so hasActiveGame never re-drags a
player back in after they chose to leave
Mobile UX
- Remove all opponent/partner card backs; replace with compact card-count
badge — frees ~120px of vertical space on small phones
- Screen height: 100dvh (dynamic viewport) instead of 100vh — fixes the
"only top 1/5 visible" issue on phones with browser chrome
- Table grid side columns shrunk to 36px on touch devices; player names
rotated vertically
- Bidding overlay: transparent non-blocking top panel on touch; hand stays
visible and interactive; auto fan-mode during bidding
- touch-action: pan-x on hand scroll, none in fan/drag mode — suppresses
Android back-gesture and Google Gemini conflicts
- user-select: none on game screen prevents long-press selection menus
Gameplay & notifications
- Center trick area now shows whose turn it is instead of trump (trump is
already in the info bar); flashes gold when it's the player's turn
- Turn reminder after 5 s of inaction: gold glow pulse on hand area
+ Android vibration OR two-note Web Audio chime on iOS (vibrate API not
supported by Apple)
- Fix: turn reminder was never triggered after winning a trick — justWon
branch blocked myTurnNow from being set even when currentTurn === mySeat
- Waiting room ☰ menu: Reload and Exit accessible without entering the game
- Prevent duplicate room joins (same socket, same userId, or same name)
Service worker
- Bump to shelem-v2; pre-cache all 55 card SVGs at install time so cards
are available instantly from the very first hand, including offline
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
+27
-1
@@ -1,5 +1,28 @@
|
||||
'use strict';
|
||||
const CACHE_NAME = 'shelem-v1';
|
||||
const CACHE_NAME = 'shelem-v2';
|
||||
|
||||
// ── Generate all 55 card paths ──────────────────────────────────
|
||||
const SUITS = ['CLUB', 'DIAMOND', 'HEART', 'SPADE'];
|
||||
const CARD_PATHS = [
|
||||
'/cards/JOKER-1.svg',
|
||||
'/cards/JOKER-2.svg',
|
||||
'/cards/JOKER-3.svg',
|
||||
...SUITS.flatMap(s => [
|
||||
`/cards/${s}-1.svg`,
|
||||
`/cards/${s}-2.svg`,
|
||||
`/cards/${s}-3.svg`,
|
||||
`/cards/${s}-4.svg`,
|
||||
`/cards/${s}-5.svg`,
|
||||
`/cards/${s}-6.svg`,
|
||||
`/cards/${s}-7.svg`,
|
||||
`/cards/${s}-8.svg`,
|
||||
`/cards/${s}-9.svg`,
|
||||
`/cards/${s}-10.svg`,
|
||||
`/cards/${s}-11-JACK.svg`,
|
||||
`/cards/${s}-12-QUEEN.svg`,
|
||||
`/cards/${s}-13-KING.svg`,
|
||||
]),
|
||||
];
|
||||
|
||||
const PRECACHE = [
|
||||
'/',
|
||||
@@ -10,6 +33,7 @@ const PRECACHE = [
|
||||
'/icons/icon-192.png',
|
||||
'/icons/icon-512.png',
|
||||
'/icons/icon.svg',
|
||||
...CARD_PATHS,
|
||||
];
|
||||
|
||||
self.addEventListener('install', event => {
|
||||
@@ -33,6 +57,7 @@ self.addEventListener('fetch', event => {
|
||||
if (event.request.method !== 'GET') return;
|
||||
if (url.includes('/socket.io/')) return;
|
||||
|
||||
// Cards: always serve from cache (never change)
|
||||
if (url.includes('/cards/')) {
|
||||
event.respondWith(
|
||||
caches.match(event.request).then(cached => {
|
||||
@@ -46,6 +71,7 @@ self.addEventListener('fetch', event => {
|
||||
return;
|
||||
}
|
||||
|
||||
// Everything else: network-first, cache as offline fallback
|
||||
event.respondWith(
|
||||
fetch(event.request)
|
||||
.then(res => {
|
||||
|
||||
Reference in New Issue
Block a user