Skip to content

Getting Started with Project Development

This document explains how to set up the project locally for development.

1. Clone the project

Start by cloning the project repository locally.

git clone <project-url>
cd <project-name>

Replace <project-url> with the repository URL, then move into the project directory.

2. Use the available Dev Container

A .devcontainer configuration is available in the project.

If you use an editor or IDE that supports Dev Containers, you can open the project inside the container to get a preconfigured development environment.

Once the Dev Container is running, use the same project commands described below.

3. Create a Python virtual environment

The project must be run inside a Python virtual environment to isolate its dependencies.

python -m venv .venv

Activate the virtual environment.

On Linux or WSL:

source .venv/bin/activate

On Windows - require Docker Desktop:

.venv\Scripts\activate

4. Install the development dependencies

Once the Python environment is activated, install the packages from the dev section of pyproject.toml.

The only supported installation format is:

pip install -e .["<section>"]

For development, run:

pip install -e .["dev"]

5. Create a Discord application

To run the project in development mode, you need a Discord application and a bot token.

Open the Discord Developer Portal and create a new application.

Then configure the bot:

  1. Open your application in the Discord Developer Portal.
  2. Go to the Bot section.
  3. Create a bot user if it does not already exist.
  4. In the Bot section, reset or copy the bot token.
  5. Use this token as the value of discord_token in your development profile.

The bot token is secret. Do not commit it, share it, or paste it in public logs.

6. Generate the Discord bot invite URL

The bot must be invited to your development Discord server.

In the Discord Developer Portal:

  1. Open your application.
  2. Go to OAuth2 → URL Generator.
  3. Select the bot scope.
  4. Under bot permissions, select the Administrator permission.
  5. Copy the generated URL.
  6. Open the URL in your browser.
  7. Select your development server and authorize the bot.

The server ID used for development must match the value configured in your development profile.

7. Set up your development identity

Put the bot token in the .env file at the project root:

DISCORD_TOKEN=yourToken

Then copy dev/profiles/local.example.json to dev/profiles/local.json (ignored by git) and fill in your IDs:

{
  "$schema": "./schema.json",
  "guild_id": 123456789012345678,
  "developer": { "id": 123456789012345678, "role": "WEREWOLF" },
  "players": {
    "234567890123456789": { "alias": "Test1", "role": "VILLAGER" },
    "345678901234567890": { "alias": "Test2" }
  }
}
  • guild_id: your development server, the slash commands are synced on it;
  • developer: your Discord user ID and, optionally, the role you always get;
  • players: test accounts registered in every new lobby, with an optional forced role (drawn at random otherwise).

8. Development profiles

A profile of dev/profiles sets how games run. The committed ones are:

Profile Behavior
default 30 s days and nights, 30 s tick, no weekend pause, no AFK kick, no roles purge
hourly Night from 22:00 to 09:00, then days and nights alternate every hour
prod-like Production hours (day from 10:00 to 16:00), weekend pause and AFK kick

A profile can extend another one and override only some keys:

{
  "$schema": "./schema.json",
  "extends": "default",
  "description": "Long nights to test the night roles",
  "time": { "clock": { "type": "cycle", "day_seconds": 30, "night_seconds": 120 } }
}

The profile used is local.json, then the extends chain, then the profile itself, merged key by key (time.clock is replaced as a whole). The result is validated against dev/profiles/schema.json, which documents every key:

  • time.timezone, time.tick_seconds, time.weekend_pause;
  • time.clock: office (day_start, day_end) or cycle (day_seconds, night_seconds, optional anchor and night_window);
  • game.kick_afk_players, game.purge_roles.

Name your own profiles *.local.json to keep them out of git.

9. Configuration validation behavior

An invalid profile, a missing local.json or an extends loop stops the launcher with a message telling what to fix.

10. Run development mode

python -m dev                     # default profile, or $DEV_PROFILE
python -m dev --profile hourly
python -m dev --list              # profiles and their description

11. Run the documentation locally

To access the project documentation locally, install the docs section from pyproject.toml.

Make sure the Python virtual environment is activated, then run:

pip install -e .["docs"]

Start the documentation server with:

zensical serve

The command prints a local URL. Open the proposed link in your browser to access the documentation.

By default, the documentation is often available at:

http://localhost:8000

Branching and Release Workflow

The project uses werewolf-release as the release branch and main as the staging branch. The main branch is used for staging because the free version of SonarQube only analyzes the main branch.

For each new milestone or release, such as Alpha-0.4.0, a dedicated branch with the same name is created. Contributors should open their PRs/MRs against the relevant milestone branch rather than directly against main or werewolf-release.

Once the milestone is complete and the related changes have been reviewed, the milestone branch is merged into main for staging and SonarQube analysis. Any follow-up fixes, improvements, or adjustments identified during this phase are handled through incremental version revisions, such as 0.4.1, 0.4.2, and so on.

When the staging branch is considered stable, the validated changes can then be promoted to the release branch.

Branch Roles

The project uses a milestone-based branching workflow. Each branch has a specific role:

Branch Role
main Staging and integration branch. This is the branch analyzed by SonarQube.
werewolf-release Stable release branch. Only validated release-ready code should be merged here.
Alpha-0.4.0, Alpha-0.5.0, etc. Milestone branches used to prepare upcoming releases.
feature/*, fix/* Contributor branches used for individual changes.

Contributors should open PRs/MRs against the active milestone branch, not directly against main or werewolf-release.

Typical flow:

feature/my-change
        ↓
Alpha-0.4.0
        ↓
main
        ↓
werewolf-release

The main branch is used as the staging branch because the free version of SonarQube only analyzes the main branch. Once a milestone branch is complete, it is merged into main so the full CI and SonarQube analysis can run. After validation, the changes can be promoted to werewolf-release.