Skip to content

feat: add turn, a dungeon-turn tracker - #2

Merged
ptaranat merged 1 commit into
mainfrom
ptaranat/db-106-dw-turn-dungeon-turn-tracker
Aug 28, 2026
Merged

feat: add turn, a dungeon-turn tracker#2
ptaranat merged 1 commit into
mainfrom
ptaranat/db-106-dw-turn-dungeon-turn-tracker

Conversation

@ptaranat

Copy link
Copy Markdown
Member

Adds dw turn, the dungeon clock: advance turns (10 min each), track named light sources and spells by duration (6, 30m, 1h), warn on expiry and upcoming expiry, and remind on the wandering-check cadence (configurable, default every 2 turns). State survives between invocations in dw-session.json at the repo root (already gitignored), overridable via DW_SESSION; a corrupt state file starts fresh with a note. No named light sources or book content hardcoded: the user names the thing and gives its duration. DB-106.

@macro-application

Copy link
Copy Markdown

@ptaranat
ptaranat requested a lite review from Copilot August 28, 2026 13:39
@cloudflare-workers-and-pages

cloudflare-workers-and-pages Bot commented Aug 28, 2026

Copy link
Copy Markdown

Deploying dlmnwd with  Cloudflare Pages  Cloudflare Pages

Latest commit: 300bd2a
Status: ✅  Deploy successful!
Preview URL: https://fbc052df.dlmnwd.pages.dev
Branch Preview URL: https://ptaranat-db-106-dw-turn-dung.dlmnwd.pages.dev

View logs

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds a new dw turn command to track dungeon turns (10 minutes each), persist session state between invocations, and provide reminders for expiring tracked items and wandering-check cadence.

Changes:

  • Introduces core turn/session state logic (parseTurns, advance, persistence helpers) and associated tests.
  • Adds the turn CLI command with subcommands (track, status, check-every, end) and integrates it into the main CLI help/dispatch.
  • Updates documentation and shell completion to expose the new command.

Reviewed changes

Copilot reviewed 6 out of 6 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
test/turn.test.ts Adds unit tests for parsing, advancement rules, wandering-check cadence, and persistence/corruption handling.
src/turn.ts Implements turn-state model, duration parsing/formatting, advancement logic, and JSON file persistence.
src/commands/turn.ts Adds the dw turn CLI subcommand implementation and user-facing output.
src/cli.ts Registers turn in command dispatch and documents it in dw help.
README.md Documents dw turn usage and updates the “Working” command list/roadmap.
completions/_dw Adds zsh completion entries for the new turn command and its subcommands.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread src/turn.ts
Comment thread src/turn.ts
@ptaranat
ptaranat force-pushed the ptaranat/db-106-dw-turn-dungeon-turn-tracker branch from a75cef2 to 99cc0f0 Compare August 28, 2026 13:45
@ptaranat
ptaranat requested a lite review from Copilot August 28, 2026 13:45

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 6 out of 6 changed files in this pull request and generated 2 comments.

Suppressed comments (1)

src/commands/turn.ts:90

  • cmdAdvance uses parseInt, so inputs like dw turn 1h or dw turn 3x will be accepted and silently interpreted as 1/3. Given this command’s docs also mention m/h durations (for track), this is especially likely to produce wrong advances. Consider requiring a pure integer string for [n] before parsing.
function cmdAdvance(arg: string | undefined): void {
  const n = arg === undefined ? 1 : parseInt(arg, 10);
  if (Number.isNaN(n) || n < 1) {
    console.error(USAGE);
    process.exit(1);
  }

Comment thread src/turn.ts
Comment thread src/commands/turn.ts
@ptaranat
ptaranat force-pushed the ptaranat/db-106-dw-turn-dungeon-turn-tracker branch from 99cc0f0 to 300bd2a Compare August 28, 2026 13:49
@ptaranat
ptaranat merged commit 6c23b12 into main Aug 28, 2026
2 checks passed
ptaranat added a commit that referenced this pull request Aug 28, 2026
Moves the dw turn session file default from the repo root to
~/.cache/dw/dw-session.json, the same machine-local home as dw.db and
the extraction cache, so state survives switching or re-cloning
checkouts. DW_SESSION still overrides. The repo-root gitignore entry
stays as protection for old state files. Follows up the Copilot thread
on #2, where my repo-root-convention claim was wrong.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants