Skip to content

Commit

Permalink
fix: win/lose
Browse files Browse the repository at this point in the history
  • Loading branch information
haxgun committed Oct 30, 2023
1 parent 22d233b commit 4efc839
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions src/js/overlay.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ const { NICKNAME, TAG} = {
};

let lastMatchId = '';
let win = 0;
let lose = 0;

document.querySelector('#overlay').innerHTML = `
<div id="elements">
Expand Down Expand Up @@ -208,8 +210,6 @@ async function winlose(region, puuid) {
const dataMatches = await getMatches(region, puuid);
const [won, tied] = await getWonInfo(puuid, dataMatches);
const currentMatchId = dataMatches.data[0].metadata.matchid;
let win = 0;
let lose = 0;

if (currentMatchId !== lastMatchId) {
if (won === true) {
Expand Down Expand Up @@ -257,12 +257,12 @@ async function playerTeam(puuid, dataMatches) {
return team.toLowerCase();
}

async function WinLoseVisual(win, lose) {
winValue.innerHTML = `${win}`;
loseValue.innerHTML = `${lose}`;
const totalGames = win + lose;
const winPercentage = (win / totalGames) * 100;
if (win + lose !== 0) {
async function WinLoseVisual(winVal, loseVal) {
winValue.innerHTML = `${winVal}`;
loseValue.innerHTML = `${loseVal}`;
const totalGames = winVal + loseVal;
const winPercentage = (winVal / totalGames) * 100;
if (winVal + loseVal !== 0) {
wlProccent.innerHTML = `(${winPercentage.toFixed()}%)`;
}
}
Expand Down

0 comments on commit 4efc839

Please sign in to comment.