From 67f79af0e77db0d16562920faa603b445d4a3b70 Mon Sep 17 00:00:00 2001 From: roxxorarc Date: Mon, 26 Feb 2024 19:51:42 +0100 Subject: [PATCH 1/2] feat: add kill participation in notif --- src/features/summoner.ts | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/features/summoner.ts b/src/features/summoner.ts index bbecf1a..5a38e3a 100644 --- a/src/features/summoner.ts +++ b/src/features/summoner.ts @@ -306,13 +306,20 @@ const getDamageDealtPercent = (match: Galeforce.dto.MatchDTO, participant: Parti return ((participant.totalDamageDealtToChampions / totalDamage) * 100).toFixed(2); }; +const getKillParticipation = (match: Galeforce.dto.MatchDTO, participant: Participant) => { + const participantsInTeam = match.info.participants.filter((p) => p.teamId === participant.teamId); + const teamKills = participantsInTeam.reduce((acc, p) => acc + p.kills, 0); + + return ((participant.kills + participant.assists) / teamKills) * 100; +} + const getMatchDescription = async (match: Galeforce.dto.MatchDTO, participant: Participant) => { return `**${participant.kills}/${participant.deaths}/${participant.assists}** with **${ participant.championName }** (${formatGameDuration(match.info.gameDuration)}) - **${getDamageDealtPercent( match, participant - )}%** of team's damage`; + )}%** of team's damage and **${getKillParticipation(match, participant).toFixed(2)}%** kill participation`; }; const formatGameDuration = (gameDuration: number) => { From d5595d4782f4e3ae186862e4af5fcc6b72a96fd9 Mon Sep 17 00:00:00 2001 From: ledouxm Date: Tue, 27 Feb 2024 16:34:06 +0100 Subject: [PATCH 2/2] "KP" instead of "kill participation" --- src/features/summoner.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/features/summoner.ts b/src/features/summoner.ts index 5a38e3a..82fcc38 100644 --- a/src/features/summoner.ts +++ b/src/features/summoner.ts @@ -319,7 +319,7 @@ const getMatchDescription = async (match: Galeforce.dto.MatchDTO, participant: P }** (${formatGameDuration(match.info.gameDuration)}) - **${getDamageDealtPercent( match, participant - )}%** of team's damage and **${getKillParticipation(match, participant).toFixed(2)}%** kill participation`; + )}%** of team's damage and **${getKillParticipation(match, participant).toFixed(2)}%** KP`; }; const formatGameDuration = (gameDuration: number) => {