diff options
author | Timothy Flynn <trflynn89@pm.me> | 2021-05-25 12:44:38 -0400 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2021-05-25 21:20:50 +0200 |
commit | 5d4cca7e0c737626876648cdeabf6242f64037fa (patch) | |
tree | 3bb6e3a172e3a5e8d58e9834b9b1fe3d10d9349d /Userland/Games/Solitaire | |
parent | 0f80e9e4dbb33e4d6988bdf5f7d23e61d6765cb9 (diff) | |
download | serenity-5d4cca7e0c737626876648cdeabf6242f64037fa.zip |
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
Diffstat (limited to 'Userland/Games/Solitaire')
-rw-r--r-- | Userland/Games/Solitaire/main.cpp | 14 |
1 files changed, 11 insertions, 3 deletions
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)); + } } }; |