Skip to content

osrlib.data

Generated SRD data and its typed loaders.

The JSON files in this package are generated by tools/srd_compile/ from the SRD markdown in srd/ and are never hand-edited — CI regenerates them and fails on any diff. Regenerate with uv run python -m tools.srd_compile. Each file carries a _meta block naming its source SRD pages; entries corrected by compiler overrides record the touched field paths in overrides_applied.

Loaders read package resources, validate into frozen models, and cache: everything a loader returns is immutable shared data — play spawns mutable instances from these templates. Generated data that fails validation is malformed content and raises ContentValidationError.

The compiled data is Open Game Content under the Open Game License 1.0a; the license text and Section 15 notice ship in this package as LICENSE-OGL.md.

Language

Bases: BaseModel

A language a character can speak.

choosable marks the SRD's twenty Other Languages, available to characters with high INT; Common is not choosable (every class already speaks it natively). Alignment tongues are not data entries — they derive from the alignment enum.

id instance-attribute

id: str

name instance-attribute

name: str

choosable instance-attribute

choosable: bool

LanguageCatalog

Bases: BaseModel

The loaded language list: Common plus the twenty Other Languages.

languages instance-attribute

languages: tuple[Language, ...]

get

get(language_id: str) -> Language

Return the language with language_id.

Parameters:

Name Type Description Default
language_id str

The language id, e.g. "gnoll".

required

Returns:

Type Description
Language

The language.

Raises:

Type Description
ValueError

If no language has that id.

load_ability_tables cached

load_ability_tables() -> AbilityTables

Load the six ability modifier tables and the prime requisite XP table.

Returns:

Type Description
AbilityTables

The frozen tables.

Raises:

Type Description
ContentValidationError

If the generated data is missing or fails validation.

load_classes cached

load_classes() -> ClassCatalog

Load the seven Classic class definitions.

Returns:

Type Description
ClassCatalog

The frozen class catalog — see the class id index for the

ClassCatalog

class ids it defines.

Raises:

Type Description
ContentValidationError

If the generated data is missing or fails validation.

load_combat_tables cached

load_combat_tables() -> CombatTables

Load the attack matrix, monster saving-throw bands, and XP-awards table.

Returns:

Type Description
CombatTables

The frozen combat tables.

Raises:

Type Description
ContentValidationError

If the generated data is missing or fails validation.

load_encounter_tables cached

load_encounter_tables() -> EncounterTables

Load the dungeon encounter tables by level.

Returns:

Type Description
EncounterTables

The frozen encounter tables.

Raises:

Type Description
ContentValidationError

If the generated data is missing or fails validation.

load_equipment cached

load_equipment() -> EquipmentCatalog

Load the weapon, armour, gear, ammunition, and treasure-weight lists.

Returns:

Type Description
EquipmentCatalog

The frozen equipment catalog — see the equipment id index

EquipmentCatalog

for the item ids it defines.

Raises:

Type Description
ContentValidationError

If the generated data is missing or fails validation.

load_languages cached

load_languages() -> LanguageCatalog

Load the language list: Common plus the twenty Other Languages.

Returns:

Type Description
LanguageCatalog

The frozen language catalog — see the language id index

LanguageCatalog

for the language ids it defines.

Raises:

Type Description
ContentValidationError

If the generated data is missing or fails validation.

load_magic_items cached

load_magic_items() -> MagicItemCatalog

Load the magic item catalog: templates, sub-tables, and the sword tables.

Returns:

Type Description
MagicItemCatalog

The frozen magic item catalog — see the magic item id index

MagicItemCatalog

for the item ids it defines.

Raises:

Type Description
ContentValidationError

If the generated data is missing or fails validation.

load_monsters cached

load_monsters() -> MonsterCatalog

Load the monster templates compiled from the SRD's monster pages.

Returns:

Type Description
MonsterCatalog

The frozen monster catalog — see the monster id index for

MonsterCatalog

the template ids it defines.

Raises:

Type Description
ContentValidationError

If the generated data is missing or fails validation.

load_spells cached

load_spells() -> SpellCatalog

Load the spell templates compiled from the SRD's spell pages.

Returns:

Type Description
SpellCatalog

The frozen spell catalog — see the spell id index for the

SpellCatalog

spell ids it defines.

Raises:

Type Description
ContentValidationError

If the generated data is missing or fails validation.

load_treasure_tables cached

load_treasure_tables() -> TreasureTables

Load the treasure types, gem values, magic item type, stocking, and unguarded tables.

Returns:

Type Description
TreasureTables

The frozen treasure tables — see the treasure type index

TreasureTables

for the treasure type letters they key on.

Raises:

Type Description
ContentValidationError

If the generated data is missing or fails validation.