mirror of
https://github.com/clusterio/clusterio.git
synced 2026-11-11 23:04:52 +09:00
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
999c1b6c7a | ||
|
|
61b1b1a106 | ||
|
|
8b4ec58459 | ||
|
|
6e26d32fed | ||
|
|
74d9ec38dc | ||
|
|
dbef2bd2b3 | ||
|
|
e0b521d2fe | ||
|
|
9a032aed2e | ||
|
|
72b56a00c7 | ||
|
|
c25bf23286 | ||
|
|
9e983aff84 | ||
|
|
8973dcc6dd | ||
|
|
475128c8c4 | ||
|
|
0cdb5d0ce4 | ||
|
|
075d54f708 | ||
|
|
62f3a99feb | ||
|
|
3b1ed1a667 | ||
|
|
6a6274e85c | ||
|
|
a9cc743106 | ||
|
|
2a7758f60d | ||
|
|
7e2ca58a59 | ||
|
|
718d4ed659 | ||
|
|
6b090cddbe | ||
|
|
56c023f643 | ||
|
|
78de7236c5 | ||
|
|
97c7a69c7a | ||
|
|
0c45e57732 | ||
|
|
88eff17dfd | ||
|
|
e1374d501e |
No files matched your search
+1
-1
@@ -1,6 +1,6 @@
|
|||||||
language: node_js
|
language: node_js
|
||||||
node_js:
|
node_js:
|
||||||
- "9"
|
- 10
|
||||||
before_install:
|
before_install:
|
||||||
- sudo apt-get -qq update
|
- sudo apt-get -qq update
|
||||||
- sudo apt-get install -y curl git tar
|
- sudo apt-get install -y curl git tar
|
||||||
|
|||||||
@@ -0,0 +1,41 @@
|
|||||||
|
Changelog
|
||||||
|
=========
|
||||||
|
|
||||||
|
Version 1.2.2
|
||||||
|
-------------
|
||||||
|
|
||||||
|
- Fixed possible crash with modded technologies named the same as a built-in
|
||||||
|
Object prototype property in researchSync.
|
||||||
|
- Fixed progress of a current infinite tech carrying over to the next one
|
||||||
|
when researching it and another node completes it in researchSync.
|
||||||
|
- Fixed progress of a previous infinite tech from another node being applied
|
||||||
|
to the current one in researchSync.
|
||||||
|
- Fixed crash in researchSync when modded technologies are present only on some
|
||||||
|
nodes.
|
||||||
|
- Fixed install failing due to bcrypt version less than 3 not being supported
|
||||||
|
on node v10.
|
||||||
|
- Reordered install instructions to avoid problem with npm creating files owned
|
||||||
|
by root in the home directory.
|
||||||
|
- Swapped curl out with wget in the install instructions as the latter comes
|
||||||
|
pre-installed on Ubuntu.
|
||||||
|
|
||||||
|
### Breaking Changes
|
||||||
|
|
||||||
|
- Node.js versions below 10 are no longer supported.
|
||||||
|
|
||||||
|
|
||||||
|
Version 1.2.1
|
||||||
|
-------------
|
||||||
|
|
||||||
|
- Updated node-factorio-api to v0.3.8 to fix mod downloads randomly breaking
|
||||||
|
([#229][#229].)
|
||||||
|
- Fixed SIGINT being sent twice to Factorio server when interrupted by CTRL+C
|
||||||
|
on Linux ([#217][#217].)
|
||||||
|
- Fixed package.json incorrectly reporting the license as ISC.
|
||||||
|
|
||||||
|
[#217]: https://github.com/clusterio/factorioClusterio/issues/217
|
||||||
|
[#229]: https://github.com/clusterio/factorioClusterio/issues/229
|
||||||
|
|
||||||
|
### Breaking Changes
|
||||||
|
|
||||||
|
- Added authentication to the socket.io server running on the master.
|
||||||
+1
-1
@@ -1,4 +1,4 @@
|
|||||||
FROM node:9.11.2
|
FROM node:10
|
||||||
RUN apt-get update && apt install git curl tar -y
|
RUN apt-get update && apt install git curl tar -y
|
||||||
RUN mkdir factorioClusterio
|
RUN mkdir factorioClusterio
|
||||||
|
|
||||||
|
|||||||
@@ -8,6 +8,13 @@
|
|||||||
|
|
||||||
Discord for development/support/play: https://discord.gg/5XuDkje
|
Discord for development/support/play: https://discord.gg/5XuDkje
|
||||||
|
|
||||||
|
## Important notice
|
||||||
|
|
||||||
|
This is the stable branch of the project. The
|
||||||
|
[master branch][http://github.com/clusterio/factorioClusterio/tree/master]
|
||||||
|
is undergoing significant changes that breaks compatibility to plugins and
|
||||||
|
existing installations and is not recommended for use.
|
||||||
|
|
||||||
### Ways to support me/the project:
|
### Ways to support me/the project:
|
||||||
|
|
||||||
* Contribute with code/documentation. Always nice to move the project forward
|
* Contribute with code/documentation. Always nice to move the project forward
|
||||||
@@ -88,19 +95,21 @@ NodeJS does not support EOL ubuntu releases. Make sure you are on the most recen
|
|||||||
|
|
||||||
Master and all slaves:
|
Master and all slaves:
|
||||||
|
|
||||||
sudo curl -sL https://deb.nodesource.com/setup_9.x | sudo -E bash -
|
wget -qO - https://deb.nodesource.com/setup_10.x | sudo -E bash -
|
||||||
sudo apt install -y nodejs python-dev git wget curl tar build-essential
|
sudo apt install -y nodejs python-dev git build-essential
|
||||||
sudo npm install pm2 -g
|
git clone -b 1.2.x https://github.com/Danielv123/factorioClusterio.git
|
||||||
git clone https://github.com/Danielv123/factorioClusterio.git
|
|
||||||
cd factorioClusterio
|
cd factorioClusterio
|
||||||
curl -o factorio.tar.gz -L https://www.factorio.com/get-download/latest/headless/linux64
|
wget -O factorio.tar.gz https://www.factorio.com/get-download/latest/headless/linux64
|
||||||
tar -xf factorio.tar.gz
|
tar -xf factorio.tar.gz
|
||||||
npm install --only=production
|
npm install --only=production
|
||||||
cp config.json.dist config.json
|
cp config.json.dist config.json
|
||||||
node ./lib/npmPostinstall.js
|
node ./lib/npmPostinstall.js
|
||||||
|
|
||||||
|
downloads and installs nodejs, git and clusterio. To specify a version, change "latest" in the link to a version number like 0.14.21.
|
||||||
|
|
||||||
downloads and installs nodejs, pm2, git and clusterio. To specify a version, change "latest" in the link to a version number like 0.14.21.
|
Optional step (if you want to use pm2):
|
||||||
|
|
||||||
|
sudo npm install pm2 -g
|
||||||
|
|
||||||
Now you need to edit the `config.json` file. If you skip this step nothing will work.
|
Now you need to edit the `config.json` file. If you skip this step nothing will work.
|
||||||
Pretty much all the blank fields should be filled in, except on the master where a few can be omitted.
|
Pretty much all the blank fields should be filled in, except on the master where a few can be omitted.
|
||||||
@@ -113,11 +122,12 @@ Pretty much all the blank fields should be filled in, except on the master where
|
|||||||
|
|
||||||
**Master**
|
**Master**
|
||||||
|
|
||||||
|
node master.js
|
||||||
|
|
||||||
|
Or with pm2 (it's recommened to run it without pm2 first):
|
||||||
|
|
||||||
pm2 start master.js --name master
|
pm2 start master.js --name master
|
||||||
|
|
||||||
OR
|
|
||||||
|
|
||||||
node master.js
|
|
||||||
|
|
||||||
**Server Host**
|
**Server Host**
|
||||||
|
|
||||||
@@ -159,7 +169,7 @@ Game Client = The people connecting to the server
|
|||||||
|
|
||||||
**Requirements**
|
**Requirements**
|
||||||
|
|
||||||
download and install nodeJS 8 or 9 from http://nodejs.org
|
download and install nodeJS 10 from http://nodejs.org
|
||||||
|
|
||||||
download and install git from https://git-scm.com/
|
download and install git from https://git-scm.com/
|
||||||
|
|
||||||
|
|||||||
@@ -53,6 +53,8 @@ if(!config.masterAuthToken || typeof config.masterAuthToken !== "string"){
|
|||||||
console.error("Master server now needs an access token for write operations. As clusterio slaves depends \
|
console.error("Master server now needs an access token for write operations. As clusterio slaves depends \
|
||||||
upon this, please add your token to config.json in the field named masterAuthToken. \
|
upon this, please add your token to config.json in the field named masterAuthToken. \
|
||||||
You can retrieve your auth token from the master in secret-api-token.txt after running it once.");
|
You can retrieve your auth token from the master in secret-api-token.txt after running it once.");
|
||||||
|
process.exitCode = 1;
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
const needleOptionsWithTokenAuthHeader = {
|
const needleOptionsWithTokenAuthHeader = {
|
||||||
compressed:true,
|
compressed:true,
|
||||||
@@ -359,7 +361,8 @@ write-data=${ path.resolve(config.instanceDirectory, instance) }\r\n
|
|||||||
'--rcon-port', Number(process.env.RCONPORT) || instconf.clientPort,
|
'--rcon-port', Number(process.env.RCONPORT) || instconf.clientPort,
|
||||||
'--rcon-password', instconf.clientPassword,
|
'--rcon-password', instconf.clientPassword,
|
||||||
], {
|
], {
|
||||||
'stdio': ['pipe', 'pipe', 'pipe']
|
'stdio': ['pipe', 'pipe', 'pipe'],
|
||||||
|
'detached': process.platform === "linux",
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
factorio.stdout.on("data", data => {
|
factorio.stdout.on("data", data => {
|
||||||
@@ -471,7 +474,8 @@ write-data=${ path.resolve(config.instanceDirectory, instance) }\r\n
|
|||||||
'--server-settings', instancedirectory + '/server-settings.json',
|
'--server-settings', instancedirectory + '/server-settings.json',
|
||||||
'--port', args.port || Number(process.env.FACTORIOPORT) || instanceconfig.factorioPort
|
'--port', args.port || Number(process.env.FACTORIOPORT) || instanceconfig.factorioPort
|
||||||
], {
|
], {
|
||||||
'stdio': ['pipe', 'pipe', 'pipe']
|
'stdio': ['pipe', 'pipe', 'pipe'],
|
||||||
|
'detached': process.platform === "linux",
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
@@ -570,7 +574,10 @@ async function instanceManagement(instanceconfig) {
|
|||||||
console.log("Started instanceManagement();");
|
console.log("Started instanceManagement();");
|
||||||
|
|
||||||
/* Open websocket connection to master */
|
/* Open websocket connection to master */
|
||||||
var socket = ioClient("http://"+config.masterIP+":"+config.masterPort);
|
var socket = ioClient("http://"+config.masterIP+":"+config.masterPort+"?token="+config.masterAuthToken);
|
||||||
|
socket.on("error", err => {
|
||||||
|
console.log("SOCKET | Error: ", err);
|
||||||
|
});
|
||||||
socket.on("hello", data => {
|
socket.on("hello", data => {
|
||||||
console.log("SOCKET | registering slave!");
|
console.log("SOCKET | registering slave!");
|
||||||
socket.emit("registerSlave", {
|
socket.emit("registerSlave", {
|
||||||
|
|||||||
+1
-1
@@ -14,7 +14,7 @@
|
|||||||
"masterPort": 8080,
|
"masterPort": 8080,
|
||||||
|
|
||||||
"__commentsslPort": "HTTPS port for the master to listen to. Set to 0 or an empty string to not listen for HTTPS.",
|
"__commentsslPort": "HTTPS port for the master to listen to. Set to 0 or an empty string to not listen for HTTPS.",
|
||||||
"sslPort": 443,
|
"sslPort": 0,
|
||||||
"sslCert": "database/certificates/cert.crt",
|
"sslCert": "database/certificates/cert.crt",
|
||||||
"sslPrivKey": "database/certificates/cert.key",
|
"sslPrivKey": "database/certificates/cert.key",
|
||||||
|
|
||||||
|
|||||||
@@ -921,6 +921,18 @@ class wsSlave {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
io.use((socket, next) => {
|
||||||
|
let token = socket.handshake.query.token;
|
||||||
|
authenticate.check(token).then((result) => {
|
||||||
|
if (result.ok) {
|
||||||
|
next();
|
||||||
|
} else {
|
||||||
|
console.error(`SOCKET | authentication failed for ${socket.handshake.address}`);
|
||||||
|
next(new Error(result.msg));
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
io.on('connection', function (socket) {
|
io.on('connection', function (socket) {
|
||||||
// cleanup dead sockets from disconnected people
|
// cleanup dead sockets from disconnected people
|
||||||
let terminatedConnections = 0;
|
let terminatedConnections = 0;
|
||||||
|
|||||||
+7
-4
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "clusterio",
|
"name": "clusterio",
|
||||||
"version": "1.7.0",
|
"version": "1.2.2",
|
||||||
"description": "Interserver communication for factorio",
|
"description": "Interserver communication for factorio",
|
||||||
"repository": "https://github.com/Danielv123/factorioClusterio",
|
"repository": "https://github.com/Danielv123/factorioClusterio",
|
||||||
"main": "master.js",
|
"main": "master.js",
|
||||||
@@ -15,12 +15,15 @@
|
|||||||
"factorio"
|
"factorio"
|
||||||
],
|
],
|
||||||
"author": "Danielv123",
|
"author": "Danielv123",
|
||||||
"license": "ISC",
|
"license": "MIT",
|
||||||
|
"engines": {
|
||||||
|
"node": ">=10"
|
||||||
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"as-table": "^1.0.31",
|
"as-table": "^1.0.31",
|
||||||
"averaged-timeseries": "^1.4.0",
|
"averaged-timeseries": "^1.4.0",
|
||||||
"base64url": "^3.0.0",
|
"base64url": "^3.0.0",
|
||||||
"bcrypt": "^2.0.1",
|
"bcrypt": "^3.0.6",
|
||||||
"bcrypt-promise": "^2.0.0",
|
"bcrypt-promise": "^2.0.0",
|
||||||
"body-parser": "^1.18.2",
|
"body-parser": "^1.18.2",
|
||||||
"cli": "^1.0.1",
|
"cli": "^1.0.1",
|
||||||
@@ -46,7 +49,7 @@
|
|||||||
"moment": "^2.22.2",
|
"moment": "^2.22.2",
|
||||||
"ncp": "^2.0.0",
|
"ncp": "^2.0.0",
|
||||||
"needle": "^2.2.4",
|
"needle": "^2.2.4",
|
||||||
"node-factorio-api": "^0.3.5",
|
"node-factorio-api": "^0.3.8",
|
||||||
"node-forge": "^0.7.1",
|
"node-forge": "^0.7.1",
|
||||||
"prom-client": "^10.2.3",
|
"prom-client": "^10.2.3",
|
||||||
"rcon-client-fork": "^3.2.0",
|
"rcon-client-fork": "^3.2.0",
|
||||||
|
|||||||
@@ -11,15 +11,22 @@ local function updateTech()
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
if game.forces['player'].technologies['{tech_name}'] then
|
local force = game.forces['player']
|
||||||
|
local tech = force.technologies['{tech_name}']
|
||||||
|
if tech then
|
||||||
if 1 == {tech_infinite} then
|
if 1 == {tech_infinite} then
|
||||||
if (game.forces['player'].technologies['{tech_name}'].level ~= level) then
|
if (tech.level ~= level) then
|
||||||
game.forces['player'].technologies['{tech_name}'].level = {tech_level}
|
tech.level = {tech_level}
|
||||||
|
if tech == force.current_research then
|
||||||
|
force.research_progress = {tech_progress}
|
||||||
|
else
|
||||||
|
force.set_saved_technology_progress(tech.name, {tech_progress});
|
||||||
|
end
|
||||||
updateTech()
|
updateTech()
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
if not game.forces['player'].technologies['{tech_name}'].researched then
|
if not tech.researched then
|
||||||
game.forces['player'].technologies['{tech_name}'].researched = true
|
tech.researched = true
|
||||||
updateTech()
|
updateTech()
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -169,21 +169,24 @@ class ResearchSync {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
clear_contribution_to_researched_techs() {
|
clear_contribution_to_researched_techs() {
|
||||||
// if between updates tech was researched
|
for (let [name, tech] of Object.entries(this.research)) {
|
||||||
if (!this.prev_research)
|
if (!Object.hasOwnProperty.call(this.prev_research, name)) {
|
||||||
return
|
continue;
|
||||||
for (let [name, research] of Object.entries(this.research)) {
|
}
|
||||||
let researched
|
|
||||||
if (research.infinite)
|
|
||||||
researched = this.prev_research[name].level < research.level
|
|
||||||
else
|
|
||||||
researched = this.prev_research[name].researched < research.researched
|
|
||||||
|
|
||||||
if (researched)
|
let researched;
|
||||||
research.contribution = 0
|
if (tech.infinite) {
|
||||||
}
|
researched = this.prev_research[name].level < tech.level;
|
||||||
}
|
} else {
|
||||||
|
researched = this.prev_research[name].researched < tech.researched;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (researched) {
|
||||||
|
tech.contribution = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
get_cluster_techs(slavesData) {
|
get_cluster_techs(slavesData) {
|
||||||
let cluster_techs = {}
|
let cluster_techs = {}
|
||||||
@@ -193,7 +196,7 @@ class ResearchSync {
|
|||||||
if (isNaN(node_tech.researched) || isNaN(node_tech.level) || isNaN(node_tech.infinite))
|
if (isNaN(node_tech.researched) || isNaN(node_tech.level) || isNaN(node_tech.infinite))
|
||||||
continue
|
continue
|
||||||
|
|
||||||
if (cluster_techs[name]) {
|
if (Object.hasOwnProperty.call(cluster_techs, name)) {
|
||||||
if (cluster_techs[name].infinite === 1 && cluster_techs[name].level < node_tech.level) {
|
if (cluster_techs[name].infinite === 1 && cluster_techs[name].level < node_tech.level) {
|
||||||
cluster_techs[name].level = node_tech.level
|
cluster_techs[name].level = node_tech.level
|
||||||
} else if (node_tech.researched > cluster_techs[name].researched) {
|
} else if (node_tech.researched > cluster_techs[name].researched) {
|
||||||
@@ -208,65 +211,85 @@ class ResearchSync {
|
|||||||
}
|
}
|
||||||
|
|
||||||
recount_cluster_research_progress(slaves_data, cluster_researches) {
|
recount_cluster_research_progress(slaves_data, cluster_researches) {
|
||||||
for (let [name, research] of Object.entries(cluster_researches))
|
for (let [name, tech] of Object.entries(cluster_researches)) {
|
||||||
research.progress = this.research[name].contribution
|
if (Object.hasOwnProperty.call(this.research, name)) {
|
||||||
|
tech.progress = this.research[name].contribution
|
||||||
|
} else {
|
||||||
|
tech.progress = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
for (let slave_data of slaves_data) {
|
for (let slave_data of slaves_data) {
|
||||||
for (let [name, research] of Object.entries(slave_data.meta.research)) {
|
for (let [name, tech] of Object.entries(slave_data.meta.research)) {
|
||||||
if (!cluster_researches[name])
|
if (!Object.hasOwnProperty.call(cluster_researches, name)) {
|
||||||
continue
|
continue;
|
||||||
if (isNaN(cluster_researches[name].progress)
|
}
|
||||||
|| isNaN(research.contribution)
|
|
||||||
|| isNaN(research.level)
|
if (
|
||||||
|| isNaN(cluster_researches[name].level))
|
isNaN(cluster_researches[name].progress)
|
||||||
continue
|
|| isNaN(tech.contribution)
|
||||||
if (cluster_researches[name].level === research.level)
|
|| isNaN(tech.level)
|
||||||
cluster_researches[name].progress += research.contribution
|
|| isNaN(cluster_researches[name].level)
|
||||||
|
) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (cluster_researches[name].level === tech.level) {
|
||||||
|
cluster_researches[name].progress += tech.contribution;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for (let [name, research] of Object.entries(cluster_researches)) {
|
for (let [name, tech] of Object.entries(cluster_researches)) {
|
||||||
if (research.progress > 1) {
|
if (Object.hasOwnProperty.call(this.research, name) && tech.progress > 1) {
|
||||||
research.progress = null
|
tech.progress = null
|
||||||
research.researched = 1
|
tech.researched = 1
|
||||||
this.research[name].contribution = 0
|
this.research[name].contribution = 0
|
||||||
research.contribution = 0
|
tech.contribution = 0
|
||||||
if (this.research[name].level >= research.level)
|
if (this.research[name].level >= tech.level)
|
||||||
research.level = this.research[name].level + 1
|
tech.level = this.research[name].level + 1
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
filter_researched_techs(cluster_researches) {
|
filter_researched_techs(cluster_researches) {
|
||||||
let local_researches = this.research
|
|
||||||
let result = {};
|
let result = {};
|
||||||
for (let key in local_researches) {
|
for (let [name, tech] of Object.entries(this.research)) {
|
||||||
if (!cluster_researches[key])
|
if (!Object.hasOwnProperty.call(cluster_researches, name)) {
|
||||||
continue
|
continue;
|
||||||
if (isNaN(cluster_researches[key].researched) || isNaN(cluster_researches[key].level))
|
}
|
||||||
|
|
||||||
|
if (isNaN(cluster_researches[name].researched) || isNaN(cluster_researches[name].level))
|
||||||
continue
|
continue
|
||||||
|
|
||||||
let researched
|
let researched
|
||||||
if (local_researches[key].infinite)
|
if (tech.infinite) {
|
||||||
researched = local_researches[key].level < cluster_researches[key].level
|
researched = tech.level < cluster_researches[name].level;
|
||||||
else
|
} else {
|
||||||
researched = local_researches[key].researched < cluster_researches[key].researched
|
researched = tech.researched < cluster_researches[name].researched;
|
||||||
|
}
|
||||||
|
|
||||||
if (researched)
|
if (researched)
|
||||||
result[key] = cluster_researches[key]
|
result[name] = cluster_researches[name]
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
filter_updated_techs(cluster_techs, to_research) {
|
filter_updated_techs(cluster_techs, to_research) {
|
||||||
let local_techs = this.research
|
|
||||||
let result = {}
|
let result = {}
|
||||||
for (let name in local_techs) {
|
for (let [name, tech] of Object.entries(this.research)) {
|
||||||
if (name in to_research || !cluster_techs[name])
|
if (Object.hasOwnProperty.call(to_research, name) || !Object.hasOwnProperty.call(cluster_techs, name)) {
|
||||||
continue
|
continue;
|
||||||
|
}
|
||||||
if (isNaN(cluster_techs[name].progress))
|
if (isNaN(cluster_techs[name].progress))
|
||||||
continue
|
continue
|
||||||
if (local_techs[name].progress < cluster_techs[name].progress)
|
|
||||||
|
// Do not update progress for infinite techs with a local level that's higher.
|
||||||
|
if (tech.infinite && tech.level > cluster_techs[name].level) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (tech.progress < cluster_techs[name].progress)
|
||||||
result[name] = cluster_techs[name]
|
result[name] = cluster_techs[name]
|
||||||
}
|
}
|
||||||
return result
|
return result
|
||||||
@@ -274,8 +297,9 @@ class ResearchSync {
|
|||||||
|
|
||||||
research_technologies(to_research) {
|
research_technologies(to_research) {
|
||||||
for (let name of Object.keys(to_research))
|
for (let name of Object.keys(to_research))
|
||||||
if (!this.research[name])
|
if (!Object.hasOwnProperty.call(this.research, name)) {
|
||||||
delete to_research[name]
|
delete to_research[name];
|
||||||
|
}
|
||||||
|
|
||||||
const notify = Object.keys(to_research).length === 1
|
const notify = Object.keys(to_research).length === 1
|
||||||
for (let [name, tech] of Object.entries(to_research)) {
|
for (let [name, tech] of Object.entries(to_research)) {
|
||||||
@@ -283,9 +307,9 @@ class ResearchSync {
|
|||||||
this.research[name].progress = null
|
this.research[name].progress = null
|
||||||
let command = this.functions.enableResearch;
|
let command = this.functions.enableResearch;
|
||||||
command = command.replace(/{tech_name}/g, name);
|
command = command.replace(/{tech_name}/g, name);
|
||||||
command = command.replace(/{tech_researched}/g, tech.researched);
|
|
||||||
command = command.replace(/{tech_level}/g, tech.level);
|
command = command.replace(/{tech_level}/g, tech.level);
|
||||||
command = command.replace(/{tech_infinite}/g, tech.infinite);
|
command = command.replace(/{tech_infinite}/g, tech.infinite);
|
||||||
|
command = command.replace(/{tech_progress}/g, tech.progress)
|
||||||
command = command.replace(/{notify}/g, notify);
|
command = command.replace(/{notify}/g, notify);
|
||||||
this.messageInterface(command);
|
this.messageInterface(command);
|
||||||
let log_message = tech.infinite
|
let log_message = tech.infinite
|
||||||
@@ -299,8 +323,9 @@ class ResearchSync {
|
|||||||
|
|
||||||
update_technologies_progress(to_update) {
|
update_technologies_progress(to_update) {
|
||||||
for (let [name, tech] of Object.entries(to_update)) {
|
for (let [name, tech] of Object.entries(to_update)) {
|
||||||
if (!this.research[name])
|
if (!Object.hasOwnProperty.call(this.research, name)) {
|
||||||
continue
|
continue;
|
||||||
|
}
|
||||||
let progress = this.research[name].progress
|
let progress = this.research[name].progress
|
||||||
if (progress === null)
|
if (progress === null)
|
||||||
progress = 'nil'
|
progress = 'nil'
|
||||||
@@ -317,11 +342,10 @@ class ResearchSync {
|
|||||||
}
|
}
|
||||||
|
|
||||||
print_own_contribution() {
|
print_own_contribution() {
|
||||||
if (!this.prev_research)
|
|
||||||
return
|
|
||||||
for (let [name, tech] of Object.entries(this.research)) {
|
for (let [name, tech] of Object.entries(this.research)) {
|
||||||
if (!this.prev_research[name])
|
if (!Object.hasOwnProperty.call(this.prev_research, name)) {
|
||||||
continue
|
continue;
|
||||||
|
}
|
||||||
let diff = this.research[name].contribution - this.prev_research[name].contribution
|
let diff = this.research[name].contribution - this.prev_research[name].contribution
|
||||||
if (Math.abs(diff) > Number.EPSILON * 1000)
|
if (Math.abs(diff) > Number.EPSILON * 1000)
|
||||||
this.log(`Own research ${name}: ${this.research[name].progress} += ${diff}`)
|
this.log(`Own research ${name}: ${this.research[name].progress} += ${diff}`)
|
||||||
@@ -346,8 +370,10 @@ class ResearchSync {
|
|||||||
|
|
||||||
if (isNaN(level) || isNaN(researched))
|
if (isNaN(level) || isNaN(researched))
|
||||||
return
|
return
|
||||||
this.prev_research[name] = this.research[name]
|
|
||||||
if (!this.prev_research[name]) {
|
if (Object.hasOwnProperty.call(this.research, name)) {
|
||||||
|
this.prev_research[name] = this.research[name];
|
||||||
|
} else {
|
||||||
this.prev_research[name] = {
|
this.prev_research[name] = {
|
||||||
researched: null,
|
researched: null,
|
||||||
level: null,
|
level: null,
|
||||||
|
|||||||
Reference in new issue
Block a user