From 03ad8a1d163ab067e2c2bb40460a2c7626376d06 Mon Sep 17 00:00:00 2001 From: Dragon Fire Date: Mon, 2 Mar 2020 14:43:09 -0500 Subject: [PATCH] Filter out tributes with no kills --- commands/sp-games/hunger-games.js | 23 +++++++++++++---------- 1 file changed, 13 insertions(+), 10 deletions(-) diff --git a/commands/sp-games/hunger-games.js b/commands/sp-games/hunger-games.js index 72591fba..e263a61f 100644 --- a/commands/sp-games/hunger-games.js +++ b/commands/sp-games/hunger-games.js @@ -136,15 +136,18 @@ module.exports = class HungerGamesCommand extends Command { let i = 0; let previousPts = null; let positionsMoved = 1; - return tributes.sort((a, b) => kills[b] - kills[a]).map(tribute => { - if (previousPts === kills[tribute]) { - positionsMoved++; - } else { - i += positionsMoved; - positionsMoved = 1; - } - previousPts = kills[tribute]; - return `**${i}.** ${tribute} (${kills[tribute]} Kills)`; - }); + return tributes + .filter(tribute => kills[tribute] > 0) + .sort((a, b) => kills[b] - kills[a]) + .map(tribute => { + if (previousPts === kills[tribute]) { + positionsMoved++; + } else { + i += positionsMoved; + positionsMoved = 1; + } + previousPts = kills[tribute]; + return `**${i}.** ${tribute} (${kills[tribute]} Kill${kills[tribute] === 1 ? '' : 's'})`; + }); } };