-
Notifications
You must be signed in to change notification settings - Fork 7
Expand file tree
/
Copy pathindex.js
More file actions
57 lines (48 loc) · 1.54 KB
/
index.js
File metadata and controls
57 lines (48 loc) · 1.54 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
var app = require('express')()
var fs = require('fs')
var vm = require('vm')
var http = require('http').Server(app)
var io = require('socket.io')(http)
var path = require('path')
var config = require('./jsconfig')
module.exports.app = app
module.exports.fs = fs
module.exports.vm = vm
module.exports.http = http
module.exports.io = io
app.get('/', function (req, res) {
res.sendFile(path.join(__dirname, '/public/index.html'))
})
app.get('/main.js', function (req, res) {
res.sendFile(path.join(__dirname, '/public/main.js'))
})
app.get('/base64images.js', function (req, res) {
res.sendFile(path.join(__dirname, '/public/base64images.js'))
})
app.get('/styles.css', function (req, res) {
res.sendFile(path.join(__dirname, '/public/styles.css'))
})
app.get('/socket.io.js', function (req, res) {
res.sendFile(path.join(__dirname, '/public/socket.io.js'))
})
app.get('/jquery-2.2.4.min.js', function (req, res) {
res.sendFile(path.join(__dirname, '/public/jquery-2.2.4.min.js'))
})
let options = config.options
// parse commandline args
var commandlineArgs = {}
for (var i = 2; i < process.argv.length; i++) {
if (process.argv[i].indexOf('=')) {
var keyValue = process.argv[i].split('=')
keyValue[1] = parseInt(keyValue[1], 10) || keyValue[1] // if int change to int
commandlineArgs[keyValue[0]] = keyValue[1]
}
}
for (let key in commandlineArgs) {
options[key] = commandlineArgs[key]
}
module.exports.options = options
// create new game
var Game = require('./src/game')
var g = new Game('maps/' + options.map)
module.exports.Game = g