Metadata-Version: 2.5
Name: quill-and-dice
Version: 0.1.1
Summary: A single-player fantasy roleplaying game in your terminal, with Claude or Gemini as the Game Master.
Project-URL: Homepage, https://github.com/reveler-hub/Quill-and-Dice
Project-URL: Changelog, https://github.com/reveler-hub/Quill-and-Dice/releases
Author: reveler-hub
License-Expression: MIT
License-File: LICENSE
Requires-Python: >=3.10
Requires-Dist: anthropic~=2.13
Requires-Dist: claude-agent-sdk~=0.2.188
Requires-Dist: platformdirs<5,>=3.6
Requires-Dist: rich~=15.0
Requires-Dist: textual~=8.2
Requires-Dist: tomli>=1.1; python_version < '3.11'
Description-Content-Type: text/markdown

# Quill & Dice

A single-player fantasy roleplaying game in your terminal, made for new players but also welcomes experienced players as well, with Claude or Gemini as the Game Master.

<img width="1905" height="926" alt="quill_and_dice" src="https://github.com/user-attachments/assets/99b883e4-359e-41ed-a2a6-56c19a5d143b" />

## The idea

Tabletop roleplaying games are a lot of fun, but getting started is hard. You need a group, a time that suits
everyone, and someone willing to be the Game Master (the GM: the person who describes the world, plays everyone
you meet and decides what happens). Then there's a thick rulebook, and the worry of slowing everyone down while
you look things up.

Quill & Dice takes all of that away, so you can learn by playing:

- **No group needed.** Play on your own, whenever you like, for as long as you like. Your game saves itself.
- **No pressure.** Nobody is waiting on you. Take your time, try things out, and ask as many questions as you want.
- **No rulebook first.** The game rolls the dice and does the maths. The GM explains a rule in a sentence when it
  first matters, and a tips panel shows a hint that fits what's happening.
- **Just say what you do.** Type it in your own words, like "I sneak up and shoot the goblin", and the GM takes
  it from there.

Pick one of five ready-made heroes (a goliath fighter, a wood elf ranger, a halfling rogue, a gnome wizard or a
dwarf cleric) or build your own one question at a time, give them a name, and the adventure begins.

## How does the GM stay honest?

At a real table you trust the GM not to fudge the dice. Here the GM is an AI, and an AI can get numbers wrong or
be talked into things. So the GM never touches the numbers:

- **The game does every roll and every sum**, on your computer: attacks, damage, HP, spell slots, gold, XP and
  every monster's turn.
- **The GM can only ask the game to do things**, through a small set of actions, such as *ask for a DC 13
  Perception check* or *start a fight with two goblins*. The game carries them out, within limits: no fight far
  beyond what your hero can survive, no mountain of loot in one go.
- **Difficulty is fair.** How hard a task is (its DC) depends on the task, never on your character's bonus, so
  your strengths really feel strong.
- **Rewards are earned in the story.** Asking the GM for 1,000 gold, or telling it you rolled a 20, won't work.

## The rules

The game uses the 2024 fifth edition rules from the free System Reference Document 5.2.1 (the SRD). If you'd like
to read more about the rules themselves, the SRD is available at https://www.dndbeyond.com/srd.

A few things are simpler than at a real table, which experienced players may want to know:

- One hero, plus any companions who join you in the story. The game plays their turns.
- No battle map. Each enemy is either *close* (within reach) or *far* (about 30 feet away).
- Five classes (fighter, ranger, rogue, wizard and cleric), and spells up to 3rd level.

## Stuck?

Forgot what something means? Type `/rules` and the thing, for example `/rules advantage`, `/rules prone` or
`/rules vex`. `/rules` on its own lists every topic, and `/help` (or F1) shows every command.

Still not sure? Ask the GM, like you would at a real table: "GM, help me understand how grappling works." It
explains, then carries on with the story.

## Getting started

### Install

1. Install [uv](https://docs.astral.sh/uv/), a free tool that installs Python programs. It also fetches Python
   itself if your computer doesn't have a recent enough one.
   - Linux and Mac: `curl -LsSf https://astral.sh/uv/install.sh | sh`
   - Windows (PowerShell): `powershell -ExecutionPolicy ByPass -c "irm https://astral.sh/uv/install.ps1 | iex"`
2. Install the game:
   ```bash
   uv tool install quill-and-dice
   ```
3. Start it by typing `quill`. If your terminal can't find `quill`, open a new terminal window, or run
   `uv tool update-shell` once.

**Using git instead.** use the `source` command each time you want to start the game, then type `quill` (Python 3.10 or newer):

```bash
git clone https://github.com/reveler-hub/Quill-and-Dice
cd Quill-and-Dice
python3 -m venv .venv
source .venv/bin/activate        # fish: source .venv/bin/activate.fish   Windows: .venv\Scripts\activate
pip install -r requirements.txt
quill
```

### Choose your GM

The first time you start the game, it asks which GM you want: **Claude** or **Gemini**. You can change it later
with the `backend` setting (see Settings).

**Claude.** There are two ways to connect:

- **Your Claude Code login (no key needed).** Install the `claude` command-line tool and log in with it; the game
  uses that, and turns count against your Claude plan's usage limits. The Claude desktop app on its own isn't
  enough: the game needs the `claude` command.
  - Linux and Mac: `curl -fsSL https://claude.ai/install.sh | bash`
  - Mac with Homebrew: `brew install --cask claude-code`
  - Windows (PowerShell): `irm https://claude.ai/install.ps1 | iex`

  Then open a new terminal window, run `claude` and log in.
- **A Claude API key.** Make one in your Claude API account (https://platform.claude.com), where you pay per use.
  If Claude Code isn't set up, the game asks for the key: paste it in, and the GM connects. On Claude Max, Ultra
  or Team, your plan includes monthly API credit, so you can play with a key at no extra cost (details:
  https://platform.claude.com/docs/en/about-claude/api-credits-for-subscribers).

**Gemini.** Make an API key in Google AI Studio (https://aistudio.google.com) and paste it in when the game asks.
A paid key is recommended. A free key works, but Google's free tier allows only about 20 GM requests a day for
each model (roughly 8 to 10 turns), and Google may use what you send to improve its products; the game tells you
if your key is a free one. The game starts with the best Gemini model your key can use, and moves down to the
next one when a model is busy or its daily limit is used up.

**Your keys** are each kept in their own private file (only your account can read them, and only this game uses
them). Type `/apikey` to add or replace the key for the GM you're using (`/apikey claude` or `/apikey gemini` to
pick), or `/apikey forget` to remove it. The top bar shows a running estimate of what you've spent.

A story keeps the GM it was started with, which remembers it. If that GM stops working (say you log out of Claude
Code), the story moves to another one, and that GM gets a recap so it picks up where you left off. With no GM at
all, the game still runs offline and tells you why and what to do; commands like `/roll` and `/check` still work.
The GM is sandboxed: it only gets the game's own actions, never your files, shell or the web.

### Playing

Anything you type without a `/` is what your hero says or does, and it goes to the GM. Commands start with `/`:

| Command | What it does |
|---|---|
| `/help` | the everyday commands (`/help combat` for the fight shortcuts) |
| `/rules prone` | explains a rule, condition or weapon trick |
| `/check stealth`, `/roll 2d6` | roll a check, or any dice |
| `/attack goblin`, `/cast fire bolt at goblin` | fight |
| `/end` (or F2) | end your turn in a fight |
| `/rest short`, `/rest long` | rest to heal (the GM says if it's safe) |
| `/newgame`, `/load` | start another hero, or switch between saved games |

You can write in any language. The GM tells the story in your computer's language from the first scene, and
switches if you write in another one. The game's own screens and commands stay in English.

Games are saved automatically, including the story so far, so you can stop at any time and pick up where you
left off. Saves are kept in your own folder, not with the GM.

### What it costs

The game keeps the GMs work small, so turns stay cheap. It handles every rule and number itself, so the GM's
messages are short, and it re-reads earlier parts of the conversation from cache at a fraction of the price. It
also sends each fight one round at a time, and folds a long story into a short recap.

### Settings

Settings live in a file, `settings.toml`, which the game makes the first time it starts:

- Linux: `~/.config/quill-and-dice/settings.toml`
- Mac: `~/Library/Application Support/quill-and-dice/settings.toml`
- Windows: `AppData\Local\quill-and-dice\settings.toml`

Type `/settings` in the game to see where it is and what each setting is now.

Every setting is explained in the file and switched off with a `#`. To use one, delete the `#` and change the
value, then restart the game. If something in the file is wrong, the game still starts, and tells you which line.

| Setting | Default | |
|---|---|---|
| `model` | Claude API: `claude-opus-5-5`; Claude Code: your default; Gemini: `gemini-4-hydrogen` | a cheaper model, e.g. `"claude-sonnet-5-5"` or `"gemini-3.8-flash"` |
| `effort` | `"low"` | `"medium"` or `"high"` for more considered storytelling, at a higher price |
| `long_cache` | `false` | `true` keeps Claude's cache for an hour instead of 5 minutes (Claude API key only): cheaper turns after long pauses, but each cache write costs 2x instead of 1.25x |
| `language` | your computer's language | the language the GM tells the story in, e.g. `"Spanish"` |
| `backend` | `"gemini"` if you picked Gemini; otherwise a Claude API key if there is one, then Claude Code | `"gemini"`, or for Claude `"cli"` (Claude Code) or `"api"` (a key) |
| `saves` | your own saves folder (see Playing) | any folder |
| `update_check` | `true` | `false` stops the check for new versions |
| `dev` | `false` | `true` turns on `/gm`, a developer command for calling the GM's actions by hand |

Your API key isn't in the settings file, so you can share or show the `Settings` file safely. It's kept in its own
file next to it (see Choose your GM), and `/settings` only ever shows its last four characters.

### Updates

When the game starts, and every hour while it's open, it asks GitHub whether a newer version is out. If one is,
a popup gives you three choices:

- **View changelog** opens the list of what's new in your browser.
- **Update now** closes the game (it's saved), installs the new version and starts it again.
- **Not now** stays quiet until an even newer version comes out.

The check sends nothing about you or your game, and neither the popup nor your answer ever appears in your story
or reaches the GM. To update by hand, run `uv tool upgrade quill-and-dice` (or, for a git copy, `git pull` and
then `pip install -r requirements.txt`). On Windows, close the game first: Windows won't let a program be
replaced while it's running, so the popup tells you the command instead of offering Update now.

## Licence

The code is under the MIT License (see `LICENSE`). The game rules it uses come from the SRD 5.2.1 and stay under
Creative Commons Attribution 4.0:

This work includes material from the System Reference Document 5.2.1 ("SRD 5.2.1") by Wizards of
the Coast LLC, available at https://www.dndbeyond.com/srd. The SRD 5.2.1 is licensed under the
Creative Commons Attribution 4.0 International License, available at
https://creativecommons.org/licenses/by/4.0/legalcode.
