Something went wrong. Try again.
This repository has no description
Something went wrong. Try again.
4 folders · 8 files
README.md
One Night Ultimate Werewolf #
A web-based implementation of One Night Ultimate Werewolf using boardgame.io, React, and TypeScript.
Features #
- Full Game Implementation: Complete implementation of classic One Night Ultimate Werewolf
- Multiplayer Support: Real-time multiplayer with boardgame.io
- Role System: Modular role definitions including Werewolf, Seer, Robber, Troublemaker, and Villager
- Night Phase: Automated night resolution with role-specific actions
- Secure: Server-authoritative game logic with proper secret hiding
- Modern UI: React-based interface with responsive design
Installation #
- Clone the repository
- Install dependencies:
npm install
Development #
Start Development Server #
Run both the game server and client in development mode:
npm run dev
This will start:
- Game server on
http://localhost:8000 - Client on
http://localhost:3000
Individual Services #
Start just the server:
npm run dev:server
Start just the client:
npm run dev:client
Building #
Build for production:
npm run build
This creates:
- Compiled server code in
dist/server/ - Client bundle in
dist/client/
Production #
Start the production server:
npm start
Make sure to serve the client files (in dist/client/) from a web server.
Game Rules #
Setup #
- 3-10 players can join a game
- Each player receives a secret role card
- 3 additional role cards are placed in the center
Night Phase #
- Werewolves - Look for other werewolves. If alone, look at a center card
- Seer - Look at another player's card OR two center cards
- Robber - Swap your card with another player and look at your new role
- Troublemaker - Swap two other players' cards (without looking)
Day Phase #
- Open discussion phase where players share information (or bluff!)
- Players try to figure out who the werewolves are
Voting Phase #
- All players vote simultaneously for who they think is a werewolf
- Players with the most votes are eliminated
Victory Conditions #
- Village Team: Wins if at least one werewolf is eliminated
- Werewolf Team: Wins if no werewolves are eliminated
Architecture #
Server (boardgame.io) #
- Game Logic: Core game rules and state management
- Role System: Modular role definitions in
src/server/roles/ - Night Engine: Automated sequencing of night actions
- Security: Server-authoritative with proper secret management
Client (React) #
- Phase Components: Separate UI for each game phase
- Responsive Design: Works on desktop and mobile
- Real-time Updates: Automatic synchronization with game state
File Structure #
src/
├── server/
│ ├── game-simple.ts # Main game definition
│ ├── server.ts # Server setup
│ ├── types.ts # TypeScript type definitions
│ ├── roles/ # Role definitions
│ │ ├── index.ts # Role registry
│ │ ├── werewolf.ts
│ │ ├── seer.ts
│ │ ├── robber.ts
│ │ ├── troublemaker.ts
│ │ └── villager.ts
│ └── util/
│ └── nightEngine.ts # Night resolution logic
└── client/
├── index.tsx # React entry point
├── App.tsx # Main app component
└── components/ # React components
├── Board.tsx # Main game board
├── Lobby.tsx # Pre-game lobby
├── NightPhase.tsx # Night phase UI
├── DayPhase.tsx # Day phase UI
├── VotingPhase.tsx # Voting UI
└── RevealPhase.tsx # End game results
Adding New Roles #
- Create a new role file in
src/server/roles/ - Implement the
RoleDefinitioninterface - Add night action logic if needed
- Register in
src/server/roles/index.ts - Update
NIGHT_ORDERintypes.tsif the role acts at night
Example:
import { RoleDefinition } from "../types";
const MyRole: RoleDefinition = {
id: "myrole",
name: "My Role",
description: "Does something interesting",
team: "village", // or "werewolf" or "special"
nightAction: {
// ... action definition
}
};
export default MyRole;
Testing #
Run tests:
npm test
Watch mode:
npm run test:watch
Contributing #
- Fork the repository
- Create a feature branch
- Make your changes
- Add tests for new features
- Submit a pull request
License #
MIT License - see LICENSE file for details