From 5d4cca7e0c737626876648cdeabf6242f64037fa Mon Sep 17 00:00:00 2001 From: Timothy Flynn Date: Tue, 25 May 2021 12:44:38 -0400 Subject: Solitaire: Award bonus points based on time elapsed The exact formula used for bonus points seems to vary by implementation. This uses Klondike Solitaire's formula: https://en.wikipedia.org/wiki/Klondike_(solitaire)#Scoring --- Userland/Games/Solitaire/main.cpp | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) (limited to 'Userland/Games/Solitaire') diff --git a/Userland/Games/Solitaire/main.cpp b/Userland/Games/Solitaire/main.cpp index cd81600549..736efc6cc1 100644 --- a/Userland/Games/Solitaire/main.cpp +++ b/Userland/Games/Solitaire/main.cpp @@ -115,9 +115,17 @@ int main(int argc, char** argv) if (timer->is_active()) timer->stop(); - if ((reason == Solitaire::GameOverReason::Victory) && (score > high_score)) { - update_high_score(score); - statusbar.set_text(1, String::formatted("High Score: {}", high_score)); + if (reason == Solitaire::GameOverReason::Victory) { + if (seconds_elapsed >= 30) { + uint32_t bonus = (20'000 / seconds_elapsed) * 35; + statusbar.set_text(0, String::formatted("Score: {} (Bonus: {})", score, bonus)); + score += bonus; + } + + if (score > high_score) { + update_high_score(score); + statusbar.set_text(1, String::formatted("High Score: {}", high_score)); + } } }; -- cgit v1.2.3