// tools/define-ui-contract-games.ts — Game UI contract generation (SPEC-014a)
// Generates UI contracts for game projects: HUD elements, menus, inventory, minimap.
const GAME_FW_SET = new Set(['unity', 'godot', 'unreal', 'bevy', 'phaser', 'pygame']);
/**
 * Returns true if the project is a game based on framework or category.
 */
export function isGameProject(knowledge) {
    if (knowledge.projectCategory === 'game') {
        return true;
    }
    return knowledge.framework !== null && GAME_FW_SET.has(knowledge.framework);
}
/**
 * Generate a game UI contract with HUD, menus, inventory, and dialog components.
 */
export function generateGameUIContract(screens, knowledge) {
    const engine = knowledge.framework ?? 'unknown';
    const engineTitle = engine.charAt(0).toUpperCase() + engine.slice(1);
    const components = buildGameComponents(screens, engine);
    const lines = [
        `## Game UI Contract — ${engineTitle}`,
        '',
        '### HUD (Heads-Up Display)',
        ...buildHUDSection(engine),
        '',
        '### Menus',
        ...buildMenusSection(screens),
        '',
        '### Inventory & Items',
        ...buildInventorySection(),
        '',
        '### Dialog & Notification System',
        ...buildDialogSection(),
        '',
        '### Component Tree',
        '```json',
        JSON.stringify(components, null, 2),
        '```',
    ];
    return lines.join('\n');
}
function buildHUDSection(engine) {
    const isBrowser = engine === 'phaser';
    const prefix = isBrowser ? 'DOM/Canvas' : 'Scene';
    return [
        `- **HealthBar** (${prefix}): current/max HP, animated fill, color thresholds`,
        `- **MiniMap** (${prefix}): player position, enemies, objectives overlay`,
        `- **ScoreDisplay** (${prefix}): points counter, combo multiplier, high score`,
        `- **AbilityBar** (${prefix}): cooldown timers, active/inactive states, hotkeys`,
        `- **ResourceCounters** (${prefix}): ammo/mana/stamina with icon + value`,
    ];
}
function buildMenusSection(screens) {
    const menuScreens = screens.filter((s) => s.toLowerCase().includes('menu') || s.toLowerCase().includes('pause'));
    const lines = [
        '- **MainMenu**: Play, Continue, Settings, Credits, Quit buttons',
        '- **PauseMenu**: Resume, Settings, Save, Main Menu — overlay on gameplay',
        '- **SettingsMenu**: Audio (master/music/sfx), Graphics (quality/resolution), Controls',
        '- **GameOverScreen**: Score, Best Score, Retry, Main Menu',
        '- **VictoryScreen**: Score breakdown, stars/grade, Next Level, Replay',
    ];
    for (const screen of menuScreens) {
        const normalized = screen.toLowerCase().replace(/[-_\s]/g, '');
        if (normalized !== 'mainmenu' && normalized !== 'pausemenu') {
            lines.push(`- **${screen}**: custom screen from spec`);
        }
    }
    return lines;
}
function buildInventorySection() {
    return [
        '- **InventoryGrid**: NxM slot grid, item stacking, drag-and-drop',
        '- **ItemSlot**: icon, quantity badge, durability bar, rarity color border',
        '- **ItemTooltip**: name, description, stats comparison, use/equip button',
        '- **EquipmentSlots**: character paper-doll with named equipment slots',
        '- **Hotbar**: 1-9 quick access slots with keyboard bindings',
    ];
}
function buildDialogSection() {
    return [
        '- **DialogBox**: NPC portrait, speaker name, dialog text with typewriter effect',
        '- **ChoiceDialog**: dialog text + up to 4 selectable response options',
        '- **NotificationToast**: achievement/item obtained banners (auto-dismiss 3s)',
        '- **ConfirmationModal**: destructive action confirmation (delete save, quit)',
    ];
}
function buildGameComponents(screens, engine) {
    const hudChildren = [
        {
            name: 'HealthBar',
            type: 'client',
            justification: 'Reactive HUD element that updates on player health changes',
            props: [
                { name: 'current', type: 'number', required: true, description: 'Current HP value' },
                { name: 'max', type: 'number', required: true, description: 'Maximum HP value' },
            ],
            children: [],
        },
        {
            name: 'ScoreDisplay',
            type: 'client',
            justification: 'Animated score counter that reacts to score events',
            props: [
                { name: 'score', type: 'number', required: true, description: 'Current score' },
                {
                    name: 'animated',
                    type: 'boolean',
                    required: false,
                    description: 'Enable count-up animation',
                },
            ],
            children: [],
        },
        {
            name: 'MiniMap',
            type: 'client',
            justification: 'Renders live map overlay with player and entity positions',
            props: [
                {
                    name: 'size',
                    type: 'number',
                    required: false,
                    description: 'Minimap display size in px',
                },
            ],
            children: [],
        },
    ];
    const menuChildren = screens.map((s) => ({
        name: s,
        type: 'client',
        justification: 'Game screen rendered as interactive client component',
        props: [],
        children: [],
    }));
    return [
        {
            name: 'GameCanvas',
            type: 'client',
            justification: `Root ${engine} game canvas — all rendering is client-side`,
            props: [
                { name: 'engine', type: 'string', required: true, description: 'Game engine identifier' },
                {
                    name: 'fullscreen',
                    type: 'boolean',
                    required: false,
                    description: 'Launch in fullscreen mode',
                },
            ],
            children: [
                {
                    name: 'HUDLayer',
                    type: 'client',
                    justification: 'Overlay layer rendered above the game world at fixed z-index',
                    props: [
                        {
                            name: 'zIndex',
                            type: 'number',
                            required: false,
                            description: 'CSS/canvas layer order',
                        },
                    ],
                    children: hudChildren,
                },
                {
                    name: 'MenuLayer',
                    type: 'client',
                    justification: 'Overlay layer for all game menus, above HUD',
                    props: [
                        {
                            name: 'zIndex',
                            type: 'number',
                            required: false,
                            description: 'CSS/canvas layer order',
                        },
                    ],
                    children: menuChildren,
                },
            ],
        },
    ];
}
//# sourceMappingURL=define-ui-contract-games.js.map