Files
smugglers-run/app/page.tsx
T
2026-02-07 20:11:26 +01:00

88 lines
2.3 KiB
TypeScript

"use client";
import { useGameEngine } from "@/hooks/useGameEngine";
import HUD from "../components/Hud";
import GalaxyMap from "../components/GalaxyMap";
import EventLog from "../components/EventLog";
import ActionPanel from "../components/ActionPanel";
import StartScreen from "@/components/StartScreen";
import GameOverScreen from "@/components/GameOverScreen";
import { t } from "@/content/locales"; // Import der Locales
export default function Home() {
const {
gameStarted,
startGame,
planets,
credits,
hp,
loading,
currentLocationId,
selectedPlanet,
setSelectedPlanet,
handleAttack,
executeJump,
isJumping,
activeEnemy,
executeEscape,
logs,
isGameOver,
restartGame,
} = useGameEngine();
// 1. Ladezustand
if (loading) {
return (
<div className="min-h-screen bg-black flex items-center justify-center font-mono text-yellow-500">
<div className="animate-pulse tracking-[0.3em]">{t.SYSTEM.LOADING}</div>
</div>
);
}
// Aktuellen Planeten finden für das HUD
const currentPlanet = planets.find((p) => p.id === currentLocationId);
// 2. Startbildschirm
if (!gameStarted) {
return <StartScreen onStart={startGame} />;
}
return (
<main className="min-h-screen bg-[#050505] pt-24 px-4 flex flex-col items-center">
<HUD
credits={credits}
hp={hp}
maxHp={10} // Könnte später aus einem Ship-Objekt kommen
location={currentPlanet?.name || t.SYSTEM.DEEP_SPACE}
targetCredits={100000}
/>
<div className="w-full max-w-4xl flex flex-col items-center gap-6">
<GalaxyMap
planets={planets}
onSelectLocation={(p) => setSelectedPlanet(p)}
currentLocationId={currentLocationId}
/>
{/* ActionPanel erscheint bei Zielwahl oder Feindkontakt */}
{(selectedPlanet || activeEnemy) && (
<ActionPanel
planet={selectedPlanet}
enemy={activeEnemy}
isLoading={isJumping}
onAction={activeEnemy ? handleAttack : executeJump}
onEscape={executeEscape}
/>
)}
</div>
<EventLog logs={logs} />
{/* Game Over Overlay */}
{isGameOver && (
<GameOverScreen credits={credits} onRestart={restartGame} />
)}
</main>
);
}