/** * @file Game layout component rendering the main game UI. * @copyright nhcarrigan * @license Naomi's Public License * @author Naomi Carrigan */ /* eslint-disable max-lines-per-function -- Complex layout with many conditional renders */ /* eslint-disable complexity -- Many tab render paths */ import { type JSX, useState } from "react"; import { useGame } from "../../context/gameContext.js"; import { ResourceBar } from "../ui/resourceBar.js"; import { AboutPanel } from "./aboutPanel.js"; import { AchievementPanel } from "./achievementPanel.js"; import { AchievementToast } from "./achievementToast.js"; import { AdventurerPanel } from "./adventurerPanel.js"; import { ApotheosisPanel } from "./apotheosisPanel.js"; import { BattleModal } from "./battleModal.js"; import { BossPanel } from "./bossPanel.js"; import { CharacterSheetPanel } from "./characterSheetPanel.js"; import { ClickArea } from "./clickArea.js"; import { CodexPanel } from "./codexPanel.js"; import { CodexToast } from "./codexToast.js"; import { CompanionPanel } from "./companionPanel.js"; import { CraftingPanel } from "./craftingPanel.js"; import { DailyChallengePanel } from "./dailyChallengePanel.js"; import { EditProfileModal } from "./editProfileModal.js"; import { EquipmentPanel } from "./equipmentPanel.js"; import { ExplorationPanel } from "./explorationPanel.js"; import { LoginBonusModal } from "./loginBonusModal.js"; import { OfflineModal } from "./offlineModal.js"; import { OutdatedSchemaModal } from "./outdatedSchemaModal.js"; import { PrestigePanel } from "./prestigePanel.js"; import { QuestPanel } from "./questPanel.js"; import { StatisticsPanel } from "./statisticsPanel.js"; import { StoryPanel } from "./storyPanel.js"; import { StoryToast } from "./storyToast.js"; import { TranscendencePanel } from "./transcendencePanel.js"; import { UpgradePanel } from "./upgradePanel.js"; type Tab = | "adventurers" | "upgrades" | "quests" | "bosses" | "equipment" | "achievements" | "prestige" | "transcendence" | "apotheosis" | "statistics" | "daily" | "codex" | "about" | "exploration" | "crafting" | "character" | "companions" | "story"; const baseTabs: Array<{ id: Tab; label: string }> = [ { id: "adventurers", label: "βš”οΈ Adventurers" }, { id: "upgrades", label: "πŸ”§ Upgrades" }, { id: "quests", label: "πŸ“œ Quests" }, { id: "bosses", label: "πŸ‘Ή Bosses" }, { id: "equipment", label: "πŸ—‘οΈ Equipment" }, { id: "exploration", label: "πŸ—ΊοΈ Exploration" }, { id: "crafting", label: "βš—οΈ Crafting" }, { id: "daily", label: "πŸ“… Daily" }, { id: "prestige", label: "⭐ Prestige" }, { id: "transcendence", label: "🌌 Transcendence" }, { id: "apotheosis", label: "✨ Apotheosis" }, { id: "statistics", label: "πŸ“Š Statistics" }, { id: "companions", label: "πŸ‘₯ Companions" }, { id: "character", label: "πŸ“‹ Character" }, { id: "achievements", label: "πŸ† Achievements" }, { id: "story", label: "πŸ“– Story" }, { id: "codex", label: "πŸ—ΊοΈ Codex" }, { id: "about", label: "ℹ️ About" }, ]; /** * Renders the main game layout with tabs and panels. * @returns The JSX element. */ const GameLayout = (): JSX.Element => { const { state, isLoading, error, battleResult, dismissBattle, lastSavedAt, isSyncing, forceSync, unlockedCodexEntryIds: pendingCodexEntryIds, unlockedStoryChapterIds: pendingStoryChapterIds, loginBonus, dismissLoginBonus, schemaOutdated, } = useGame(); const [ activeTab, setActiveTab ] = useState("adventurers"); const [ editingProfile, setEditingProfile ] = useState(false); const [ dismissedOutdatedWarning, setDismissedOutdatedWarning ] = useState(false); if (isLoading) { return (

{"Loading your adventure..."}

); } if (error !== null && error !== "") { return (

{"Error: "} {error}

); } if (state === null) { return (

{"Loading..."}

); } const profileUrl = `/profile/${state.player.discordId}`; const codexBadgeCount = pendingCodexEntryIds.length; const storyBadgeCount = pendingStoryChapterIds.length; function handleOpenEditProfile(): void { setEditingProfile(true); } function handleCloseEditProfile(): void { setEditingProfile(false); } function handleDismissOutdated(): void { setDismissedOutdatedWarning(true); } return (
{schemaOutdated && !dismissedOutdatedWarning ? : null} {loginBonus === null ? null : } {battleResult === null ? null : } {editingProfile ? : null}
{activeTab === "adventurers" && } {activeTab === "upgrades" && } {activeTab === "quests" && } {activeTab === "bosses" && } {activeTab === "equipment" && } {activeTab === "achievements" && } {activeTab === "prestige" && } {activeTab === "transcendence" && } {activeTab === "apotheosis" && } {activeTab === "exploration" && } {activeTab === "crafting" && } {activeTab === "statistics" && } {activeTab === "daily" && } {activeTab === "companions" && } {activeTab === "character" && } {activeTab === "story" && } {activeTab === "codex" && } {activeTab === "about" && }
); }; export { GameLayout };