import { content } from "@deadhead/content"; import { deliveryXp, loanerModel } from "@deadhead/sim"; import { useQuery } from "@tanstack/react-query"; import { useApi } from "../api/context"; import { useClock } from "../clock/clock"; import { formatCredits, formatDuration, locationName } from "../format"; import { goodName } from "../components/Goods"; import { distanceAt, tripRealMs } from "../game"; import { errorMessage, useGameAction, useLoadedPlayer } from "../state/actions"; import { usePreferences } from "../state/preferences"; import { RouteStrip } from "../components/RouteStrip"; import { Art, Button, Icon, Panel, Pill } from "../ui"; export const TUTORIAL_BOARD_KEY = ["board", "tutorial"] as const; /** The id of the tutorial intro card in dismissed tips. */ export const INTRO_TIP = "tutorial-intro"; /** The company board during the tutorial (Step 9.3). */ export function TutorialBoard() { const api = useApi(); const state = useLoadedPlayer(); const now = useClock((s) => s.now); const board = useQuery({ queryKey: TUTORIAL_BOARD_KEY, queryFn: () => api.call("getTutorialBoard", {}), }); const fly = useGameAction("createDispatch"); const runInFlight = state.tutorial?.runInFlight ?? false; const loaner = loanerModel(content); const firstRun = (state.tutorial?.runsCompleted ?? 0) === 0; // A one-time tip: dismissible, and back with "Show tips again" (CR-011). const introDismissed = usePreferences((p) => p.dismissedTips.includes(INTRO_TIP)); const dismissTip = usePreferences((p) => p.dismissTip); if (board.isPending) return

Loading contracts…

; if (board.isError) { return (
Could not load contracts.{" "}
); } return (
{firstRun && !introDismissed && (

Halvorsen Lunar Freight needs a pilot.

Their ship, your hands. Get the crates to the Moon.

)}

Company runs in the loaner {loaner.name}. You keep a share of each payout.

{runInFlight && (

Your run is in flight. Wait for it to land.

)} {fly.isError && (

{errorMessage(fly.error)}

)} {board.data.contracts.length === 0 && (

No company runs left this period. Check back soon.

)}
); }