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:
- Success — roll ≤ target.
- Special Success — roll ≤ one fifth of the target (minimum 1). Attacks roll their damage dice twice when Automate Special Success Damage is enabled.
- Failure — roll > target.
- Fumble — roll of 96–100 when the target is below 50, or a natural 100 otherwise. The GM adjudicates a mishap: dropped or damaged weapon, hit an ally, drained power pack.
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.
- Add combatants to the Combat Tracker as normal. The Ringworld impulse panel replaces the core tracker list.
- 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.
- 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:
- 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.
- 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.
- 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.
- Hit location is rolled on a d20 (or picked manually). Species use their own body schema — puppeteers, dolphins, trinocs, bandersnatchi and kzinti map differently.
- 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:
- Head or Chest at 0 — unconscious and prone.
- Abdomen at 0 — prone, both legs unusable.
- Arm at 0 — that arm is unusable.
- Leg at 0 — that leg is unusable, and the character falls prone.
- General HP at 0 — dying.
- Head, chest or abdomen at negative full value — dying; a head at negative full value is death outright.
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:
- General HP = CON + MAS. MAS (mass) replaces the familiar SIZ. Location HP scale from general HP by body schema.
- Damage modifier comes from STR + MAS and is recomputed automatically when characteristics change.
- Skill pools: Education points = (EDU − 10) × 20, Pursuit points = (Age − EDU − 6) × 20, Special points = INT × 10. The character builder on the Skills tab tracks all three.
- Skill category caps: each category is capped by a characteristic pair (e.g. Agility by STR + DEX). The builder enforces the caps.
- Gravity matters: carried weight is halved in light gravity and doubled in heavy gravity before comparing to the STR limit; over-limit explorers slow to Move 2 and suffer an Action Ranking penalty.
- Energy economy: most Ringworld tech runs on power packs (R20/R50/R100). Weapons can draw from a linked pack — keep spares, and remember fumbles can drain them.
`
},
{
name: "GM Quick Start",
content: `
To get a table playing quickly:
- 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.
- Create Random Explorer (Actors sidebar button) — rolls characteristics by species and gravity, adds base skills and a starter kit.
- 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.
- Creatures get the same automation — hit locations, dodge, armor stacking — via the creature sheet, with a body schema selector for non-humanoids.
- 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;
}