From b8d13d31a02f3209290fa998ac916202b4b5b4f8 Mon Sep 17 00:00:00 2001 From: mehbark Date: Wed, 29 Mar 2023 19:35:50 -0400 Subject: [PATCH] add wins to stat export --- index.html | 4 ++-- main.js | 7 ++++--- main.ts | 13 +++++++------ 3 files changed, 13 insertions(+), 11 deletions(-) diff --git a/index.html b/index.html index b64c84d..9ebcb1a 100644 --- a/index.html +++ b/index.html @@ -133,9 +133,9 @@ >

- +

-        
+        
         

Players: (click name to toggle strikethrough)

diff --git a/main.js b/main.js index 7410d1c..3a123d9 100644 --- a/main.js +++ b/main.js @@ -644,6 +644,9 @@ function show_game_over() { } function show_win() { wins++; + let win_count = document.getElementById("win-count"); + win_count.style.display = "block"; + win_count.innerText = `You have won ${wins} time${wins == 1 ? "" : "s"} without refreshing${wins_exclamation_marks()}`; let game_over = document.getElementById("game-over"); game_over.style.display = "block"; game_over.innerText = "YOU WIN YOU WIN YOU WIN YOU WIN HOLY CRAP"; @@ -652,6 +655,7 @@ function show_win() { let stats_text = `#elo_worldle #ew_${todays_player.name} pyrope.net/ew +Win #${wins} Guesses: ${num_guesses} Moves: ${num_moves} ${history}`; @@ -711,9 +715,6 @@ function reset() { let play_again = document.getElementById("play-again"); play_again.style.display = "none"; play_again.onclick = _ => console.log("you can't play again again sorry :]"); - let win_count = document.getElementById("win-count"); - win_count.style.display = "block"; - win_count.innerText = `You have won ${wins} time${wins > 1 ? "s" : ""}${wins_exclamation_marks()}`; todays_player = get_todays_player(); game = new Chess(); board.fen = game.fen(); diff --git a/main.ts b/main.ts index e7f5cf0..236d580 100644 --- a/main.ts +++ b/main.ts @@ -779,6 +779,11 @@ function show_game_over() { function show_win() { wins++; + let win_count = document.getElementById("win-count"); + win_count.style.display = "block"; + win_count.innerText = `You have won ${wins} time${ + wins == 1 ? "" : "s" + } without refreshing${wins_exclamation_marks()}`; let game_over = document.getElementById("game-over"); game_over.style.display = "block"; @@ -789,6 +794,7 @@ function show_win() { let stats_text = `#elo_worldle #ew_${todays_player.name} pyrope.net/ew +Win #${wins} Guesses: ${num_guesses} Moves: ${num_moves} ${history}`; @@ -855,6 +861,7 @@ function wins_exclamation_marks() { let wins_divided_by_ten = Math.floor(wins / 10); return wins_divided_by_ten > 0 ? "!".repeat(wins_divided_by_ten) : "."; } + // ERROR: ! // INELEGANT // "HACK"! @@ -864,12 +871,6 @@ function reset() { play_again.onclick = _ => console.log("you can't play again again sorry :]"); - let win_count = document.getElementById("win-count"); - win_count.style.display = "block"; - win_count.innerText = `You have won ${wins} time${ - wins > 1 ? "s" : "" - }${wins_exclamation_marks()}`; - todays_player = get_todays_player(); game = new Chess(); board.fen = game.fen();