const express = require('express');
const path = require('path');

/**
 * LetterQuest Game Server Module
 * Single-player word search game - no socket.io needed
 */
module.exports = function(ioInstance, appInstance) {
    const router = express.Router();
    
    // Serve static files for LetterQuest
    if (appInstance) {
        router.use(express.static(path.join(__dirname, '../public')));
        appInstance.use('/games/letterquest', router);
    }
    
    console.log('LetterQuest game mounted at /games/letterquest');
    
    return router;
};

// Standalone execution (if needed for development)
if (require.main === module) {
    const app = express();
    const http = require('http');
    const server = http.createServer(app);
    
    app.use(express.static(path.join(__dirname, '../public')));
    
    const PORT = process.env.PORT || 3004;
    server.listen(PORT, () => {
        console.log(`LetterQuest standalone server listening on *:${PORT}`);
    });
}
