# BoL — FoundryVTT Game System

FoundryVTT game system for Barbarians of Lemuria (French edition, Ludospherik). System id `bol`. Compatible Foundry v13–v14.

## Commands

| Command | Action |
|---------|--------|
| `npm run css` | Compile LESS → `css/bol.css` (one-shot) |
| `npm run watch` / `npm start` | Watch `styles/**/*.less`, recompile on change |

No test or lint scripts exist.

## Entry Point & Architecture

`module/bol.js` — wires everything in `Hooks.once('init', ...)` and `Hooks.once('ready', ...)`.

| Path | Role |
|------|------|
| `module/bol.js` | System init, sheet/data model registration, socket setup |
| `module/system/config.js` | `BOL` constants, `System.debugMode` flag |
| `module/system/bol-utility.js` | Static helpers, settings (`bol` namespace), socket handler (`system.bol`) |
| `module/controllers/bol-rolls.js` | All roll logic — `BoLRoll` static methods |
| `module/models/` | DataModel classes (`.mjs`) for Actor/Item types |
| `module/applications/sheets/` | **AppV2 sheets** (`ActorSheetV2`/`ItemSheetV2` + `HandlebarsApplicationMixin`) |
| `styles/` | LESS sources → compiled to `css/bol.css` |
| `templates/` | Handlebars `.hbs` partials |
| `lang/` | `fr.json`, `en.json`, `de.json`, `es.json` |

## Key Conventions

- **AppV2 sheets** — base classes are `foundry.applications.sheets.ActorSheetV2` / `ItemSheetV2` mixed with `HandlebarsApplicationMixin`. Do NOT use `foundry.appv1.sheets.*`.
- **`game.bol`** — system exposes `BoLActor`, `BoLItem`, `BoLRoll`, `BoLUtility`, `Macros`, `BOL` config, `models`, `sheets` on this namespace after init.
- **i18n prefix** — all keys start with `BOL.`; use `game.i18n.localize("BOL.xxx")`.
- **FR-first** — `fr.json` is most complete. EN compendium translation requires [Babele](https://gitlab.com/riccisi/foundryvtt-babele) module. A warning fires at startup if EN is selected without Babele.
- **`System.debugMode = true`** in `module/system/config.js:8` — set to `false` before release.
- **LESS only** — never edit `css/bol.css` directly. Edit `.less` files under `styles/`, recompile with `npm run css`.
- **Data models** — `template.json` defines schema via `Actor.types` (character, encounter, horde, vehicle) and `Item.types` (item, feature). All data lives under `.system`.
- **Sheet partials** — registered in `module/system/templates.js`. Add new partials there.
- **Static classes** — `BoLRoll` and `BoLUtility` are purely static; never instantiate.
- **`template.json.SAVED`** in root is the data model reference; the actual `template.json` may need regeneration.
- **`package.json` and lockfile are in `.gitignore`** — npm is dev-only for LESS compilation. Not needed to run the system in Foundry.
- **`{{formInput}}` for HTML fields** — always use `{{formInput fieldDef enriched=x value=y name="system.path" toggled=isEditable}}` for `HTMLField` in AppV2 sheets. Never use raw `<prose-mirror>` elements; they break form submission.
- **Tab switching** — use CSS-only toggle (no `this.render()`) to preserve ProseMirror editor state. See `base-item-sheet.mjs` pattern.

## CI & Release

- CI triggers **only on release publish** (`.gitea/workflows/main.yml`).
- Release zips: `system.json template.json README.md LICENSE assets/ compendiums/ css/ fonts/ images/ lang/ module/ packs/ styles/ templates/ ui/`.
- Version/URL manifest/download are substituted in `system.json` during CI.
- Published to Foundry package registry via `foundryvtt-publish-package-action`.
