Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Rescale APM series to show it correctly in LotV replays.
  • Loading branch information
nickelsen committed Apr 22, 2016
commit be09707389df9bf685fff87d239fc4e60391e2a2
30 changes: 27 additions & 3 deletions app/assets/javascripts/angular/resources/match.js
Original file line number Diff line number Diff line change
Expand Up @@ -570,6 +570,30 @@ gg.factory('Match', ['$ggResource', '$compile', 'Matchnote', function($ggResourc
return _.zip(_bases_x_minutes, _series_y);
};

// Rescale series to a point per game minute
statxminutes = function(statarray) {
// Don't rescale the series if it is all zeros, since it will show up even as zero when rescaled
var sum = 0;
$.each(statarray, function(){
sum += this
});
if (sum == 0) {
return statarray;
}

result = [];
seconds_between_stat_updates = 60.0
if (this.expansion_tag == 'LotV') {
seconds_between_stat_updates /= Sc2.LOTV_SPEEDUP;
}
now_seconds = seconds_between_stat_updates;
_.each(statarray, function(stat) {
result.push([now_seconds / 60.0, stat]);
now_seconds = now_seconds + seconds_between_stat_updates;
});
return result;
}

statx = function(statarray) {
result = [];
seconds_between_stat_updates = 10.0;
Expand Down Expand Up @@ -630,9 +654,9 @@ gg.factory('Match', ['$ggResource', '$compile', 'Matchnote', function($ggResourc
}

if(entity.data) {
this._series.apm.entities[_entity] = $.extend({data: entity.data.apm, pointStart: 1}, base_series);
this._series.wpm.entities[_entity] = $.extend({data: entity.data.wpm, pointStart: 1}, base_series);
this._series.creep_spread.entities[_entity] = $.extend({data: entity.data.creep_spread, pointStart: 1}, base_series);
this._series.apm.entities[_entity] = $.extend({data: statxminutes(entity.data.apm), pointStart: 1}, base_series);
this._series.wpm.entities[_entity] = $.extend({data: statxminutes(entity.data.wpm), pointStart: 1}, base_series);
this._series.creep_spread.entities[_entity] = $.extend({data: statxminutes(entity.data.creep_spread), pointStart: 1}, base_series);
}
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

very clever!


if (this.num_bases) {
Expand Down