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
This commit is contained in:
Timothy Flynn 2021-05-25 12:44:38 -04:00 committed by Andreas Kling
parent 0f80e9e4db
commit 5d4cca7e0c
Notes: sideshowbarker 2024-07-18 17:23:55 +09:00

View file

@ -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));
}
}
};