107 lines
12 KiB
Markdown
107 lines
12 KiB
Markdown
# Change Request CR-024 — Fleet Sleep Mode
|
||
|
||
> **Numbering note (added when recorded):** this request arrived titled "CR-022 — Fleet Sleep Mode" for "Phase 22". CR-022 (Welcome Screens) and CR-023 (Shop Time Counts as Rest), and Phases 22 and 23, already existed, so it is stored as **CR-024** and done as **Phase 24**: every "22.n" below means **24.n**. Its references map to this repo as: "Phase 13 and CR-001 through CR-021" = Phase 13 and **CR-001 to CR-023**; "CR-004 pilot rest" is the same number; "CR-008 settings" = **CR-011** (Settings, the Notifications toggle's screen); "CR-011 local-first" = **CR-014** (the engine, the command catalog in `packages/schema/src/routes.ts`, the notification scheduler); "CR-019 independent pilots" = **CR-021** (Independent pilots, catch-up, the pilot logbook and the 8-hour away scenario). Plan 12.1 is the same step. Its new decisions CR-022.D1–D4 are recorded as **0.5.136 Manual decisions**, **0.5.137 Sleep**, **0.5.138 Waking** and **0.5.139 Sleep notification**.
|
||
>
|
||
> **On recording:** "HQ shows 'Fleet asleep'" is read as the Bridge (the dashboard, where the Dispatch Office panel is), as CR-021 read "HQ screen"; the HQs tab (CR-020) lists bays only. The Notifications toggle is CR-014's (Settings).
|
||
|
||
**Project:** Deadhead: Space Freight Tycoon
|
||
**Applies to:** a build with Phase 13 and CR-001 through CR-021 complete
|
||
**Do this:** as **Phase 22**
|
||
**Related docs:** `change-request-pilot-rest.md` (CR-004), `change-request-settings.md` (CR-008), `change-request-local-first.md` (CR-011), `change-request-independent-pilots.md` (CR-019), `DECISIONS.md`
|
||
|
||
This change request is written for the local-first engine (CR-011).
|
||
|
||
---
|
||
|
||
## 1. Why
|
||
|
||
Playtesting: left alone for a week, Independent pilots (CR-019) kept running jobs the whole time. That makes absence too rewarding, removes any reason to check in, and makes catch-up long. The fleet should **go quiet when the boss hasn't given any orders for a while**, then wake up the moment the player makes a decision.
|
||
|
||
## 2. Rules
|
||
|
||
| Rule | Detail |
|
||
| -------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
||
| Manual decision | Any game command the player makes: dispatch, deadhead, refuel, buy, lease, hire, assign, spend a skill point, upgrade, change a pilot's mode or orders, claim a goal, repay the loan, accept the deal, buy the Dispatch Office. **Not** counted: opening the app, viewing screens, dismissing summaries, device preferences (CR-008 display/help), export/import. |
|
||
| Sleep threshold | 24 real hours after the last manual decision by default. Player setting in Settings → Company: 12 h, 24 h, 48 h, or 3 days. |
|
||
| Asleep | From the sleep time on, **Independent pilots start no new jobs or deadheads.** Trips already in flight finish normally (payout, XP, pilot share, loan repayment), and mandatory rest still happens. Pilots then wait with status "Waiting for orders". |
|
||
| Unaffected | Trips the player dispatched by hand, upgrades in progress, and everything else that's already scheduled. |
|
||
| Waking | The next manual decision wakes the fleet immediately: Independent pilots resume from that moment. The return screen also offers a **"Back to work"** button, which counts as a manual decision. |
|
||
| Catch-up | Catch-up (CR-019) computes the sleep time from the saved last-decision time and stops starting new Independent work after it. Results stay deterministic. |
|
||
| Notification (native only) | Each manual decision schedules one local notification at the sleep time, replacing the previous one: "Your pilots are waiting for orders." Canceled if a manual decision happens first. Respects the Notifications toggle (CR-011). |
|
||
|
||
### On return
|
||
|
||
The "while you were away" screen (CR-019 logbook) shows a banner when the fleet went quiet: "Your fleet went quiet on [date, time] after [24 h] without orders." with the **Back to work** button. The logbook covers activity up to the sleep time and the trips that finished after it.
|
||
|
||
## 3. Rules for this change
|
||
|
||
- All rules in `implementation-plan.md` §0.1 apply: steps in order, one commit per step, each step's test must pass, `packages/sim` stays pure, all numbers live in `packages/content`.
|
||
- **One place decides what counts as a manual decision**: a flag on each engine command in the command catalog, so new commands must declare it.
|
||
- Save migration: last manual decision time is set to the migration time; sleep threshold to the default.
|
||
- Update `architecture.md` and `progress.md` as you go. Stop for the user's review at the end of Phase 22.
|
||
|
||
## 4. Decisions
|
||
|
||
Record these in `DECISIONS.md` and `implementation-plan.md` §0.5, using the next free numbers (labeled CR-022.D1–D4 here; note the mapping).
|
||
|
||
- **CR-022.D1 Manual decisions.** Defined per §2 and flagged per command in the command catalog.
|
||
- **CR-022.D2 Sleep.** After the threshold (default 24 h, player-selectable), Independent pilots start no new work; in-flight trips and rest finish normally.
|
||
- **CR-022.D3 Waking.** Any manual decision, including "Back to work", wakes the fleet immediately.
|
||
- **CR-022.D4 Sleep notification.** One local notification at the sleep time, rescheduled on every manual decision.
|
||
|
||
## 5. Steps — Phase 22
|
||
|
||
### Step 22.1 — Content and save
|
||
|
||
- Add the default sleep threshold and the allowed options to config. Add to the save: last manual decision time and the chosen threshold. Save migration per §3.
|
||
- **Test:** Config validates. A new company starts with the last manual decision time set to its creation and the default threshold. An older save migrates as described.
|
||
|
||
### Step 22.2 — Engine: manual decision flag
|
||
- **Amended by CR-026:** Answering a radio call (`answerRadioCall`) and repairing a ship (`repairShip`) are manual decisions.
|
||
|
||
- Add a "manual decision" flag to every command in the command catalog per §2. Running a flagged command updates the last manual decision time.
|
||
- **Test:** A catalog test fails if any command is missing the flag. Dispatching updates the time; changing a display preference or exporting a save doesn't. Commands run by Independent pilots (CR-019) never update it.
|
||
|
||
### Step 22.3 — Engine: sleep in live play and catch-up
|
||
|
||
- Independent pilots don't start new jobs or deadheads at or after the sleep time (last manual decision time + threshold). In-flight trips and rest resolve normally. Pilots that would act show "Waiting for orders".
|
||
- **Test:** From a save with two Independent pilots and no manual decisions, catching up 7 days produces no new Independent trips after 24 hours; trips in flight at the 24-hour mark still pay out. Catching up in one go and in pieces gives identical results. A manual dispatch flown before the sleep time completes after it as normal. Changing the threshold to 48 hours moves the cutoff.
|
||
|
||
### Step 22.4 — Engine: waking and "Back to work"
|
||
|
||
- Add a "Back to work" command (flagged as a manual decision). Any manual decision after the sleep time wakes the fleet: Independent pilots become eligible to act again from that moment.
|
||
- **Test:** After sleep, running "Back to work" lets Independent pilots take jobs again in the next decision round; so does any other manual decision, such as buying fuel.
|
||
|
||
### Step 22.5 — Client: return banner, status, and setting
|
||
- **Amended by CR-025:** The sleep banner stays at the top of the highlights pop-up, under its title.
|
||
|
||
- The "while you were away" screen shows the sleep banner and "Back to work" button when the fleet went quiet. HQ shows "Fleet asleep — waiting for your orders" with the same button while asleep.
|
||
- Pilot status lines show "Waiting for orders" for sleeping Independent pilots.
|
||
- Settings → Company: "Fleet goes quiet after: 12 h / 24 h / 48 h / 3 days".
|
||
- **Test:** Component tests: the banner and HQ status appear only when asleep; the button calls the command and they disappear; the setting saves and changes the displayed threshold.
|
||
|
||
### Step 22.6 — Client: sleep notification (native)
|
||
|
||
- Schedule the notification per §2 through the CR-011 notification scheduler; reschedule on every manual decision; cancel on new company or import.
|
||
- **Test:** With a mocked scheduler: a dispatch schedules one notification at last decision + threshold; a second manual decision replaces it; turning off notifications or starting a new company cancels it; on web, nothing is scheduled.
|
||
|
||
### Step 22.7 — Plan amendments and regression
|
||
|
||
- Apply the amendments in §6.
|
||
- Run the full suite.
|
||
- **Test:** CI is green. The CR-019 8-hour away scenario still meets its 40–80% target (it's under the default threshold). A new balance check: a 7-day absence earns no more than a 24-hour absence plus trips in flight at the sleep time. Manual check: set the threshold to 12 h, leave the game, reopen after 13+ hours, and confirm the banner, the logbook, and that "Back to work" restarts the pilots.
|
||
|
||
## 6. Amendments
|
||
|
||
| Where | Change |
|
||
| --------- | ---------------------------------------------------------------------------------------------------------------------- |
|
||
| Plan 0.5 | Add CR-022.D1–D4. |
|
||
| CR-011 | Command catalog gains the manual-decision flag; notification scheduler gains the sleep notification. |
|
||
| CR-019 | Independent pilots stop starting new work while the fleet is asleep; logbook gains the sleep banner. |
|
||
| CR-008 | Settings → Company gains the threshold option. |
|
||
| Plan 12.1 | 7-day absence check added (22.7). |
|
||
|
||
## 7. Out of scope
|
||
|
||
Sleeping manually dispatched trips, gradual slowdowns before sleep, extra offline earnings caps, and anything else in `implementation-plan.md` §0.3.
|