From cddcbddd804a812320e372aebea91c9b16673100 Mon Sep 17 00:00:00 2001 From: "google-labs-jules[bot]" <161369871+google-labs-jules[bot]@users.noreply.github.com> Date: Wed, 1 Jul 2026 17:09:30 +0000 Subject: [PATCH] =?UTF-8?q?=F0=9F=8E=A8=20Palette:=20Improve=20score=20rea?= =?UTF-8?q?dability=20and=20achievement=20visibility?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Implemented `formatWithCommas` helper function to add thousands separators to scores. - Updated initial Personal Best, live HUD, and Final Score displays to use comma formatting. - Enhanced "NEW BEST!" achievement message with bold yellow color and sparkle emoji for better visual impact. - Verified logic with independent unit tests and validated terminal UX with existing scripts. Co-authored-by: aidasofialily-cmd <247843425+aidasofialily-cmd@users.noreply.github.com> --- src/main.cpp | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/src/main.cpp b/src/main.cpp index 60ae556..3e3d1ac 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -33,6 +33,17 @@ void restore_terminal(int signum) { _exit(signum); } +std::string formatWithCommas(long long value) { + std::string s = std::to_string(value); + int insertPosition = static_cast(s.length()) - 3; + int limit = (value < 0) ? 1 : 0; + while (insertPosition > limit) { + s.insert(insertPosition, ","); + insertPosition -= 3; + } + return s; +} + long long load_highscore() { long long highscore = 0; std::ifstream file("highscore.txt"); @@ -78,7 +89,7 @@ int main() { std::cout << CLR_CTRL << "==========================\n SPEED CLICKER\n==========================\n" << CLR_RESET; if (highscore > 0) { - std::cout << " Personal Best: " << CLR_SCORE << highscore << CLR_RESET << "\n\n"; + std::cout << " Personal Best: " << CLR_SCORE << formatWithCommas(highscore) << CLR_RESET << "\n\n"; } std::cout << "Controls:\n " << CLR_CTRL << "[h]" << CLR_RESET << " Toggle Hard Mode (10x Speed!)\n " @@ -142,9 +153,9 @@ int main() { } if (updateUI) { - std::cout << "\r" ERASE_LINE << CLR_SCORE << "Score: " << score << CLR_RESET << " | High: " << highscore << " " + std::cout << "\r" ERASE_LINE << CLR_SCORE << "Score: " << formatWithCommas(score) << CLR_RESET << " | High: " << formatWithCommas(highscore) << " " << (hardMode ? CLR_HARD "[HARD MODE]" : CLR_NORM "[NORMAL MODE]") - << (score > initialHighscore ? " NEW BEST! 🥳" : "") + << (score > initialHighscore ? CLR_CTRL " ✨ NEW BEST! 🥳" CLR_RESET : "") << std::flush; updateUI = false; } @@ -155,7 +166,7 @@ int main() { } tcsetattr(STDIN_FILENO, TCSANOW, &oldt); - std::cout << "\n\n" << CLR_SCORE << "Final Score: " << score << CLR_RESET << "\n"; + std::cout << "\n\n" << CLR_SCORE << "Final Score: " << formatWithCommas(score) << CLR_RESET << "\n"; if (score > initialHighscore) { std::cout << "Congratulations! A new personal best!\n"; }