CI failed once on aGameInProgressSurvivesARestart: a room took its
snapshot after an event was handled, but sent the new table during it,
so a server stopping in between saved the game one move behind what the
players had already seen. A room now takes its snapshot before it sends
a table or the seating.
A refused connection (too many from one address, or too many messages)
now flushes its error before the socket closes, so the client reads it.
The connection-limit test waits for the server to see the first
connection close before opening another, instead of racing it.
Failing server tests now print their full message in the build log, as
CI runs them inside the image build.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Sounds: your turn to play or to call, 10 seconds left and the last five
ticking (online), cards, the deal, a trick gathered, trump called, the
end of a hand, winning or losing, and someone sitting down in your room.
They are synthesised in code (struck bells, filtered noise), so there
are no audio files to license, and played through SoundPool on Android
and Web Audio in the browser. The cues follow the game state outside of
composition, so a browser tab in the background still chimes when it is
your turn. A speaker button on the table and a switch in the settings
turn them off.
Online, every move and call now has 30 seconds; then the server's bot
makes it. Two in a row and the bot plays for that player without
waiting until they tap "Vraćam se" (or, with nobody else at the table,
the game waits for them). After a hand the next one is dealt within 30
seconds. The time shows as a ring round the portrait of whoever is to
play, on your own plate while you play and under the trump offer while
you call. Tables carry the time left and the autoplay state as new
optional fields, so older clients still work.
The suits are now called as players call the Hungarian cards: Herc,
Bundeva, Zelje, Žir ("zove bundevu").
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Someone scripting the server could guess the 4-character room codes
without limit (one connection, thousands a second), open all 2000 rooms
in seconds, or flood it with connections and messages. Per IP address
now:
- 10 wrong room codes in a row, then one a minute; while cut off even a
right code gets no answer. Coming back to your seat with a token is
not limited, and answers the same whether the room or the seat is
gone, so it tells nothing about which codes are in use.
- 10 new rooms in a row, then one every 3 minutes.
- 32 connections at a time; 40 messages in a burst, then 10 a second.
The address comes from X-Forwarded-For only when the connection is from
the local or Docker network (the TLS proxy); the server warns once if
such connections arrive without the header.
A room where no player did anything for 3 hours now closes even with
screens still connected (a forgotten tab), telling them why. Rooms
nobody is connected to already closed after 10 minutes.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A redeploy no longer ends the games in progress. The server writes the open
rooms (players, tokens, host, and each game as its seed and moves) to
$DATA_DIR/rooms.json every few seconds when something changed and once more
on shutdown (SIGTERM via Ktor's shutdown hook), and loads them before it
accepts connections. Clients reconnect with their saved token and get the
same table back; bots wait 30 s for them after a restart. Saves older than
10 minutes are ignored, and a game the new rules cannot replay leaves the
room in the lobby.
The image sets DATA_DIR=/data (owned by the bela user) and the compose file
mounts the bela-data named volume on it.
Also fixes a flaky test: the guest ignored its first table, so the game
waited forever whenever the random dealer made the guest call first.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
- shared: the whole UI moves to Compose Multiplatform (Android + Kotlin/Wasm). Platform pieces
(card images, storage, links, back button) come in through a Platform interface; fonts, logo and
suit icons are compose resources; images are reduced by halving so they stay sharp everywhere.
- web: the browser app (bela.mariosem.es), with 1x card faces, localStorage and room links (?soba=KOD).
- Online play: lobby (name, open a room, join by code), waiting room with seats, then the usual
table. The server runs every game with the engine and sends each player only their own view;
bots fill empty seats; same pacing as the local game. Reconnect with a saved token (also after
closing the app or reloading the page), 10 s grace before a bot plays for an absent player,
heartbeat so dead connections are noticed.
- server: Ktor (WebSocket /ws, /health, serves the web app with pre-compressed files). Tests cover
a whole two-player game, resume and leaving.
- Dockerfile (one image: web + server, tests run in the build), docker-compose.yml and a Gitea
Actions workflow like Keep's (build, Trivy scan, push msemes/bela:<sha> and :latest).
- Android talks to the server with Ktor CIO; the update section stays Android-only. The QR code is
precomputed (QrMatrix) and checked against ZXing in a unit test.
- -PbelaNoAndroid=true builds without the Android SDK; -PbelaDownloadNode=false reuses the local Node.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>