Skip to content

nothingness-dev/parasite

Repository files navigation

Parasite

Trust no one. Survive.

Parasite is a lightweight browser-based social deduction game built with Node.js, Express, Socket.IO, and vanilla HTML/CSS/JavaScript. Players create or join a room, receive hidden roles, move between station rooms, complete tasks, report bodies, call meetings, vote, and survive sabotage.

Features

  • Real-time multiplayer rooms with Socket.IO
  • 4-10 players per room
  • Human and parasite roles
  • Private parasite team knowledge
  • Room-based movement with travel delay
  • Tasks, fake tasks, task cooldowns, and task redistribution after human deaths
  • Kill cooldowns and body reporting
  • Meetings, voting, ties, skips, and ejection results
  • Sabotages: lights, reactor, doors, and communications
  • Ghost chat for dead players
  • In-memory room lifecycle cleanup
  • Server-side validation for room IDs, player names, socket ownership, vote targets, and action phases

Screenshots

Lobby Gameplay Sabotage Result

Gameplay

Roles

Humans

  • Complete all real tasks.
  • Report bodies.
  • Call emergency meetings.
  • Vote out parasites.
  • Fix sabotages.

Humans win when all tasks are completed or all parasites are eliminated.

Parasites

  • Eliminate humans.
  • Trigger sabotages.
  • Blend in using fake tasks.
  • Vote strategically during meetings.

Parasites win when living parasites are greater than or equal to living humans, or when reactor meltdown is not fixed in time.

Rooms

Room Purpose Sabotage Fix
Lab Research and analysis Lights
Reactor Power core Reactor
Security Surveillance Doors
Storage Supplies and cargo None
MedBay Medical treatment None
Communications Station communications Comms

Core Loop

Move -> Tasks -> Sabotage -> Kill
  |
Report -> Meeting -> Vote -> Results -> Repeat

Rules

  • Dead players cannot move, vote, report, kill, fix sabotages, or use normal chat.
  • Dead players can use Ghost Chat.
  • Humans can report unreported bodies in their current room.
  • Players can only vote during the voting phase.
  • Players cannot vote for themselves.
  • Vote targets must be alive players, or skip.
  • Sabotages can only be triggered by living parasites during gameplay.
  • Only one sabotage can be active at a time.
  • Actions that finish after a phase change are interrupted instead of mutating state.
  • Player names must be 2-20 characters and may contain letters, numbers, spaces, underscores, and hyphens.

Player Scaling

Players Parasites
4-6 1
7-8 2
9-10 3

Quick Start

Requirements

  • Node.js 18+ recommended
  • npm

Install

npm install

Run

npm start

Then open:

http://localhost:3000

The server binds to 0.0.0.0 and uses PORT when provided:

PORT=8080 npm start

On Windows PowerShell:

$env:PORT = "8080"
npm start

Configuration

Core game constants live in server/utils/Constants.js.

Important values:

MIN_PLAYERS: 4,
MAX_PLAYERS: 10,
MEETING_DURATION: 30000,
VOTING_DURATION: 20000,
RESULTS_DURATION: 8000,
TASK_COOLDOWN: 3000,
KILL_COOLDOWN: 45000,
SABOTAGE_COOLDOWN: 45000,
REACTOR_TIMER: 45000,
TASKS_PER_PLAYER: 3

Project Structure

parasite/
|-- server.js
|-- package.json
|-- public/
|   |-- index.html
|   |-- css/
|   |   `-- style.css
|   `-- js/
|       `-- client.js
`-- server/
    |-- core/
    |   |-- EventValidator.js
    |   |-- GameState.js
    |   `-- PhaseManager.js
    |-- rooms/
    |   `-- RoomManager.js
    |-- state/
    |   `-- PlayerManager.js
    |-- systems/
    |   |-- SabotageSystem.js
    |   |-- TaskSystem.js
    |   `-- VotingSystem.js
    `-- utils/
        `-- Constants.js

Architecture

Browser client
  | Socket.IO
Node.js server
  |-- RoomManager: room lifecycle and host tracking
  |-- PlayerManager: socket-to-player and player state
  |-- GameState: per-room gameplay state
  |-- PhaseManager: legal phase transitions
  |-- EventValidator: input validation
  |-- TaskSystem: role assignment, tasks, redistribution
  |-- SabotageSystem: sabotage effects and cleanup
  `-- VotingSystem: vote casting and tallying

Security And Reliability Notes

  • Game state is stored in memory. Restarting the server clears all rooms.
  • This project does not include accounts, persistence, matchmaking, or reconnect recovery yet.
  • Socket actions are checked against the connected socket to prevent basic player impersonation.
  • Dynamic chat and player-rendered content is escaped in the browser.
  • For public deployments, consider adding rate limiting, structured logging, reconnect support, and automated tests before running large public games.

Deployment

Render

Create render.yaml:

services:
  - type: web
    name: parasite
    env: node
    buildCommand: npm install
    startCommand: npm start
    plan: free

Railway

railway login
railway init
railway up

Fly.io

fly launch
fly deploy

VPS

npm install
npm start

For a long-running production process, use a process manager such as PM2:

npm install -g pm2
pm2 start server.js --name parasite
pm2 save

Development

There is currently no automated test suite. Useful checks:

node --check server.js
node --check public/js/client.js

For all project JavaScript files on PowerShell:

rg --files -g "*.js" -g "!node_modules/**" | ForEach-Object { node --check $_ }

Tech Stack

Layer Technology
Backend Node.js, Express
Real-time Socket.IO
Frontend Vanilla HTML, CSS, JavaScript
Persistence In memory
Build tools None

Future Ideas

  • Real task minigames instead of timed task placeholders
  • Room settings UI for task count, cooldowns, durations, and parasite count
  • Reconnect support
  • Host migration messaging
  • Public/private room options
  • More roles, maps, and sabotage types
  • Automated tests for state transitions, voting, tasks, sabotage, and disconnects

License

MIT. See LICENSE.

About

Parasite - A lightweight social deduction multiplayer web game. Trust no one. Survive. Built with Node.js, Express, and Socket.IO.

Topics

Resources

License

Stars

2 stars

Watchers

0 watching

Forks

Packages

 
 
 

Contributors