Werewolf (also known as Mafia) is a social deduction game where players are secretly assigned roles and must figure out who among them are the werewolves. As much as I love playing this game with friends, moderating it can be challenging - keeping track of all the roles, player states, and the complex night-order sequence requires constant attention and note-taking.

The site: https://tituslesley89.github.io/werewolf-assistant/

Introduction

To make moderating easier, I built a pure JavaScript web app that assists the moderator during gameplay. The app doesn’t replace the physical cards needed to play - it simply provides tools to help the moderator keep track of everything that’s happening in the game. Best of all, it works directly in a mobile browser without requiring any app installation.

Features

The first iteration came together nicely, with several core features working smoothly:

Session Management: The app uses Local Storage to save and load game sessions, so moderators can pause, resume or reset/restart games without losing any information.

Day Cycle Timer: A simple timer in the top-right corner helps moderators keep track of how long each day phase has been running.

Dynamic Night Order: One of the most valuable features is the automatic night-order generation based on which roles are active in the current game. This greatly simplified the night-time announcements.

Player Tracking: The app maintains the state of all players (alive/dead) and keeps a running count of how many werewolves remain in the game, making it easier to determine when the game should end.

Custom Notes: Moderators can add notes to individual players to track important game events or information.

Challenges and Future Improvements

After having a friend use the app during a real game session, several areas for improvement became apparent:

Deck Builder: Creating a balanced deck for a given player count is time-consuming, especially when players arrive or leave at the last minute. An automated deck-building feature would significantly streamline game setup.

Night Cycle Resolver: While the app displays the night order, it’s still easy to forget steps or skip players during the night phase. A guided “run night cycle” feature with step-by-step instructions would make moderating much more foolproof.

Role Expansion: The initial version only includes basic roles. Adding more interesting and complex roles would make the app useful for more advanced game variants.

Update 2023

Looking back at this project, I realized I wrote it in plain JavaScript before I had fully embraced TypeScript. The lack of type safety occasionally led to bugs that could have been caught at compile time. I’m considering rewriting the app in TypeScript to make it more maintainable and robust for future enhancements.