import { SYSTEM_ID } from "./constants"; const JOURNAL_NAME = "Ringworld GM Reference"; interface ReferencePage { name: string; content: string; } function buildPages(): ReferencePage[] { return [ { name: "Percentile Outcomes", content: `

Every check is a d100 roll against a target percentage. The system classifies results automatically:

Characteristic checks use Characteristic × Multiplier (usually ×5): click any characteristic button on a sheet to pick the multiplier.

` }, { name: "Combat Sequence (Impulses)", content: `

Ringworld does not use simple initiative. Combat rounds are split into impulses and each combatant acts on a rhythm set by their Action Ranking (AR), which is derived from DEX (lower is faster) and worsened by encumbrance.

  1. Add combatants to the Combat Tracker as normal. The Ringworld impulse panel replaces the core tracker list.
  2. Each combatant schedules an action: a major action (attack, full move, complex task) completes after AR impulses; a minor action (drop prone, shout, draw) completes after 1 impulse.
  3. Advance the clock with Next Completion or +1. When a combatant's action completes, resolve it, then let them schedule the next one.

The floating impulse HUD can be dragged anywhere on screen and mirrors the tracker for quick play.

` }, { name: "Attack Workflow", content: `

Target a token, then press the weapon's Use button on the attacker's sheet. The system walks through the 1984 rules in order:

  1. Aim state (ranged only): unaimed fires at quarter skill, partially aimed at half, fully aimed at full skill. Cover, movement, range and situational modifiers are applied before the aim multiplier.
  2. Ammunition and energy are spent. Projectile weapons with an ammo capacity are blocked when empty — use the Reload button on the weapon row. Energy weapons draw from the actor pool or a linked power pack.
  3. Dodge: on a hit, the defender is offered a Dodge roll (DEX ×5). A successful dodge evades a normal hit; only a special dodge evades a special hit. Disable with the Prompt Defender Dodge setting.
  4. Hit location is rolled on a d20 (or picked manually). Species use their own body schema — puppeteers, dolphins, trinocs, bandersnatchi and kzinti map differently.
  5. Damage is rolled, stacked armor at that location is subtracted, and the result reduces both the location HP and the general HP.
` }, { name: "Wounds & Conditions", content: `

When a hit location reaches 0 HP or less, conditions are applied automatically:

Limbs cannot go below their negative maximum. Use Reset Conditions on a sheet after treatment or recovery. Prone, unconscious and dead sync to token status icons.

` }, { name: "Running the 1984 Rules", content: `

Quirks of the original boxed set that the system encodes for you:

` }, { name: "GM Quick Start", content: `

To get a table playing quickly:

  1. Seed the catalog (Items sidebar button) — species, 55 base skills, pursuits, weapons, armor and gear from the boxed set appear in organised folders. This runs automatically for new worlds.
  2. Create Random Explorer (Actors sidebar button) — rolls characteristics by species and gravity, adds base skills and a starter kit.
  3. For bespoke characters, unlock the sheet tools (padlock, top right of the sheet) and use the Character Builder on the Skills tab: pick pursuits, then allocate the three point pools.
  4. Creatures get the same automation — hit locations, dodge, armor stacking — via the creature sheet, with a body schema selector for non-humanoids.
  5. Check System Settings for the automation toggles (special success damage, defender dodge prompts).
` } ]; } export async function seedGmReference(): Promise { if (!game.user?.isGM) return false; const journals = (game as any).journal; const existing = journals?.find((entry: any) => entry.getFlag?.(SYSTEM_ID, "gmReference") === true) ?? journals?.getName?.(JOURNAL_NAME); if (existing) return false; const pages = buildPages().map((page, index) => ({ name: page.name, type: "text", sort: (index + 1) * 100000, text: { format: 1, content: page.content.trim() } })); await (getDocumentClass("JournalEntry") as any).create({ name: JOURNAL_NAME, pages, flags: { [SYSTEM_ID]: { gmReference: true } }, ownership: { default: 0 } }); return true; }