from src.game_info import GameInfo
from src.game_launchers import *

def get_game_registry(configs):
    registry = []

    launcher_map = {
        "Minecraft: Java Edition": JavaLauncher,
        "Minecraft: Bedrock Edition": BedrockLauncher,
        "Minecraft Dungeons": lambda g, c: SteamLauncher(g, c),
        "Minecraft Legends": lambda g, c: SteamLauncher(g, c),
        "Minecraft: Story Mode": lambda g, c: SteamLauncher(g, c) if c.get("version") == "steam" else LutrisLauncher(g, c),
        "Minecraft Story Mode: Season 2": lambda g, c: SteamLauncher(g, c) if c.get("version") == "steam" else LutrisLauncher(g, c),
        "Minecraft: Xbox 360 Edition": Xbox360Launcher,
        "Minecraft Classic": WebLauncher,
        "Terraria": lambda g, c: SteamLauncher(g, c),
        "Vintage Story": lambda g, c: FlatpakLauncher(g, c) if c.get("type") == "flatpak" else NativeLauncher(g, c),
        "Luanti": lambda g, c: FlatpakLauncher(g, c) if c.get("type") == "flatpak" else NativeLauncher(g, c),
        "ClassiCube": NativeLauncher,
        # "Hytale": NativeLauncher
    }

    for name, cfg in configs.items():
        if not isinstance(cfg, dict):
            continue

        if not cfg.get("show", False):
            continue

        launcher_cls = launcher_map.get(name)
        if not launcher_cls:
            continue

        info = GameInfo(name, cfg.get("image_path", None), cfg.get("icon_path", None))
        game_launcher = launcher_cls(info, cfg)
        registry.append((info, game_launcher))
    return registry
