mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 12:17:44 +00:00
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:
parent
0f80e9e4db
commit
5d4cca7e0c
1 changed files with 11 additions and 3 deletions
|
@ -115,10 +115,18 @@ int main(int argc, char** argv)
|
||||||
if (timer->is_active())
|
if (timer->is_active())
|
||||||
timer->stop();
|
timer->stop();
|
||||||
|
|
||||||
if ((reason == Solitaire::GameOverReason::Victory) && (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);
|
update_high_score(score);
|
||||||
statusbar.set_text(1, String::formatted("High Score: {}", high_score));
|
statusbar.set_text(1, String::formatted("High Score: {}", high_score));
|
||||||
}
|
}
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
GUI::ActionGroup draw_setting_actions;
|
GUI::ActionGroup draw_setting_actions;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue