mirror of
https://github.com/clusterio/clusterio.git
synced 2026-11-11 23:04:52 +09:00
Update remove.js
This commit is contained in:
1 parent
abf4b5d926
commit
fddafaec09
1 file changed
+21
-8
+21
-8
@@ -4,14 +4,17 @@ const doleNN = require("./../../lib/dole_nn_base.js")
|
||||
|
||||
class neuralDole {
|
||||
constructor({
|
||||
items,
|
||||
items, gauge
|
||||
}){
|
||||
// Set some storage variables for the dole divider
|
||||
this.prometheusDoleFactorGauge = gauge
|
||||
this.items = items
|
||||
this.itemsLastTick = JSON.parse(JSON.stringify(items))
|
||||
this.dole = {}
|
||||
this.carry = {}
|
||||
this.lastRequest = {}
|
||||
this.doleinfo_last = {}
|
||||
this.doleinfo_new = {}
|
||||
|
||||
setInterval(()=>{
|
||||
for(let name in this.items){
|
||||
@@ -22,10 +25,15 @@ class neuralDole {
|
||||
let magicData = doleNN.Tick(
|
||||
count,
|
||||
this.dole[name],
|
||||
this.itemsLastTick[name]
|
||||
this.itemsLastTick[name],
|
||||
this.doleinfo_last[name] || {numreq:0 , numslave:0},
|
||||
this.doleinfo_new[name] || {numreq:0 , numslave:0}
|
||||
)
|
||||
this.dole[name] = magicData[0]
|
||||
// TODO handle magicData[1] for graphing for our users
|
||||
// DONE handle magicData[1] for graphing for our users
|
||||
this.prometheusDoleFactorGauge.labels(name).set(magicData[1] || 0);
|
||||
this.doleinfo_last[name]=this.doleinfo_new[name]
|
||||
this.doleinfo_new[name]={numreq:0 , numslave:0}
|
||||
}
|
||||
this.itemsLastTick = JSON.parse(JSON.stringify(this.items))
|
||||
}, 1000)
|
||||
@@ -42,15 +50,20 @@ class neuralDole {
|
||||
this.items[object.name],
|
||||
this.itemsLastTick[object.name] || 0,
|
||||
this.dole[object.name],
|
||||
this.carry[object.name] || 0,
|
||||
this.lastRequest[object.name+"_"+object.instanceID+"_"+object.instanceName] || 0
|
||||
this.carry[object.name+" "+object.instanceID] || 0,
|
||||
this.lastRequest[object.name+"_"+object.instanceID+"_"+object.instanceName] || 0,
|
||||
this.doleinfo_last[object.name] || {numreq:0 , numslave:0}
|
||||
)
|
||||
this.lastRequest[object.name+"_"+object.instanceID+"_"+object.instanceName] = object.count
|
||||
//0.Number of items to give in that dose
|
||||
//1.New dole for item X
|
||||
//2.New carry for item X slave Y
|
||||
this.dole[object.name] = magicData[1]
|
||||
this.carry[object.name] = magicData[2]
|
||||
this.carry[object.name+" "+object.instanceID] = magicData[2]
|
||||
|
||||
this.doleinfo_new[object.name].numreq=magicData[0] + (this.doleinfo_new[object.name].numreq || 0)
|
||||
this.doleinfo_new[object.name].numslave=1 + (this.doleinfo_new[object.name].numslave || 0)
|
||||
|
||||
// Remove item from DB and send it
|
||||
if(this.items.removeItem({count: magicData[0], name: object.name})){
|
||||
if(config.logItemTransfers){
|
||||
@@ -96,7 +109,7 @@ function doleDivider({
|
||||
prometheusImportGauge,
|
||||
req,res,
|
||||
}){
|
||||
const doleDivisionRetardation = 10; //lower rates will equal more dramatic swings
|
||||
const doleDivisionRetardation = 10; //lower rates will equal more dramatic swings
|
||||
const maxDoleDivision = 250; //a higher cap will divide the store more ways, but will take longer to recover as supplies increase
|
||||
|
||||
const originalCount = Number(object.count) || 0;
|
||||
@@ -143,4 +156,4 @@ function doleDivider({
|
||||
module.exports = {
|
||||
doleDivider,
|
||||
neuralDole
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user