import React from 'react'; import { WORLD_1 } from './levels/world1.js'; import { WORLD_2 } from './levels/world2.js'; import { WORLD_3 } from './levels/world3.js'; import { WORLD_4 } from './levels/world4.js'; import { WORLD_5 } from './levels/world5.js'; import { WORLD_6 } from './levels/world6.js'; import { getLevelProgress, isLevelUnlocked, loadProgress } from './gameState.js'; const worlds = [WORLD_1, WORLD_2, WORLD_3, WORLD_4, WORLD_5, WORLD_6]; function Stars({ count, max = 3 }) { return ( {Array.from({ length: max }, (_, i) => ( ))} ); } function getTotalStars() { const p = loadProgress(); return Object.values(p.completedLevels).reduce((s, l) => s + (l.stars || 0), 0); } function getMaxStars() { return worlds.reduce((s, w) => s + w.levels.length * 3, 0); } function isWorldUnlocked(world) { if (!world.unlockStars) return true; // World 1 always unlocked return getTotalStars() >= world.unlockStars; } export default function WorldMap({ onSelectLevel, onSandbox, onAdmin }) { const totalStars = getTotalStars(); const maxStars = getMaxStars(); return (
{/* Header */}
~

SynthQuest

Aprende sintesis modular resolviendo puzzles

{totalStars}/{maxStars}
{onAdmin && ( )}
{/* All worlds */} {worlds.map((world, worldIdx) => { const unlocked = isWorldUnlocked(world); const worldStars = world.levels.reduce((s, l) => { const p = getLevelProgress(l.id); return s + (p?.stars || 0); }, 0); const worldMaxStars = world.levels.length * 3; if (!unlocked) { return (
{world.icon}

Mundo {worldIdx + 1}: {world.name}

Consigue {world.unlockStars} estrellas para desbloquear ({totalStars}/{world.unlockStars})

🔒
); } return (
{world.icon}

Mundo {worldIdx + 1}: {world.name}

{world.subtitle}

{worldStars}/{worldMaxStars}
{world.levels.map((level, idx) => { const progress = getLevelProgress(level.id); const levelUnlocked = isLevelUnlocked(level.id, world.levels); const stars = progress?.stars || 0; const isBoss = idx === world.levels.length - 1; return (
levelUnlocked && onSelectLevel(level, world)} >
{idx + 1}

{level.title}

{level.subtitle}

{levelUnlocked ? ( ) : ( 🔒 )} {!levelUnlocked &&
}
); })}
); })}
); }