-
Notifications
You must be signed in to change notification settings - Fork 0
/
server.js
88 lines (68 loc) · 2.36 KB
/
server.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
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
87
88
/*TODO
* PRetty much everything. Learn react, form a canvas, figure out collision between player and enemies
* Implement random encounters
*/
'use strict';
require('./tgbot.js');
const player = require('./player.js');
const command = require('./command.js');
var config = require('./config.js');
var playerDB = require('./playerDB.js');
var commandDB = require('./commandDB.js');
var http = require('http');
const { tgcommands } = require('./tgbot.js');
var port = process.env.PORT || 1337;
/*
var playerDatabase = new playerDB(config.databaseInfo[0], config.databaseInfo[1], config.databaseInfo[2], config.databaseInfo[3]);
var commandDatabase = new commandDB(config.databaseInfo[0], config.databaseInfo[1], config.databaseInfo[2], config.databaseInfo[3]);
playerDatabase.openDB(true);
*/
function everyFiveSeconds() {
config.allPlayers.forEach(function (element) {
element.heal(1);
});
}
function everyMinute() {
if (config.allPlayers[0] != null) {
config.playerDatabase.updatePlayersBatch(config.playerDatabase.playerObjectToArray(config.allPlayers));
config.allPlayers.forEach(function (element) {
element.heal(3);
});
}
if (allCommands[0] != null) {
config.commandDatabase.updateCommandsBatch(config.commandDatabase.commandObjectToArray(allCommands));
}
}
function everyFiveMinutes() {
config.allPlayers.forEach(function (element) {
element.heal(10);
});
}
function everyTenMinutes() {
config.allPlayers.forEach(function (element) {
if (element.availableFights < 6) {
element.availableFights++;
};
});
}
function everyHour() {
config.allPlayers.forEach(function (element) {
element.addXP(500);
element.addCoin(50);
if (element.availablePlayerFights < 3) {
element.availablePlayerFights++;
};
});
}
setInterval(everyFiveSeconds, 5000);
setInterval(everyMinute, 60000);
setInterval(everyFiveMinutes, 300000);
setInterval(everyTenMinutes, 600000);
setInterval(everyHour, 3600000);
http.createServer(function (req, res) {
const newPlayer = new player("Jared", "Master", 0, 0, 1);
config.allPlayers.forEach(function (element) {
res.write(`${element.name} the ${element.level} level ${element.charClass}\n`);
});
res.end('\nres.end line\n');
}).listen(port);