Fix misc problems detected by ESLint

Reformat and clean up issues detected by ESLint.
This commit is contained in:
Hornwitser committed 2020-06-17 20:59:37 +02:00
1 parent 8cb21c5fa8
commit e9f5cae4f0
34 files changed
+132 -189

No files matched your search

+2 -2
View File
@@ -112,7 +112,7 @@ class MasterPlugin extends plugin.BaseMasterPlugin {
}
for (let instanceTech of message.data.technologies) {
let [name, level, progress, researched] = instanceTech;
let [name, level, progress, researched] = instanceTech;
let tech = this.technologies.get(name);
if (!tech) {
this.technologies.set(name, { level, progress, researched });
@@ -152,7 +152,7 @@ class MasterPlugin extends plugin.BaseMasterPlugin {
let technologies = [];
for (let [name, tech] of this.technologies) {
technologies.push([ name, tech.level, tech.progress, tech.researched ]);
technologies.push([name, tech.level, tech.progress, tech.researched]);
}
return { technologies };
+7 -5
View File
@@ -16,7 +16,7 @@ const prometheusDoleFactorGauge = new prometheus.Gauge(
);
class neuralDole {
getRequestStats(itemname,samples)
{
var sum=0;
@@ -28,7 +28,7 @@ class neuralDole {
if (sum==0) return 0.1;
return sum/samples;
}
constructor({
items,
}){
@@ -41,6 +41,7 @@ class neuralDole {
this.stats=[];
this.debt= {};
}
doMagic() {
for (let [name, count] of this.items._items) {
let magicData = doleNN.Tick(
@@ -50,7 +51,7 @@ class neuralDole {
this.getRequestStats(name,5)
);
this.stats[name]=this.stats[name] || [];
this.stats[name].unshift({ req:0,given:0 });//stats[name][0] is the one we currently collect
this.stats[name].unshift({ req: 0, given: 0 });//stats[name][0] is the one we currently collect
if (this.stats[name].length>10) this.stats[name].pop();//remove if too many samples in stats
this.dole[name] = magicData[0];
@@ -59,6 +60,7 @@ class neuralDole {
}
this.itemsLastTick = new Map(this.items._items);
}
divider(object) {
let magicData = doleNN.Dose(
object.count, // numReq
@@ -100,7 +102,7 @@ function doleDivider({
let itemCount = items.getItemCount(object.name);
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;
object.count /= ((_doleDivisionFactor[object.name]||0)+doleDivisionRetardation)/doleDivisionRetardation;
object.count = Math.round(object.count);
@@ -128,4 +130,4 @@ function doleDivider({
module.exports = {
doleDivider,
neuralDole,
};
};
+10 -10
View File
@@ -47,7 +47,7 @@ function Dose(numreq,instore,store_last_tick,dole,carry,prev_req,numreq_total_ad
instore=Number(instore);
var instore_adj=instore;
if (instore_adj==0) instore_adj=0.1;
var b=Math.trunc(prev_req/instore_adj*numreq);
var inp1=[numreq,instore_adj,store_last_tick/numreq,dole,carry];//0..4
var inp2=[prev_req/numreq,numreq/numreq_total_adj,store_last_tick/numreq_total_adj,prev_req/instore_adj,b,numreq_total_adj,store_last_tick,debt];//5..12
@@ -55,7 +55,7 @@ function Dose(numreq,instore,store_last_tick,dole,carry,prev_req,numreq_total_ad
var internal=new Array(20).fill(0);
var outputs=[0,0,0,0];
//NN: Please don't touch :), code is generated
outputs[0]=inputs[7]*0.8058582544;
outputs[0]=sigmoid2(outputs[0]);
outputs[1]=sigmoid0(outputs[1]);
@@ -65,20 +65,20 @@ function Dose(numreq,instore,store_last_tick,dole,carry,prev_req,numreq_total_ad
debt=debt || 0;
if (outputs[0]>0.99) outputs[0]=1.0;
var res1=Number(outputs[0])*numreq+outputs[3]+debt;
var res_capped=Math.round(res1);
if (res_capped>numreq) res_capped=numreq;
if (res_capped>instore) res_capped=instore;
if (res_capped<0) res_capped=0;
res1=res1 || 0;
res_capped=res_capped || 0;//Safeguard against wrong values
debt=res1-res_capped;
debt_cap=Math.round(numreq*1.5)+5;
if (debt>debt_cap) debt=debt_cap;
carry=sigmoid0(outputs[2]*carry+outputs[0]) || 0;
return [res_capped,dole+outputs[1],carry,debt];
}
@@ -102,9 +102,9 @@ function Tick(instore,dole,store_last_tick,numreq_total_adj)
var internal=new Array(10).fill(0);
var outputs=[0,0];
//NN: Please don't touch :), code is generated
outputs[0]=inputs[3]*0.9364774823;
outputs[0]=outputs[0]*1.0*0.4590721726;
outputs[0]=outputs[0]*0.4590721726;
outputs[0]=sigmoid2(outputs[0]);
outputs[1]=outputs[0]*1.828422785;
outputs[1]=sigmoid3(outputs[1]);
@@ -113,8 +113,8 @@ function Tick(instore,dole,store_last_tick,numreq_total_adj)
if (numreq_total_adj<0.11) avg=1;//When no item's are requested, result is 0.1 ; In that case there is no deficit, so return 1 = 100% demand fulfilled
if (avg>1) avg=1;
if (avg<0) avg=0;
return [sigmoid0(outputs[0]),avg];
}
module.exports = { Dose,Tick };
module.exports = { Dose,Tick };
+8 -8
View File
@@ -13,24 +13,24 @@ function drawcontents(data) {
data = data.filter(function(item) {
return search.test(item.name);
});
sortByKey(data, "count");
const table = document.querySelector("#contents tbody"); //tables have tbody inserted automatically
const rows = table.children;
//update existing rows or create new ones
data.forEach(function(item, i) {
// format count to have .s in it for large number readability (1,000,000)
item.count = item.count.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ",");
let row = rows[i];
if(!row) {
row = document.createElement("tr");
row.innerHTML = "<td><div></div></td><td class=name></td><td class=count></td>";
table.appendChild(row);
}
const itemIcon = row.querySelector("div");
const iconClass = getItemIconClass(item.name);
if (itemIcon.getAttribute("class") !== iconClass) {
@@ -56,13 +56,13 @@ function drawcontents(data) {
if(name.textContent !== localeName) {
name.textContent = localeName;
}
const count = row.querySelector(".count");
if(count.textContent !== ""+item.count) {
if(count.textContent !== String(item.count)) {
count.textContent = item.count;
}
});
//remove excess rows, for example, after filtering
while (data.length < rows.length) {
table.removeChild(rows[data.length]);