import React, { useState, useEffect } from "react"; import GameDataManager from "../../../services/GameDataManager.js"; import "./styles/DungeonsTab.css"; const DungeonsTab = ({ startDungeon }) => { const [dungeons, setDungeons] = useState([]); const [selectedDungeon, setSelectedDungeon] = useState(null); const [showSelector, setShowSelector] = useState(true); useEffect(() => { const allKeys = Array.from(GameDataManager.dungeons.keys()); const uniqueDungeons = Array.from(new Set(allKeys)) .map((id) => GameDataManager.getDungeon(id)) .filter( (d, index, self) => d && self.findIndex((t) => t.id === d.id) === index, ); setDungeons(uniqueDungeons); if (uniqueDungeons.length > 0 && !selectedDungeon) { setSelectedDungeon(uniqueDungeons[0]); } }, []); const handleSelectDungeon = (id) => { const translatedDungeon = GameDataManager.getDungeon(id); setSelectedDungeon(translatedDungeon); if (window.innerWidth <= 768) { setShowSelector(false); } }; return (

AVAILABLE_MISSIONS

{dungeons.map((dungeon) => (
handleSelectDungeon(dungeon.id)} >
{dungeon.displayName} {dungeon.energyCost} EN
))}
{selectedDungeon ? (
MISSION_BRIEFING

{selectedDungeon.displayName}

{selectedDungeon.description || "No tactical briefing available for this sector."}

EXPECTED_REWARDS:

{selectedDungeon.lootTable?.map((loot, idx) => { const item = GameDataManager.getItem(loot.itemId); const rarity = item?.meta?.rarity || "common"; return (
{item?.texture ? ( {item.displayName} ) : ( )}
{item?.displayName || loot.itemId} {loot.chance}% ACQUISITION
); })}
) : (

WAITING_FOR_COORDINATES...

)}
); }; export default DungeonsTab;