mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 03:07:43 +00:00
Solitaire: Only update high score after a victorious game
Doesn't make much sense to update the high score on a lost game.
This commit is contained in:
parent
95401d2ca2
commit
0b30a0febb
3 changed files with 14 additions and 9 deletions
|
@ -93,11 +93,6 @@ int main(int argc, char** argv)
|
|||
|
||||
game.on_score_update = [&](uint32_t score) {
|
||||
statusbar.set_text(0, String::formatted("Score: {}", score));
|
||||
|
||||
if (score > high_score) {
|
||||
update_high_score(score);
|
||||
statusbar.set_text(1, String::formatted("High Score: {}", high_score));
|
||||
}
|
||||
};
|
||||
|
||||
uint64_t seconds_elapsed = 0;
|
||||
|
@ -116,9 +111,14 @@ int main(int argc, char** argv)
|
|||
seconds_elapsed = 0;
|
||||
timer->start();
|
||||
};
|
||||
game.on_game_end = [&]() {
|
||||
game.on_game_end = [&](Solitaire::GameOverReason reason, uint32_t score) {
|
||||
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));
|
||||
}
|
||||
};
|
||||
|
||||
GUI::ActionGroup draw_setting_actions;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue