Filter out tributes with no kills

This commit is contained in:
Dragon Fire
2020-03-02 14:43:09 -05:00
parent 2090e04525
commit 03ad8a1d16
+13 -10
View File
@@ -136,15 +136,18 @@ module.exports = class HungerGamesCommand extends Command {
let i = 0; let i = 0;
let previousPts = null; let previousPts = null;
let positionsMoved = 1; let positionsMoved = 1;
return tributes.sort((a, b) => kills[b] - kills[a]).map(tribute => { return tributes
if (previousPts === kills[tribute]) { .filter(tribute => kills[tribute] > 0)
positionsMoved++; .sort((a, b) => kills[b] - kills[a])
} else { .map(tribute => {
i += positionsMoved; if (previousPts === kills[tribute]) {
positionsMoved = 1; positionsMoved++;
} } else {
previousPts = kills[tribute]; i += positionsMoved;
return `**${i}.** ${tribute} (${kills[tribute]} Kills)`; positionsMoved = 1;
}); }
previousPts = kills[tribute];
return `**${i}.** ${tribute} (${kills[tribute]} Kill${kills[tribute] === 1 ? '' : 's'})`;
});
} }
}; };