r/webdev • • 14m ago

Showoff Saturday A multiplayer card game with no game server: Rust/WASM rules engine, static SvelteKit, peer-to-peer over WebRTC

Post image

I started this as a Rust side project in 2022, shelved it, and came back to it last week. It's now a full game: Strato, a card game you can play against bots, pass around one phone, or play online with friends. No signup.

How it's put together:

- The rules engine is Rust compiled to WebAssembly. It's a pure state machine with no I/O: you give it a move, it gives back what happened. The Svelte app never re-implements a rule; it only asks the engine what's legal and draws the result.

- The app is a static SvelteKit site and an installable PWA, so it works offline once you've opened it.

- Online play is peer-to-peer over WebRTC. Public Nostr relays (via Trystero) are only used for matchmaking. One phone runs the game as host, and if it drops, the next player's phone takes over mid-game.

- The daily deal is seeded from the date, so every device deals the same cards with no server handing them out.

Play: https://strato.parker-codes.dev

Write-up on how it came together: https://parker-codes.dev/blog/strato

Source: https://github.com/parker-codes/strato

I'd appreciate feedback, especially if you've built games before.

1 Upvotes

0 comments sorted by