/** * @file Apotheosis panel component for the final prestige layer. * @copyright nhcarrigan * @license Naomi's Public License * @author Naomi Carrigan */ /* eslint-disable max-lines-per-function -- Complex component with many render paths */ /* eslint-disable complexity -- Complex component with many conditional render paths */ import { type JSX, useState } from "react"; import { useGame } from "../../context/gameContext.js"; import { TRANSCENDENCE_UPGRADES } from "../../data/transcendenceUpgrades.js"; const totalEchoUpgrades = TRANSCENDENCE_UPGRADES.length; /** * Renders the apotheosis panel for achieving the final game milestone. * @returns The JSX element. */ const ApotheosisPanel = (): JSX.Element => { const { state, apotheosis } = useGame(); const [ isPending, setIsPending ] = useState(false); const [ result, setResult ] = useState(null); const [ error, setError ] = useState(null); if (state === null) { return (

{"Loading..."}

); } const purchasedIds = state.transcendence?.purchasedUpgradeIds ?? []; const purchasedCount = TRANSCENDENCE_UPGRADES.filter((upgrade) => { return purchasedIds.includes(upgrade.id); }).length; const isEligible = purchasedCount >= totalEchoUpgrades; const apotheosisCount = state.apotheosis?.count ?? 0; async function handleApotheosis(): Promise { setIsPending(true); setError(null); try { const data = await apotheosis(); setResult(data.newApotheosisCount); } catch (caughtError) { setError( caughtError instanceof Error ? caughtError.message : "Apotheosis failed", ); } finally { setIsPending(false); } } function handleApotheosisClick(): void { void handleApotheosis(); } const plural = apotheosisCount === 1 ? "" : "s"; return (

{"✨ Apotheosis"}

{"Apotheosis is the final act — a complete dissolution of everything" + " you have built. Prestige, Transcendence, Echoes, upgrades," + " equipment, resources: all of it returns to nothing." + " In exchange, you receive only one thing:"}

{"The "} {"✨ Apotheosis"} {" badge. Proof that you have done it all."}

{"Apotheosis can be achieved multiple times. Each cycle requires" + " you to purchase every Transcendence upgrade again before the" + " next Apotheosis becomes available. There is no mechanical" + " benefit — only the knowledge that you have reached the" + " pinnacle, dissolved it, and climbed back up."}

{apotheosisCount > 0 &&
{"You have achieved Apotheosis "} {apotheosisCount} {" time"} {plural} {"."}
}

{"Transcendence upgrades purchased: "} {purchasedCount} {" / "} {totalEchoUpgrades}

{isEligible ? null :

{"🔒 Purchase all "} {totalEchoUpgrades} {" Transcendence upgrades to unlock Apotheosis. ("} {totalEchoUpgrades - purchasedCount} {" remaining)"}

} {isEligible ?

{"✅ All Transcendence upgrades purchased. You are ready."}

: null}
{isEligible ?

{"This action is "} {"permanent and irreversible"} {"."}

{error === null ? null :

{error}

} {result !== null &&

{"Apotheosis achieved. This is cycle "} {result} {". The infinite loop continues."}

}
: null}
); }; export { ApotheosisPanel };