Files
mgt2-compendium-amiral-denisov/.github/copilot-instructions.md

4.1 KiB
Raw Blame History

Copilot Instructions

What this repository is

A FoundryVTT content module for the MGT2 (Mongoose Traveller 2nd edition) system. It is a pure data module — there is no JavaScript, CSS, or HTML. All content is in French.

Compatible with FoundryVTT v11v13, requiring the mgt2 game system.

Architecture

module.json       ← FoundryVTT module manifest (single source of truth for module metadata)
packs/            ← Compendium packs stored as LevelDB databases (binary .ldb files)
assets/icons/     ← SVG icons, named in French (with accented characters)

Packs

Each subdirectory under packs/ is a LevelDB database managed by FoundryVTT. Never edit .ldb files directly — pack content is modified through the FoundryVTT UI and exported via its built-in compendium tools.

Current packs and their document types:

Pack folder Label Type
armures Armures Item
armes Armes Item
competences Compétences Item
carrieres Carrières Item
talents-psioniques Talents psioniques Item
maladie-poison-and-blessure Maladie, Poison & Blessure Item
equipement Équipement Item
ordinateur Ordinateur Item
contenant-sac-coffre Contenant (sac, coffre) Item
espece Espèce Item
objet Objets Item
journal Journal Psioniques JournalEntry

The folders arme, carriere, and talent-psy appear to be legacy/deprecated predecessors of armes, carrieres, and talents-psioniques.

JavaScript module architecture

The module now includes a /commerce chat command that opens a trade workflow dialog. Entry point: scripts/commerce.js (ES module, declared under "esmodules" in module.json).

scripts/
  commerce.js          ← entry point; registers /commerce via Hooks.on("chatMessage")
  CommerceDialog.js    ← FormApplication with 3 tabs (passengers / cargo / speculative trade)
  tradeHelper.js       ← business logic: dice rolls (Foundry Roll API), price calculations
  uwpParser.js         ← parses UWP strings (e.g. A788899-C) → trade codes (Ag, In, Ri…)
  data/
    tradeTables.js     ← all data tables: goods (D66), passenger/cargo traffic, prices
templates/
  commerce-dialog.hbs  ← Handlebars template for the dialog (3-tab form)
  commerce-result.hbs  ← Handlebars template for the chat result card
styles/
  commerce.css         ← dialog and chat card styles

Key patterns

  • Dice rolls use await new Roll(formula).evaluate() — always async.
  • UWP parsing via parseUWP(uwp, zone) in uwpParser.js; trade codes are derived automatically.
  • Trade code modifiers: only the highest applicable modifier from each column (buy/sell) is used per the rules (not cumulative).
  • Goods table (D66): all 30 entries (D66 1166) are implemented in tradeTables.js, including illegal goods (D66 6165) and the free-form Exotics entry (D66 66). Illegal goods have illegal: true and are only surfaced when blackMarket: true is passed to findAvailableGoods().
  • Template helpers (formatCredits, join, gt, gte, eq) are registered lazily in CommerceDialog.js on first use.
  • FormApplication tabs use the built-in Foundry tab system (navSelector, contentSelector, initial).

Key conventions

module.json

Every pack must be declared in module.json under "packs". The standard ownership for all packs is:

"ownership": {
  "PLAYER": "OBSERVER",
  "ASSISTANT": "OWNER"
}

All packs use "system": "mgt2".

When adding a new pack, add its entry to module.json and create the corresponding directory under packs/ (FoundryVTT will initialise the LevelDB files on first use).

Icons

  • Stored in assets/icons/ as SVG files
  • File names are in French and may contain accented characters (e.g., mécanique.svg, éclaireur.svg)
  • Referenced in item data as relative module paths, e.g.:
    modules/mgt2-compendium-amiral-denisov/assets/icons/<name>.svg

Version bumps

Version is defined once in module.json under "version". There is no separate changelog file.