import { content } from "@deadhead/content"; import type { TutorialState } from "@deadhead/schema"; import { realToGame } from "@deadhead/sim"; import { useClock } from "../clock/clock"; import { formatGameTime } from "../clock/GameClock"; import { Countdown } from "../components/Countdown"; import { GoalsCard } from "../components/GoalsCard"; import { LoanCard } from "../components/LoanCard"; import { formatCredits, locationName } from "../format"; import { useLoadedPlayer } from "../state/actions"; /** What the player needs to do next to reach the deal (decision 0.5.30). */ export function tutorialHint(tutorial: TutorialState, runsBeforeDeal: number): string { if (tutorial.dealAvailable) return "Halvorsen is waiting at Earth with an offer."; if (tutorial.runsCompleted < runsBeforeDeal) { return "Keep flying — the old man has an offer for you."; } // Enough runs, but the deal is made at Earth. return tutorial.runInFlight ? "Halvorsen will talk once you land at Earth." : "One more run: bring the ship back to Earth — Halvorsen is waiting there."; } export function HQ() { const state = useLoadedPlayer(); const now = useClock((s) => s.now); const idle = state.ships.filter((s) => s.status === "idle").length; const flying = state.ships.filter((s) => s.status === "in-flight").length; const runsBeforeDeal = content.config.tutorialRunsBeforeDeal; const next = [...state.activeDispatches].sort((a, b) => a.arrivalAt - b.arrivalAt)[0]; // Resting pilots and who wakes first (CR-004). const resting = state.pilots .filter((p) => p.resting && p.restEndsAt !== null) .sort((a, b) => a.restEndsAt! - b.restEndsAt!); return (

HQ

Next arrival

{next ? (

{locationName(next.originId)} → {locationName(next.destinationId)} in{" "}

) : (

Nothing in flight.

)}
{!state.tutorial && (

Pilots resting: {resting.length}

{resting[0] ? (

{resting[0].name} wakes in

) : (

Everyone is ready to fly.

)}
)} {!state.tutorial && state.ships.length === 0 && (

No ships yet — buy one in the Market.

)} {state.tutorial && (

Flying for Halvorsen Lunar Freight

Company runs: {Math.min(state.tutorial.runsCompleted, runsBeforeDeal)} of{" "} {runsBeforeDeal}

{tutorialHint(state.tutorial, runsBeforeDeal)}

)} {!state.tutorial && } {!state.tutorial && state.company.loanBalance > 0 && }
); } function Stat({ label, value }: { label: string; value: string }) { return (
{label}
{value}
); }