# ACG — Advanced Character Generator

A Rolemaster character generator, rebuilt for the browser.

The original was written in Delphi in 1998 and is still in use. This is a
rebuild of it, so that it can be modified again — same rules, same numbers, a
modern interface, and no installer.

Everything runs locally. There is no server, no account and nothing to sign up
for: characters live in files on your own machine, and the browser keeps the
one you were last working on so a reload does not lose it.

---

## It ships with no game content

**There is no game data in this repository.** No rules pack, no attack or
critical tables, no characters. Rolemaster is copyright Iron Crown
Enterprises; the tables are theirs and are not mine to distribute, and the
characters are people's own.

What is here is the program, and the tools to build a pack from a copy of ACG
you already own.

A **rules pack** is a JSON file holding the categories, skills, professions,
races, development costs and spell lists a character is built from. The
application reads one you supply and contains none itself — the build is
checked for that.

`packs/example.json` is the exception, and it is invented from end to end: a
small made-up system called Chalk & Cheese, written to show what the format
looks like. It is not playable and it is not Rolemaster.

### Building the Rolemaster Unified pack

```bash
npm run pack:stats && npm run pack:races && npm run pack:skills   # and so on
npm run pack:rmu                                                  # assemble
```

Each `pack:*` script reads one part of Core Law out of a PDF you own and writes
it to `packs/`; `pack:rmu` assembles those into the pack the application loads.
Nothing else feeds it — every number in it is read from the book, and the
builder refuses to finish if a constant names a skill that does not exist.

`tools/` also holds extractors for the Arms Law attack and critical strike
tables, which read a PDF you own and check their own work: every table is
verified against the printed page's column layout, and the critical extractor
refuses a page whose columns it cannot place.

Culture comes out of Table 2-3, whose ten columns are printed sideways:

```bash
python3 tools/extract-cultures.py "Core Law.pdf"
```

The two worked characters in Core Law can be built into files ACG opens, which
is the strongest test the book affords -- a whole character, recalculated, and
every figure compared against the printed sheet:

```bash
python3 tools/extract-sample-characters.py "Core Law.pdf"   # what it prints
python3 tools/build-sample-characters.py                    # what a player types
```

The output lands in `fixtures/`, which is not committed. Without it those tests
are skipped; with it they run. What they disagree with the book about is
written down in `docs/book-errata.md`.

---

## Running it

```bash
npm install
npm run dev      # http://localhost:5173
npm test
npm run build
```

`npm test` is green on a fresh clone. Most of the suite is a golden master
against a real 1999 character and a real pack, so those tests skip themselves
when the data is not present, and run when it is. Nothing is quietly ignored:
the run says which files it skipped and what each of them wanted.

---

## What it does

- **The whole character**: stats, skills and categories, points, defensive
  bonuses, resistances, items, traits and notes — the same screens the original
  had, with the arithmetic ported from the Delphi source rather than guessed.
- **Training**, with the stat gain roll it always opened with.
- **Training packages**, applied from the pack, previewing what will and will
  not land before it touches the sheet.
- **A printed character sheet**, on A4 or Letter from one layout.
- **A battle simulator** that fights the same fight a few hundred times and
  reports whether trading offensive bonus for defensive actually wins more
  often. With the real Arms Law tables loaded it resolves a blow the way the
  book does; without them it says plainly that it is estimating.
- **GM tools** for looking inside a rules pack and correcting it, which the
  original could only do through Microsoft Access.

Both file generations are read: the five-file `.acg` family from 3.x and ACG
4's single XML document.

---

## Layout

```
packages/rules    the engine — pure TypeScript, no dependencies
apps/web          the application
tools/            extractors and pack builders
docs/             notes on the data model
PLAN.md           what was rebuilt, in what order, and what is left
```

The engine has no dependencies and knows nothing about the browser. Delphi
semantics are reproduced where they are load-bearing — `Trunc` toward zero,
integer `div`, `CompareText`'s case-insensitivity, `StrToInt`'s all-or-nothing
parse — because a character sheet that disagrees with the one printed in 1999
is a bug, however reasonable the new answer looks.

---

## Licence

The code is MIT; see `LICENSE`.

Rolemaster, Arms Law, Spell Law and Character Law are copyright Iron Crown
Enterprises. This project is not affiliated with or endorsed by them, contains
none of their content, and is of no use without a copy of the rules you have
bought.
