mirror of
https://github.com/RGBCube/serenity
synced 2025-07-28 08:37:35 +00:00
Solitaire: Ability to automatically solve the end of the game
In Solitaire, when the stock stack is empty and all cards have been revealed, finishing the game is trivial, since you only need to sort the already visible cards onto the foundation stacks. To simplify this, the game will now give you the option to finish the game automatically if these conditions are met. It then sorts the cards with a delay of 100ms between each card.
This commit is contained in:
parent
999a44969d
commit
6a4e3d9002
4 changed files with 108 additions and 2 deletions
|
@ -2,6 +2,7 @@
|
|||
* Copyright (c) 2020, Till Mayer <till.mayer@web.de>
|
||||
* Copyright (c) 2021-2023, Sam Atkins <atkinssj@serenityos.org>
|
||||
* Copyright (c) 2022, the SerenityOS developers.
|
||||
* Copyright (c) 2023, David Ganz <david.g.ganz@gmail.com>
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-2-Clause
|
||||
*/
|
||||
|
@ -45,10 +46,14 @@ public:
|
|||
bool is_auto_collecting() const { return m_auto_collect; }
|
||||
void set_auto_collect(bool collect) { m_auto_collect = collect; }
|
||||
|
||||
bool can_solve();
|
||||
void start_solving();
|
||||
|
||||
Function<void(uint32_t)> on_score_update;
|
||||
Function<void()> on_game_start;
|
||||
Function<void(GameOverReason, uint32_t)> on_game_end;
|
||||
Function<void(bool)> on_undo_availability_change;
|
||||
Function<void()> on_move;
|
||||
|
||||
private:
|
||||
Game();
|
||||
|
@ -188,6 +193,7 @@ private:
|
|||
void check_for_game_over();
|
||||
void clear_hovered_stack();
|
||||
void deal_next_card();
|
||||
void step_solve();
|
||||
|
||||
virtual void paint_event(GUI::PaintEvent&) override;
|
||||
virtual void mousedown_event(GUI::MouseEvent&) override;
|
||||
|
@ -211,6 +217,7 @@ private:
|
|||
GameInProgress,
|
||||
StartGameOverAnimationNextFrame,
|
||||
GameOverAnimation,
|
||||
Solving,
|
||||
};
|
||||
State m_state { State::WaitingForNewGame };
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue