Skip to content

Commit

Permalink
add metal spent and energy spent to the charts
Browse files Browse the repository at this point in the history
  • Loading branch information
ColaColin committed May 2, 2014
1 parent 414ea1e commit e587b9a
Showing 1 changed file with 32 additions and 8 deletions.
40 changes: 32 additions & 8 deletions src/main/webapp/static/js/chartpage.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ $(function() {
speed = 1;
}
return speed;
}
};

var buildSpeedByMetal = {
getValue : function(timepoint, i) {
Expand All @@ -21,7 +21,7 @@ $(function() {
},
text : "Build efficiency by metal",
accumulates : false
}
};

var buildSpeedByEnergy = {
getValue : function(timepoint, i) {
Expand All @@ -32,7 +32,7 @@ $(function() {
},
text : "Build efficiency by energy",
accumulates : false
}
};

var buildSpeed = {
getValue : function(timepoint, i) {
Expand All @@ -41,7 +41,7 @@ $(function() {
},
text : 'Build efficiency',
accumulates : false
}
};
var metalIncome = makeDefStat("metalIncome", "Metal income gross");
var energyIncome = makeDefStat("energyIncome", "Energy income gross");
var metalIncomeNet = makeDefStat("metalIncomeNet", "Metal income net");
Expand Down Expand Up @@ -73,7 +73,7 @@ $(function() {
return timeFound == 0 ? apm.getValue(tp, i+1) : sum / (timeFound / 60000);
}, text : 'APM',
accumulates : false,
}
};

var armyCount = makeDefStat("armyCount", "Units alive");
var metalStored = makeDefStat("metalStored", "Metal stored");
Expand All @@ -83,10 +83,34 @@ $(function() {
var energyProduced = makeDefStat("energyProduced", "Energy produced", true);
var energyWasted = makeDefStat("energyWasted", "Energy wasted", true);

var growthSinceLast = function(val, timepoint, i) {
if (i === 0) {
return 0;
} else {
return val.getValue(timepoint, i) - val.getValue(timepoint, i-1);
}
};

var metalSpent = {
getValue: function(timepoint, i) {
return metalProduced.getValue(timepoint, i) - metalWasted.getValue(timepoint, i) - growthSinceLast(metalStored, timepoint, i);
},
text: "Metal spent",
accumulates: true
};

var energySpent = {
getValue: function(timepoint, i) {
return energyProduced.getValue(timepoint, i) - energyWasted.getValue(timepoint, i) - growthSinceLast(energyStored, timepoint, i);
},
text: "Energy spent",
accumulates: true
};

self.sts = [ armyCount, buildSpeed, buildSpeedByMetal, buildSpeedByEnergy, metalIncome, metalSpending,
metalIncomeNet, metalWasted, metalStored, metalProduced,
metalIncomeNet, metalWasted, metalStored, metalProduced, metalSpent,
energyIncome, energySpending, energyIncomeNet, energyWasted,
energyStored, energyProduced, apm ]
energyStored, energyProduced, energySpent, apm ]

var firstTime = undefined;
var lastTime = undefined;
Expand All @@ -98,7 +122,7 @@ $(function() {
var graphConf = {
element : document.querySelector("#chartcontainer"),
width : 700,
height : 450,
height : 530,
min : 'auto',
interpolation : 'step-after',
renderer : 'line'
Expand Down

0 comments on commit e587b9a

Please sign in to comment.