-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathinteractive-config.js
More file actions
86 lines (72 loc) · 2.51 KB
/
interactive-config.js
File metadata and controls
86 lines (72 loc) · 2.51 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
// Simple Server Configuration
const readline = require('readline');
const rl = readline.createInterface({
input: process.stdin,
output: process.stdout
});
// Helper functions
function askQuestion(question) {
return new Promise((resolve) => {
rl.question(question, resolve);
});
}
function askYesNo(question, defaultValue = true) {
const defaultText = defaultValue ? 'Y/n' : 'y/N';
return askQuestion(`${question} (${defaultText}): `).then(answer => {
if (answer.trim() === '') return defaultValue;
return answer.toLowerCase().startsWith('y');
});
}
async function runInteractiveConfig() {
try {
console.log('\n🎮 MMCOS Server Configuration');
console.log('==============================');
console.log();
console.log('Configure the server settings that actually matter:');
console.log();
// Ask for the settings that actually affect gameplay
const maxPlayers = parseInt(await askQuestion('Maximum players per game [8]: ')) || 8;
const aiEnabled = await askYesNo('Enable AI opponents', true);
const allowSpectators = await askYesNo('Allow spectators', true);
const config = {
name: "MMCOS Community Server",
description: "Community server with custom settings",
settings: {
maxPlayers: maxPlayers,
aiEnabled: aiEnabled,
allowSpectators: allowSpectators,
// Fixed sensible defaults for everything else
rankedWithAI: true,
debugMode: false,
seasonSystem: true,
forceGameType: null,
competitiveMode: false
}
};
console.log('\n📋 Server Configuration:');
console.log('========================');
console.log(`Max Players: ${config.settings.maxPlayers}`);
console.log(`AI Opponents: ${config.settings.aiEnabled ? 'Enabled' : 'Disabled'}`);
console.log(`Spectators: ${config.settings.allowSpectators ? 'Allowed' : 'Disabled'}`);
const confirm = await askYesNo('\nStart server with this configuration', true);
if (!confirm) {
console.log('❌ Configuration cancelled');
rl.close();
process.exit(0);
}
rl.close();
// Set environment variables for main server
process.env.SERVER_CONFIG = JSON.stringify(config);
console.log('\n🚀 Starting server...\n');
// Start the main server
require('./server.js');
} catch (error) {
console.error('❌ Configuration error:', error.message);
rl.close();
process.exit(1);
}
}
// Export for use in other modules
module.exports = {
runInteractiveConfig
};