Skip to content

Commit

Permalink
Merge pull request #1 from ledouxm/feat_kp
Browse files Browse the repository at this point in the history
feat: add kill participation in notif
  • Loading branch information
ledouxm authored Feb 27, 2024
2 parents c8fa609 + d5595d4 commit bba0055
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion src/features/summoner.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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)}%** KP`;
};

const formatGameDuration = (gameDuration: number) => {
Expand Down

0 comments on commit bba0055

Please sign in to comment.