diff options
author | Matthew Jones <matthewbjones85@gmail.com> | 2021-06-03 14:55:48 -0600 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2021-06-04 00:15:25 +0200 |
commit | 1748591570172d9ff9c5843bdc5ea94d49106c7f (patch) | |
tree | 5758151e2d3e017b5cdfac977f9b8b44f7e9aa77 /Userland/Games/Solitaire | |
parent | bfffdd37f060d3bd7d23f8912a01241d2f58723f (diff) | |
download | serenity-1748591570172d9ff9c5843bdc5ea94d49106c7f.zip |
Solitaire: Fixes undo feature from incorrect merge conflict resolution
Diffstat (limited to 'Userland/Games/Solitaire')
-rw-r--r-- | Userland/Games/Solitaire/Game.cpp | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/Userland/Games/Solitaire/Game.cpp b/Userland/Games/Solitaire/Game.cpp index e17a3b25ce..a7a99a6323 100644 --- a/Userland/Games/Solitaire/Game.cpp +++ b/Userland/Games/Solitaire/Game.cpp @@ -376,16 +376,21 @@ void Game::draw_cards() update(waste.bounding_box()); update(play.bounding_box()); + NonnullRefPtrVector<Card> moved_cards; while (!play.is_empty()) { auto card = play.pop(); stock.push(card); + moved_cards.prepend(card); } while (!waste.is_empty()) { auto card = waste.pop(); stock.push(card); + moved_cards.prepend(card); } + remember_move_for_undo(waste, stock, moved_cards); + if (m_passes_left_before_punishment == 0) update_score(recycle_rules().punishment); else @@ -411,11 +416,15 @@ void Game::draw_cards() update(stock.bounding_box()); + NonnullRefPtrVector<Card> cards_drawn; for (size_t i = 0; (i < cards_to_draw) && !stock.is_empty(); ++i) { auto card = stock.pop(); + cards_drawn.append(card); play.push(move(card)); } + remember_move_for_undo(stock, play, cards_drawn); + if (play.bounding_box().size().width() > play_bounding_box.size().width()) update(play.bounding_box()); else @@ -622,6 +631,9 @@ void Game::perform_undo() } } + if (m_last_move.from->type() == CardStack::Type::Waste && m_last_move.to->type() == CardStack::Type::Stock) + pop_waste_to_play_stack(); + score_move(*m_last_move.from, *m_last_move.to, true); m_last_move = {}; |