Skip to content

Commit be09707

Browse files
committed
Rescale APM series to show it correctly in LotV replays.
1 parent 67aba1c commit be09707

File tree

1 file changed

+27
-3
lines changed
  • app/assets/javascripts/angular/resources

1 file changed

+27
-3
lines changed

app/assets/javascripts/angular/resources/match.js

Lines changed: 27 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -570,6 +570,30 @@ gg.factory('Match', ['$ggResource', '$compile', 'Matchnote', function($ggResourc
570570
return _.zip(_bases_x_minutes, _series_y);
571571
};
572572

573+
// Rescale series to a point per game minute
574+
statxminutes = function(statarray) {
575+
// Don't rescale the series if it is all zeros, since it will show up even as zero when rescaled
576+
var sum = 0;
577+
$.each(statarray, function(){
578+
sum += this
579+
});
580+
if (sum == 0) {
581+
return statarray;
582+
}
583+
584+
result = [];
585+
seconds_between_stat_updates = 60.0
586+
if (this.expansion_tag == 'LotV') {
587+
seconds_between_stat_updates /= Sc2.LOTV_SPEEDUP;
588+
}
589+
now_seconds = seconds_between_stat_updates;
590+
_.each(statarray, function(stat) {
591+
result.push([now_seconds / 60.0, stat]);
592+
now_seconds = now_seconds + seconds_between_stat_updates;
593+
});
594+
return result;
595+
}
596+
573597
statx = function(statarray) {
574598
result = [];
575599
seconds_between_stat_updates = 10.0;
@@ -630,9 +654,9 @@ gg.factory('Match', ['$ggResource', '$compile', 'Matchnote', function($ggResourc
630654
}
631655

632656
if(entity.data) {
633-
this._series.apm.entities[_entity] = $.extend({data: entity.data.apm, pointStart: 1}, base_series);
634-
this._series.wpm.entities[_entity] = $.extend({data: entity.data.wpm, pointStart: 1}, base_series);
635-
this._series.creep_spread.entities[_entity] = $.extend({data: entity.data.creep_spread, pointStart: 1}, base_series);
657+
this._series.apm.entities[_entity] = $.extend({data: statxminutes(entity.data.apm), pointStart: 1}, base_series);
658+
this._series.wpm.entities[_entity] = $.extend({data: statxminutes(entity.data.wpm), pointStart: 1}, base_series);
659+
this._series.creep_spread.entities[_entity] = $.extend({data: statxminutes(entity.data.creep_spread), pointStart: 1}, base_series);
636660
}
637661

638662
if (this.num_bases) {

0 commit comments

Comments
 (0)