# ACG — Aglarond 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 a pack from your own ACG

```bash
npm run pack:extract -- "/path/to/acg.mdb" docs/reference/acg-mdb-raw.json
npm run pack            # build, then validate
```

The extractor reads Jet/Access databases directly in Python — no Access, no
Windows, no ODBC. `npm run pack:validate` puts the result through fourteen
structural checks before you trust it.

`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.

---

## 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
packages/import   readers for the 1999 and 2003 file formats
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.
