Skip to content
This repository has been archived by the owner on Feb 11, 2024. It is now read-only.

Commit

Permalink
simplified value update logic
Browse files Browse the repository at this point in the history
  • Loading branch information
developomp committed Mar 9, 2022
1 parent 5f4e856 commit 0f18ff8
Showing 1 changed file with 14 additions and 22 deletions.
36 changes: 14 additions & 22 deletions Elo.html
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
referrerpolicy="no-referrer"
type="module"
></script>

<style>
:root {
--width: 325px;
Expand Down Expand Up @@ -218,34 +219,25 @@

socket.onmessage = (event) => {
let data = JSON.parse(event.data);
let playerStat = data.playerStatsArray[data.localPlayerIndex];

if (data.playerStatsArray[data.localPlayerIndex].killsEloDelta < 0) {
killsEloDelta.classList.remove("positive");
} else {
killsEloCountUp.update(playerStat.killsElo);
killsEloDeltaCountUp.update(playerStat.killsEloDelta / 10);

gamesEloCountUp.update(playerStat.gamesElo);
gamesEloDeltaCountUp.update(playerStat.gamesEloDelta / 10);

if (playerStat.killsEloDelta >= 0) {
killsEloDelta.classList.add("positive");
} else {
killsEloDelta.classList.remove("positive");
}

if (data.playerStatsArray[data.localPlayerIndex].gamesEloDelta < 0) {
gamesEloDelta.classList.remove("positive");
} else {
if (playerStat.gamesEloDelta >= 0) {
gamesEloDelta.classList.add("positive");
} else {
gamesEloDelta.classList.remove("positive");
}

killsEloCountUp.update(
data.playerStatsArray[data.localPlayerIndex].killsElo
);

killsEloDeltaCountUp.update(
data.playerStatsArray[data.localPlayerIndex].killsEloDelta / 10
);

gamesEloCountUp.update(
data.playerStatsArray[data.localPlayerIndex].gamesElo
);

gamesEloDeltaCountUp.update(
data.playerStatsArray[data.localPlayerIndex].gamesEloDelta / 10
);
};
</script>
</body>
Expand Down

0 comments on commit 0f18ff8

Please sign in to comment.