mirror of
https://github.com/SerenityOS/serenity.git
synced 2025-01-24 02:12:09 -05:00
Solitaire: Fixes undo feature from incorrect merge conflict resolution
This commit is contained in:
parent
bfffdd37f0
commit
1748591570
1 changed files with 12 additions and 0 deletions
|
@ -376,16 +376,21 @@ void Game::draw_cards()
|
||||||
update(waste.bounding_box());
|
update(waste.bounding_box());
|
||||||
update(play.bounding_box());
|
update(play.bounding_box());
|
||||||
|
|
||||||
|
NonnullRefPtrVector<Card> moved_cards;
|
||||||
while (!play.is_empty()) {
|
while (!play.is_empty()) {
|
||||||
auto card = play.pop();
|
auto card = play.pop();
|
||||||
stock.push(card);
|
stock.push(card);
|
||||||
|
moved_cards.prepend(card);
|
||||||
}
|
}
|
||||||
|
|
||||||
while (!waste.is_empty()) {
|
while (!waste.is_empty()) {
|
||||||
auto card = waste.pop();
|
auto card = waste.pop();
|
||||||
stock.push(card);
|
stock.push(card);
|
||||||
|
moved_cards.prepend(card);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
remember_move_for_undo(waste, stock, moved_cards);
|
||||||
|
|
||||||
if (m_passes_left_before_punishment == 0)
|
if (m_passes_left_before_punishment == 0)
|
||||||
update_score(recycle_rules().punishment);
|
update_score(recycle_rules().punishment);
|
||||||
else
|
else
|
||||||
|
@ -411,11 +416,15 @@ void Game::draw_cards()
|
||||||
|
|
||||||
update(stock.bounding_box());
|
update(stock.bounding_box());
|
||||||
|
|
||||||
|
NonnullRefPtrVector<Card> cards_drawn;
|
||||||
for (size_t i = 0; (i < cards_to_draw) && !stock.is_empty(); ++i) {
|
for (size_t i = 0; (i < cards_to_draw) && !stock.is_empty(); ++i) {
|
||||||
auto card = stock.pop();
|
auto card = stock.pop();
|
||||||
|
cards_drawn.append(card);
|
||||||
play.push(move(card));
|
play.push(move(card));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
remember_move_for_undo(stock, play, cards_drawn);
|
||||||
|
|
||||||
if (play.bounding_box().size().width() > play_bounding_box.size().width())
|
if (play.bounding_box().size().width() > play_bounding_box.size().width())
|
||||||
update(play.bounding_box());
|
update(play.bounding_box());
|
||||||
else
|
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);
|
score_move(*m_last_move.from, *m_last_move.to, true);
|
||||||
|
|
||||||
m_last_move = {};
|
m_last_move = {};
|
||||||
|
|
Loading…
Add table
Reference in a new issue