summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Userland/Games/Solitaire/Game.cpp10
-rw-r--r--Userland/Games/Solitaire/Game.h3
2 files changed, 10 insertions, 3 deletions
diff --git a/Userland/Games/Solitaire/Game.cpp b/Userland/Games/Solitaire/Game.cpp
index 0b7a4c86e5..35a034bc12 100644
--- a/Userland/Games/Solitaire/Game.cpp
+++ b/Userland/Games/Solitaire/Game.cpp
@@ -139,7 +139,7 @@ void Game::start_timer_if_necessary()
}
}
-void Game::score_move(CardStack& from, CardStack& to, bool inverse = false)
+void Game::score_move(CardStack& from, CardStack& to, bool inverse)
{
if (from.type() == CardStack::Type::Play && to.type() == CardStack::Type::Normal) {
update_score(5 * (inverse ? -1 : 1));
@@ -152,6 +152,11 @@ void Game::score_move(CardStack& from, CardStack& to, bool inverse = false)
}
}
+void Game::score_flip(bool inverse)
+{
+ update_score(5 * (inverse ? -1 : 1));
+}
+
void Game::update_score(int to_add)
{
m_score = max(static_cast<int>(m_score) + to_add, 0);
@@ -200,7 +205,7 @@ void Game::mousedown_event(GUI::MouseEvent& event)
if (top_card.is_upside_down()) {
if (top_card.rect().contains(click_location)) {
top_card.set_upside_down(false);
- update_score(5);
+ score_flip();
update(top_card.rect());
remember_flip_for_undo(top_card);
}
@@ -600,6 +605,7 @@ void Game::perform_undo()
if (on_undo_availability_change)
on_undo_availability_change(false);
invalidate_layout();
+ score_flip(true);
return;
}
diff --git a/Userland/Games/Solitaire/Game.h b/Userland/Games/Solitaire/Game.h
index 30168bd13c..a49199f295 100644
--- a/Userland/Games/Solitaire/Game.h
+++ b/Userland/Games/Solitaire/Game.h
@@ -155,7 +155,8 @@ private:
}
void mark_intersecting_stacks_dirty(Card& intersecting_card);
- void score_move(CardStack& from, CardStack& to, bool inverse);
+ void score_move(CardStack& from, CardStack& to, bool inverse = false);
+ void score_flip(bool inverse = false);
void remember_move_for_undo(CardStack& from, CardStack& to, NonnullRefPtrVector<Card> moved_cards);
void remember_flip_for_undo(Card& card);
void update_score(int to_add);