Ver código fonte

Solitaire: Fixes undo feature from incorrect merge conflict resolution

Matthew Jones 4 anos atrás
pai
commit
1748591570
1 arquivos alterados com 12 adições e 0 exclusões
  1. 12 0
      Userland/Games/Solitaire/Game.cpp

+ 12 - 0
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 = {};