← All posts

Dragon's Lair: the D&D app that leaves the map on the table

GuideProjects9 min read
dnddenotest

I'm the master of a D&D 5e campaign, played with the 2024 rules, and we play in person. The map sits on the table, we move the miniatures by hand and the dice are real. Since 29 July I've been writing an app for that table, Dragon's Lair. It keeps the character sheets, the rolls, the initiative and the campaign's codex on everyone's phone.

Dragon's Lair is not a virtual tabletop, and the map never goes into the app. The two biggest decisions in the project came from that idea: rebuilding it from scratch in October and removing automatic combat in November.

What the table needs

At the table you hold your phone between one roll and the next, so it has to show a few things and show them right away. Nobody wants to watch a spinner while the party decides whether to open the door.

A player has their own sheet with the numbers already worked out. They can let the app roll, or roll their own d20 and type in just the number that came up, because the app adds the modifiers. When I call for a roll, the request lands on their phone; if their character is concentrating on a spell and takes damage, the phone asks for the saving throw.

I sit at the laptop, with the prepared encounters, the initiative, the monsters' hit points and the codex with its secret blocks. My notes on how I run games say that preparing too much is useless, and the master's screen follows the same idea: it has to let me find things fast.

Everyone sees only their own. Every line of the log has a master's version and a public one, and a player can't work out a monster's stats from the numbers they see. Ask for something you're not supposed to know and the API answers 404, as if it didn't exist.

Diagram of the table: the map with the miniatures in the middle, four players' phones and the master's laptop around it, linked by a dashed line to the server with the rules engine, the API and the log. The map has no link.
The map stays on the table. Phones and laptop talk only to the server, which works out the rules and decides who sees what.

Four audits and an empty repository

By October the first version existed, but I wasn't happy with the quality of the code or with the way I was working on it. On 12 October I put it through four audits: rules data, engine, data corruption and interface.

The clearest case was about coins. The phone sent the server the new value, computed from its own state, which could be stale: if the master and a player touched the same character at almost the same moment, one of the two changes vanished. Handing over half a stack of items with a double tap could duplicate them. And at a table, two phones on the same character at the same moment is the normal case.

The main cause was in the data. I had no format of my own, and every part of the app reinterpreted the rules files in its own way.

That same day I decided to start again from empty, in the same repository, on a new branch. I wrote the requirements with a collaborator who later took on a good part of the interface: there were 49, today there are 50. The old app stopped on 16 October, with its database in a verified backup, and by the 19th the new one was running on the table's environment.

The coins left a rule that holds across the whole codebase: a write says what it expects to find. The client sends changes, or the value it means to replace, never an absolute number taken from a stale screen, and Undo never puts a snapshot back on top of newer changes.

A format of my own for the rules data

At the centre of the rebuild is .lair, a format of my own for the rules data. The packages live in a private repository, separate from the code. The code holds the app, the engine and the format.

Formulas are strings with a small grammar, and the validator parses them before they reach the engine. Every formula has a type:

10 + mod(dex)                                number
1d6 + floor(level(barbarian) / 2)            dice
level(druid) >= 5 and not wearing(heavy)     condition

An unknown name or a wrong type gets the package refused, so during a game a formula can't break because of how it's written. A division has to sit inside floor or ceil: D&D almost always rounds down, but the format wants it spelled out. A misspelled field is an error too, because the validator knows every field and refuses the ones it doesn't.

Then there are two rules I care about. What the format can't express yet is declared as text (mechanics: "text") and the engine leaves it alone, so nobody fills the gap with a guess. And an id never changes: a renamed thing gets an alias, and a character never loses a reference because a name moved. The format grew with the app: on 12 October it was at version 1.3, today it's at 1.49.

The engine is pure code, with no I/O. It takes the data and returns every number on the sheet with its reason; the front end shows what comes from the API and recomputes nothing. The engine computes and a person applies: only the master can force past a rule, and the override stays written in the log.

Five boxes in a row: .lair package, validator, engine, API, phone. A branch from the validator leads to «package refused»; below, an example: AC 15 equals 10 plus Dexterity 3 plus shield 2.
From the package to the phone. An error in a package stops at the validator, and every number arrives with its reason.

From 71 to 2,583 tests in a month

On 12 October, the first day of the rebuild, there were 71 tests. On 11 November there are 2,583, and they all pass on the latest merge.

Line chart of the automated tests from 12 October to 11 November 2026: 71, 785, 1,590, 1,884, 1,959, 2,211, 2,536, 2,583. Two vertical lines mark 19 October, the first day at the table, and 5 November, when combat went back to the master's hands.
Tests defined on the development branch, counted on the last commit of each measured day.

The number matters to me less than the rule behind it: only what passes the checks reaches the table. There are two environments. development runs with an invented demo campaign and it's where we work; release is the table.

The CI on Forgejo checks formatting and types, the boundaries between packages (the engine can't import anything that does I/O), that no file goes over 400 lines, secrets committed by mistake, vulnerable dependencies, the tests and the weight of the first page's JavaScript. On the latest merge it took 286 seconds, and it deploys only if everything is green. I run the end-to-end tests, on a phone and on a desktop, locally before merging.

Only I update release, and I back up the database first. When there's a new migration I try it on a copy of the real database, and the sheets must give the same numbers before and after. During a session a fix can reach the table even mid-game, but only once the CI on development is green.

My collaborator pushes to development whenever needed, without asking me, while release stays mine. That way nobody waits for me, and I always know what's on the table. I also learned that two branches that are green on their own can break once merged, so I merge several pieces of work locally, check the whole and push once.

On 5 November I removed automatic combat

Until that day the app ran combat. Monster attacks landed on characters by themselves, a ten-second reaction window paused the game on everyone's phone, the player's turn was guided step by step, and legendary actions, summons and zones went off on their own. That same day I had written down that the goal was to get closer to Foundry, a complete virtual tabletop. That evening I put the goal on hold.

The reason, again, is the map on the table. The app doesn't know who is hiding behind a pillar or who is inside a fireball's area: to automate an attack I have to tell it things everyone at the table can already see, and meanwhile the game waits. Every automation is also a rule that has to match the book exactly. At one point a rule for delaying your own turn had made it into the app, though it isn't in the 2024 rules and nobody had asked for it. Back in October, listing the tools I like, I had noted about Foundry that I like how complete it is, and that it's too much.

Now I run combat, and the app helps with prepared encounters, initiative, the turn list, monster stat blocks and quick rolls that only I see and that apply nothing. I type hit points on a keypad, for the whole party at once too (full damage, half or none, with a single Undo). If a concentrating character takes damage, the saving throw still lands on their phone. Conditions are labels you take off by hand, while an effect that lasts a set number of rounds or minutes ends by itself, like a timer.

The removed code lives on a branch and an archive tag. Old fights still open: log lines of a kind that no longer exists replay as if they weren't there, with no errors.

On 8 November I took the backup, updated release, and that day we played on the new version.

What comes next

The goal is a well-made D&D 5.5 character sheet, with Fight Club 5e as the yardstick, plus the master's tools. The code is under the AGPL-3.0 licence; the repository is private for now, and opening it is on the list. The campaign's and the players' data stay out of all this, and the demo uses an invented campaign. The technical details are on the project page.

Artysan.

Custom software, automation and integrations. From Rome.

© 2026 Samuel Tagliacozzo · Artysan