const GAME_FW_SET = new Set(['unity', 'godot', 'unreal', 'bevy', 'phaser', 'pygame']);
/**
 * Returns true if the project is a game that needs game-specific tests.
 */
export function isGameProject(knowledge) {
    if (knowledge.projectCategory === 'game') {
        return true;
    }
    return knowledge.framework !== null && GAME_FW_SET.has(knowledge.framework);
}
/**
 * Generate game-specific test definitions: logic, systems integration, and performance.
 */
export function generateGameTestDefs(title, testDir, knowledge) {
    const engine = knowledge.framework ?? 'unknown';
    const defs = [
        {
            name: `${title} — game logic unit tests`,
            type: 'unit',
            file: `${testDir}/unit/game-logic/`,
            description: `Test core game logic: state machines, score calculation, lives/respawn (${engine})`,
            priority: 'critical',
            automatable: true,
        },
        {
            name: `${title} — system integration tests`,
            type: 'integration',
            file: `${testDir}/integration/systems/`,
            description: `Test interactions between game systems: physics+animation, inventory+combat, save+load`,
            priority: 'high',
            automatable: true,
        },
        {
            name: `${title} — performance benchmarks`,
            type: 'unit',
            file: `${testDir}/performance/`,
            description: `Benchmark: 60fps with 1000 entities, memory < 200MB, load time < 3s`,
            priority: 'medium',
            automatable: true,
        },
    ];
    return defs;
}
/**
 * Generate game test file content scaffold.
 */
export function generateGameTestContent(title, engine, testFramework) {
    if (engine === 'unity') {
        return generateUnityTestContent(title);
    }
    if (engine === 'godot') {
        return generateGodotTestContent(title);
    }
    if (engine === 'bevy' || engine === 'unreal') {
        return generateRustCppTestContent(title, engine);
    }
    return generateJSGameTestContent(title, testFramework);
}
function getGameTestExt(engine) {
    const extMap = {
        unity: 'cs',
        godot: 'gd',
        unreal: 'cpp',
        bevy: 'rs',
        phaser: 'ts',
        pygame: 'py',
    };
    return extMap[engine] ?? 'ts';
}
function generateUnityTestContent(title) {
    return [
        'using NUnit.Framework;',
        'using UnityEngine.TestTools;',
        '',
        '[TestFixture]',
        `public class ${sanitizeTitle(title)}Tests {`,
        '    [Test]',
        '    public void CoreGameLogic_ShouldWork() {',
        '        // Arrange',
        '        // Act',
        '        // Assert',
        '        Assert.Pass();',
        '    }',
        '',
        '    [Test]',
        '    public void SaveSystem_ShouldPersistData() {',
        '        // Test save/load round-trip',
        '        Assert.Pass();',
        '    }',
        '}',
    ].join('\n');
}
function generateGodotTestContent(title) {
    return [
        'extends GutTest',
        '',
        `func test_${sanitizeTitle(title).toLowerCase()}_core_logic():`,
        '    # Arrange',
        '    # Act',
        '    # Assert',
        '    pass',
        '',
        'func test_save_system():',
        '    # Test save/load round-trip',
        '    pass',
    ].join('\n');
}
function generateRustCppTestContent(title, engine) {
    if (engine === 'bevy') {
        return [
            '#[cfg(test)]',
            'mod tests {',
            '    use super::*;',
            '    use bevy::prelude::*;',
            '',
            '    #[test]',
            `    fn test_${sanitizeTitle(title).toLowerCase()}_core_logic() {`,
            '        // Arrange',
            '        // Act',
            '        // Assert',
            '    }',
            '}',
        ].join('\n');
    }
    return [
        `// ${title} Tests (Unreal)`,
        '#include "CoreMinimal.h"',
        '#include "Misc/AutomationTest.h"',
        '',
        `IMPLEMENT_SIMPLE_AUTOMATION_TEST(F${sanitizeTitle(title)}Test, "Game.${sanitizeTitle(title)}", EAutomationTestFlags::ApplicationContextMask | EAutomationTestFlags::SmokeFilter)`,
        `bool F${sanitizeTitle(title)}Test::RunTest(const FString& Parameters) {`,
        '    // Test implementation',
        '    return true;',
        '}',
    ].join('\n');
}
function generateJSGameTestContent(title, testFramework) {
    const isVitest = testFramework === 'vitest';
    return [
        isVitest
            ? "import { describe, it, expect } from 'vitest';"
            : "import { describe, it, expect } from '@jest/globals';",
        '',
        `describe('${title} — Game Logic', () => {`,
        "  it('should handle core game loop correctly', () => {",
        '    // Arrange',
        '    // Act',
        '    // Assert',
        '    expect(true).toBe(true);',
        '  });',
        '',
        "  it('should maintain 60fps with 1000 entities', () => {",
        '    const start = performance.now();',
        '    // Simulate 1000 entity updates',
        '    const elapsed = performance.now() - start;',
        '    expect(elapsed).toBeLessThan(16.67); // 60fps budget',
        '  });',
        '});',
    ].join('\n');
}
function sanitizeTitle(title) {
    return title.replace(/[^a-zA-Z0-9]/g, '').replace(/^\d+/, '');
}
// Export ext helper for potential external use; suppress unused-locals for internal callers
export { getGameTestExt };
//# sourceMappingURL=game-tests-generator.js.map