Record CR-023: shop time counts as rest (Phase 23)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
fireshaper 2026-10-11 17:55:49 -04:00
parent e17abb3a3e
commit 103f8f1e72
4 changed files with 77 additions and 0 deletions

View File

@ -1778,3 +1778,7 @@ Implementation decisions not spelled out in `memory-bank/implementation-plan.md`
- **Decision 0.5.134: the Contracts chips count ships ready for a job.** "Idle" counted ships whose pilot was resting, so a location looked like it had a pilot available when none could fly. Uncrewed ships, ships in the shop and Independent pilots' ships don't count either: none of them can take a job the player picks. The chip's label is now "N ship(s) ready".
- **Rest is checked against the clock on the board**, not the `resting` flag from the last state fetch, so the count changes when rest ends. The Jobs tab badge keeps using the flag, to avoid re-rendering the whole app every second.
- **The Dispatch sheet is unchanged**: it already lists a resting pilot's ship as blocked, with the time left.
## CR-023 recorded (Shop Time Counts as Rest)
- **Numbering:** received as "CR-021 — Shop Time Counts as Rest" for "Phase 21"; stored as **CR-023**, built as **Phase 23** (its 21.n = 23.n), since CR-021 (Independent Pilots) and CR-022 (Welcome Screens) exist. Its decision CR-021.D1 is **0.5.135**. Its references: CR-006 → CR-009, CR-011 → CR-014, CR-019 → CR-021; CR-004 is unchanged.

View File

@ -0,0 +1,57 @@
# Change Request CR-023 — Shop Time Counts as Rest
> **Numbering note (added when recorded):** this request arrived titled "CR-021 — Shop Time Counts as Rest" for "Phase 21". CR-021 (Independent Pilots) and CR-022 (Welcome Screens), and Phases 21 and 22, already existed, so it is stored as **CR-023** and done as **Phase 23**: every "21.n" below means **23.n**. Its references map to this repo as: "Phase 13 and CR-001 through CR-020" = Phase 13 and **CR-001 to CR-022**; "CR-004 pilot rest" is the same number; "CR-006 ship upgrades" = **CR-009**; "CR-011 local-first" = **CR-014** (the resolution loop and catch-up are CR-021's event queue, decision 0.5.129); "CR-019 independent pilots" = **CR-021**. Its new decision CR-021.D1 is recorded as **0.5.135 Shop time counts as rest**.
>
> **On recording:** rest is 10 game hours (10 real minutes at 60× compression) and the shop takes 10, 20 or 30 real minutes (10, 20 or 30 game hours), so every shop time already covers a full rest.
**Project:** Deadhead: Space Freight Tycoon
**Applies to:** a build with Phase 13 and CR-001 through CR-020 complete
**Do this:** as **Phase 21** (small)
**Related docs:** `change-request-pilot-rest.md` (CR-004), `change-request-ship-upgrades.md` (CR-006), `change-request-local-first.md` (CR-011), `change-request-independent-pilots.md` (CR-019), `DECISIONS.md`
---
## 1. Why
An upgrade takes a ship out of service for 10–30 real minutes, and a full rest is 10 real minutes. Today a tired pilot can wait out an upgrade and then still have to rest afterward: double downtime while they were standing around. From now on, a pilot who stays with their ship while it's in the shop comes out rested.
## 2. Rules
| Rule | Detail |
| ------------------ | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| Duty reset | When an upgrade finishes, the pilot assigned to that ship has their duty hours set to zero, **if** they were assigned to it for the whole shop time and didn't fly in the meantime. |
| Already resting | If the pilot was resting when the upgrade started, the rest continues as normal alongside it. If the rest would end after the upgrade, it also ends when the upgrade finishes. |
| Not locked in | The pilot isn't blocked during the upgrade. They can still be unassigned at the HQ and fly another ship; if they do, they don't get the reset. |
| Shop time vs rest | All shop times are at least the rest duration. A content test enforces this; if a future shop time is shorter, it doesn't count as rest. |
| Independent pilots | Same rule (CR-019). An Independent pilot whose ship is in the shop waits with it and comes out rested. |
## 3. Decision
Record in `DECISIONS.md` and `implementation-plan.md` §0.5 with the next free number (labeled CR-021.D1 here).
- **CR-021.D1 Shop time counts as rest.** Per §2.
## 4. Steps — Phase 21
### Step 21.1 — Content test
- **Test:** Every upgrade level's shop time, converted to game hours, is at least the rest duration.
### Step 21.2 — Sim and engine: duty reset on upgrade completion
- When an upgrade's shop time ends (in the resolution loop or catch-up), if the ship's current pilot has been assigned to it since the upgrade started and hasn't flown since, set their duty hours to zero and clear any rest that would end later. Track this with an "assigned since" time on the pilot, or by recording the pilot id on the upgrade when it starts.
- **Test:** A pilot near the duty limit whose ship finishes an upgrade has zero duty hours and can be dispatched immediately. A pilot who was unassigned during the upgrade and flew another ship keeps their duty hours. A pilot already resting when the upgrade started is free when the upgrade ends, if their rest would have ended later. Catch-up produces the same result as live play.
### Step 21.3 — Client: status line
- While the ship is in the shop, the assigned pilot's status reads "Resting while in the shop — mm:ss" (the upgrade countdown). The ship's Fleet card keeps its "In the shop" countdown.
- **Test:** Component test: a pilot whose ship is in the shop shows the new status with the right countdown; after unassigning them, the status no longer says they're resting.
### Step 21.4 — Regression
- Run the full suite.
- **Test:** CI is green. Manual check: fly a pilot close to the duty limit, start an upgrade at the HQ, and confirm they're ready to fly the moment the upgrade finishes.
## 5. Out of scope
Rest facilities at HQs, shortening shop times, and anything else in `implementation-plan.md` §0.3.

View File

@ -190,6 +190,7 @@ These answer the pre-build review. Log each one in `DECISIONS.md` as it is imple
132. **How to play** (CR-022). Settings → Help reopens the three cards any time, ending in "Close"; it doesn't change the saved flag.
133. **Boards are for the player's pilots** (fix after CR-021). The qualifying fleet (0.5.115) counts only Manual pilots and the ships not assigned to an Independent pilot, so the player never sees jobs only an Independent pilot could fly; Independent pilots check each job against their own pair. With no Manual pair at all, the whole fleet counts.
134. **Ready ships** (fix after CR-022). The Contracts screen's location chips and the Jobs tab badge count only ships a job could go out on now: idle, with an assigned pilot who isn't resting or Independent, and not in the shop. Where idle ships are docked but none is ready, the board says so and names the pilot who wakes first.
135. **Shop time counts as rest** (CR-023). When an upgrade finishes, the pilot who was assigned to the ship for the whole shop time (never unassigned, so never flying another ship) has their duty reset to zero, and a rest that would end later ends then. A shop time shorter than a rest doesn't count. Independent pilots alike.
### 0.6 Translating change requests written for the server (CR-014 §7)
@ -883,6 +884,12 @@ Steps 22.1–22.4 are specified in `memory-bank/change-requests/CR-022-welcome-s
---
## Phase 23 — Shop Time Counts as Rest (CR-023)
Steps 23.1–23.4 are specified in `memory-bank/change-requests/CR-023-shop-time-rest.md` §4 (written there as 21.1–21.4). Stop for review at the end.
---
## Definition of Done (Base Game)
- All step tests pass in CI.

View File

@ -505,3 +505,12 @@ Spec: `memory-bank/change-requests/CR-022-welcome-screens.md` (received as "CR-0
- [x] **Boards ignore Independent pilots (decision 0.5.133).** Reported: with Rosa Independent, the board still showed jobs only that pilot could fly. The board's qualifying fleet now leaves out Independent pilots and their ships, both when a board is generated and when it's read, so a board already stored this period hides those jobs at once. Independent pilots still check each job against their own pair; with no Manual pair at all, the whole fleet counts. Tests (`packages/engine/test/completable-boards.test.ts`): heavy jobs vanish from the board when the Freighter's pilot goes Independent, this period and the next five; the fallback to the whole fleet.
- [x] **Ready ships, not idle ships (decision 0.5.134).** Reported: a resting pilot still showed as available on the board. The location chips on Contracts counted every idle ship, so a ship whose pilot was resting still showed as ready. They now count ships ready for a job (`readyShips` in `apps/web/src/game.ts`): crewed, the pilot not resting (checked against the clock, so the count updates the moment rest ends) or Independent, and not in the shop. The Jobs tab badge uses the same rule. With idle ships here but none ready, the board says "No pilot here is ready to fly" and who wakes first. Tests (`apps/web/test/ready-ships.test.tsx`, `location-boards.test.tsx`). Screenshots: `docs/screenshots/fix-ready-ships-resting-{phone,desktop}.png`.
## Phase 23 — Shop Time Counts as Rest (CR-023)
Spec: `memory-bank/change-requests/CR-023-shop-time-rest.md` (received as "CR-021 … Phase 21"). New decision recorded as plan §0.5.135.
- [ ] Step 23.1 — Content test
- [ ] Step 23.2 — Sim and engine: duty reset on upgrade completion
- [ ] Step 23.3 — Client: status line
- [ ] Step 23.4 — Regression