-
Notifications
You must be signed in to change notification settings - Fork 5
/
rpg.js
41 lines (32 loc) · 1.03 KB
/
rpg.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
'use strict';
const config = require('./config');
const RPG = require('./types/rpg');
const Server = require('@fabric/http');
async function main () {
let server = new Server(config);
let rpg = new RPG({
path: './stores/rpg'
});
// For our main loop, we want to monitor the game world
// and present some output to the user. Here, we catch
// events from the server (our trusted oracle) as well
// as the local RPG instance. Both will stay in sync!
server.on('info', function (msg) {
console.log('server info:', msg);
});
rpg.on('info', function (msg) {
console.log('rpg info:', msg);
});
// Finally, launch our processes. The server will manage
// connections with the rest of the network, while any of
// your clients will now be able to connect.
await server.start();
await rpg.start();
// Let's register with the network.
let player = await rpg._registerPlayer({
name: process.env['PLAYER_HANDLE'] || 'admin'
});
console.log('rpg:', rpg);
console.log('player:', player);
}
main();