import { content, type Location } from "@deadhead/content"; import { Link } from "react-router"; import { useClock } from "../clock/clock"; import { cargoName, formatCredits, formatMillionKm } from "../format"; import { distanceAt } from "../game"; import { errorMessage, useGameAction, useLoadedPlayer } from "../state/actions"; import { Art, Button, buttonClass, Icon, Panel, Pill, Screen, ScreenHeader } from "../ui"; const TYPE_LABELS: Record = { "atmospheric-world": "Atmospheric world", "airless-body": "Airless body", "cloud-platform": "Cloud platform", "belt-station": "Belt station", }; /** What a bay is for (CR-002: bays are HQs, not access to contracts). */ export const HQ_EXPLANATION = "Open an HQ here: hire pilots and take delivery of new ships at this location."; const LANDING_LABELS = { vacuum: "Any ship", atmospheric: "Atmospheric", hardened: "Hardened" }; /** Every location; details, contracts and HQ leasing once discovered (Steps 9.9, 10B.9). */ export function Locations() { const state = useLoadedPlayer(); const now = useClock((s) => s.now); const lease = useGameAction("leaseBay"); return ( {lease.isError && (

{errorMessage(lease.error)}

)}
    {content.locations.map((location) => { const discovered = state.locations.find((l) => l.id === location.id)?.discovered; if (!discovered) { return (
    {location.name}
    Undiscovered — deliver here to unlock.
    ); } const hasBay = state.bays.some((b) => b.locationId === location.id); const affordable = state.company.credits >= location.bayLeasePrice; return (
    {location.name} {hasBay && ( HQ )}
    {location.id === "earth" ? "Home" : `${formatMillionKm(distanceAt("earth", location.id, now))} from Earth`}
    Type
    {TYPE_LABELS[location.type]}
    Landing
    {LANDING_LABELS[location.landingRequirement]}
    Produces
    {location.cargoClassMix.produces.map(cargoName).join(", ") || "—"}
    Demands
    {location.cargoClassMix.demands.map(cargoName).join(", ") || "—"}
    View contracts {hasBay ? (

    Your HQ is here

    ) : ( <>

    {HQ_EXPLANATION}

    )}
    ); })}
); }