-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathengine.js
43 lines (35 loc) · 1.18 KB
/
engine.js
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
/* Server client game core */
const Sockets = require('./networking/sockets.js');
const Players = require('./networking/players.js');
const Producer =require('./networking/producer.js');
const JSONLoader = require('./internal/jsonloader.js');
const i18next = require('i18next');
class Engine {
constructor(io, configuration, languages, server_language) {
this.io = io;
this.config = configuration;
this.languages = languages;
this.default_language = server_language;
this.sockets = new Sockets(io, this);
this.players = new Players(this);
this.loader = new JSONLoader(
configuration.getConfig('core_directory'),
configuration.getConfig('custom_directory')
);
this.producer = new Producer(this, this.sockets, this.loader);
}
run() {
console.info(i18next.t('server.engine.starting'));
this.producer.loadGraphics();
this.producer.loadFonts();
this.producer.loadColors();
this.producer.loadBasicScenes();
this.producer.loadScenarios();
console.info(i18next.t('server.engine.started'));
}
// Create a new player upon connection. Socket is an instance of networking/socket
onConnection(socket) {
this.players.newPlayer(socket);
}
}
module.exports = Engine;