Truong Van Luyn /
← Skill catalog

TURN

Per-session TURN credentials minted from an HMAC of a shared secret, so voice can connect through restrictive NATs.

In practice

Werewolf 3D: a server-authoritative party game

A ten-seat social deduction game played around a 3D campfire in the browser, with private lobbies, built-in AI players, text chat and a WebRTC voice path.

Problem
A Werewolf match needs ten players, and every player must see only what their role allows. Rejoining after a drop must not leak or lose state. A group of friends should be able to play without filling every seat, and without paid AI services.
Contribution
Sole developer: game rules, server, AI players, 3D client, networking protocol, media service and CI.
Approach
A TypeScript monorepo separates a pure rules package, a shared protocol package, a WebSocket game server, a Three.js client and a mediasoup media service. The server is the only authority. It projects a per-recipient view of each match, so hidden roles and night actions never reach clients that should not see them. AI players run inside the server and deliberately have no access to the match's private state — they act only on what they observed. Voice uses a mediasoup SFU, with TURN credentials minted per session from an HMAC of a shared secret.
Outcome
Playable locally and over a LAN with one to ten humans and up to nine AI players, core and starter role presets, reconnect handling with 60-second seat holds, and phone and tablet layouts. Voice is implemented but disabled by default; hardware benchmarks and human playtests are still pending.