resolveGuessAnyTarget() answers a GUESS with no targetId; resolveGuess() is the explicit path
A 1 s tick thread broadcasts TICK and ends the round, or freezes the clock when autoEndOnTimeout is off
HttpServer.kt
TCP 8080 — hand-rolled HTTP/1.1, one thread per connection
GET / landing page
GET /tv/ tv/index.html
GET /tv/* tv/*
GET /play/ play/index.html
GET /play/* play/*
GET /api/info
GET /api/health
GET /api/qr?text=
404 for anything else
/api/info hands out host, httpPort, wsPort and both URLs; /api/qr renders a PNG with ZXing.
WsServer
TCP 8081 — Java-WebSocket 1.5.4, bound to 0.0.0.0
Role is read off the
handshake, never logged in:
/tv → Role.TV
/play → Role.PLAYER
?role=tv|player|host
Broadcasts snapshot the connection set and drop dead sockets: a concurrent modification here used to swallow a whole ROUND_START and strand the TV on the lobby.
Everything the browsers need ships inside this APK
the host app's assets/ folder is the whole web front-end
GUESS may omit targetId. GameState.resolveGuessAnyTarget() works out which unsolved drawing the word belongs to. That is what allows one shared guess box on all three clients.
A correct guess is broadcast to everybody, because the TV and the live scoreboard need it. Each client must ignore the correct case unless byPlayerId is its own playerId, or the first solver's success would lock everybody else's row.
noMatch carries near[{targetId, distance}]: distance 1 flashes the row yellow, 2 orange, every other unsolved row red. alreadySolved raises a dialog instead.
DRAWING is forwarded only to Role.TV and Role.HOST. That is what keeps a 15-player room from saturating the LAN with a data URL every two seconds.
Duplication traps — change these in every copy
Avatar cell geometry is hard-coded in FOUR places: AvatarSprite.kt (COL_LEFT / COL_RIGHT / ROW_TOP / ROW_BOTTOM) and the AV_COL_* / AV_ROW_* tables in play.js and in tv.js. The 10×8 grid is not uniform, so those numbers are measured, never computed.
GUESS_COOLDOWN_MS = 200 lives in Constants.kt and in play.js. The browser build cannot import a Kotlin constant; change one and the two clients throttle differently.
avatar.css is duplicated between assets/play/ and assets/tv/. Fix one, fix the other, then rebuild.
Never put JavaScript in a .css file. avatar.css is loaded with <link>, so the browser discards the function silently and setAvatarIndex is undefined inside every render.
Build and packaging
minSdk 26, compileSdk 34, Java 17, viewBinding, one module.
One flavour dimension, platform: modern (targetSdk 34) and android11 (targetSdk 30, which opts out of the Android 12+ behaviour changes). The apks Gradle task builds both into app/build/outputs/apk/.
android:usesCleartextTraffic="true" — the whole game is plain http and ws on the LAN.
Permissions: INTERNET, ACCESS_NETWORK_STATE, ACCESS_WIFI_STATE. The last two exist to discover the local IP for the QR code.
Five Activities, only MainActivity exported: Main, Host, Player, Settings, AvatarPicker.
Read out of the source on branch main, 2026-10-04. Ports from Constants.DEFAULT_PORT (8080) and 8080 + 1; the two message directions from Protocol.kt and GameService.dispatch().