Skip to content

Commit

Permalink
Clean _onRoundEnd
Browse files Browse the repository at this point in the history
  • Loading branch information
andrewda committed Aug 10, 2016
1 parent 4f28248 commit 6027b42
Showing 1 changed file with 4 additions and 15 deletions.
19 changes: 4 additions & 15 deletions lib/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -202,25 +202,14 @@ Livescore.prototype._onRoundStart = function() {
Livescore.prototype._onRoundEnd = function(event) {
var teams = {};

var winner;
if (event.winner === 'TERRORIST') {
winner = Livescore.Enums.ESide['TERRORIST'];
} else {
winner = Livescore.Enums.ESide['COUNTERTERRORIST'];
}
var winner = Livescore.Enums.ESide[event.winner === 'TERRORIST' ? 'TERRORIST' : 'COUNTERTERRORIST'];

self.setTime(self.options[Livescore.Enums.EOption["FREEZE_TIME"]]);

self.getTeams(function(teams) {
var t = teams[Livescore.Enums.ESide['TERRORIST']];
var ct = teams[Livescore.Enums.ESide['COUNTERTERRORIST']];

if (t && ct) {
t.score = event.terroristScore;
ct.score = event.counterTerroristScore;

teams[Livescore.Enums.ESide['TERRORIST']] = t;
teams[Livescore.Enums.ESide['COUNTERTERRORIST']] = ct;
if (Object.keys(teams).length) {
teams[Livescore.Enums.ESide['TERRORIST']].score = event.terroristScore;
teams[Livescore.Enums.ESide['COUNTERTERRORIST']].score = event.counterTerroristScore;

// If at least 80% of the kills are knife kills, count it as a knife
// round. Sometimes players will have pistols on knife rounds and
Expand Down

0 comments on commit 6027b42

Please sign in to comment.