Skip to content

gwillish/DHModels

DHModels

This is a Swift Package built to support creating tools for the TTRPG Daggerheart. There's a great community growing that is assembling standard ways to share details on players, adversaries, environments, and more in a JSON format.

This package provides type-safe models for the Swift programming language, and some validation and extensions on those models, including a JSONSchema declaration, to hopefully promote more cross app, language, and platform tool sharing.

The JSON field names and schema conventions used by this package are derived from the community ecosystem:

Project Author Contribution
seansbox/daggerheart-srd Sean Box SRD content in JSON/CSV/Markdown; primary source for adversaries.json and environments.json field names
ly0va/beastvault ly0va Obsidian plugin; defined the adversary YAML/JSON import schema used by the community
javalent/fantasy-statblocks Jeremy Valentine Obsidian statblock layout that established community field naming conventions
daggersearch/daggerheart-data daggersearch Player-facing SRD content (classes, ancestries, items) in JSON

Many thanks to these contributors for their work establishing the shared data formats that make cross-tool compatibility possible.

Documentation for DHModels is hosted on the Swift Package Index.


What's inside

DHModels

Pure value types (structs and enums) that model Daggerheart catalog and encounter data.

DHKit@Observable stores

@MainActor observable classes for UI integration. Depends on DHModels and swift-log.

validate-dhpack — CLI tool

Command-line tool that validates one or more .dhpack files against the DHPackContent decoder and reports pass/fail:

swift run validate-dhpack my-pack.dhpack

Content packs

Community and homebrew content is distributed as .dhpack files — plain JSON containing adversaries, environments, or both.

The JSON Schema for .dhpack is at schemas/dhpack.schema.json. Add "$schema" to your pack file to enable validation and autocomplete in VS Code:

{
  "$schema": "https://cdn.jsdelivr.net/gh/gwillish/DHModels@main/schemas/dhpack.schema.json",
  "adversaries": [ ... ]
}

Use validate-dhpack to check a pack file against the decoder:

swift run validate-dhpack my-pack.dhpack

A complete field reference is in docs/dhpack-format.md.


Adding to your project

// Package.swift
.package(url: "https://github.com/gwillish/DHModels.git", from: "0.2.0"),

// Apple-platform app target
.product(name: "DHKit", package: "DHModels"),

// Linux / server target (models only)
.product(name: "DHModels", package: "DHModels"),

Building and testing

# Build both library targets
swift build

# Run all tests
swift test

# Model tests only
swift test --filter DHModelsTests

See CLAUDE.md for the full development guide.


License & Attribution

The DHModels package source code is licensed under the MIT License.

This package bundles adversary and environment data from the Daggerheart System Reference Document 1.0, used under the Darrington Press Community Gaming License (DPCGL):

This product includes materials from the Daggerheart System Reference Document 1.0, © Critical Role, LLC. under the terms of the Darrington Press Community Gaming (DPCGL) License. More information can be found at https://www.daggerheart.com. There are no previous modifications by others.

Full DPCGL license text: https://darringtonpress.com/license/

This project is not affiliated with, endorsed by, or sponsored by Darrington Press, LLC or Critical Role, LLC. Daggerheart is a trademark of Critical Role, LLC.

About

models and core Swift libraries to support type safe models for common JSON data files used to represent models for the Daggerheart TTRPG

Topics

Resources

License

Code of conduct

Contributing

Stars

Watchers

Forks

Contributors