summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGunnar Beutner <gbeutner@serenityos.org>2021-05-24 10:27:05 +0200
committerAndreas Kling <kling@serenityos.org>2021-05-25 21:05:35 +0200
commit4e3a1f2da9a20c40421eec033c379b9275a5b77d (patch)
treef47cac7eb5a6fbffd0eacd4ed86147d7b8c97b70
parent6da481205b66c4c70d29bef4052e5345a73112c5 (diff)
downloadserenity-4e3a1f2da9a20c40421eec033c379b9275a5b77d.zip
Hearts: Move hand sorting functionality into a method
-rw-r--r--Userland/Games/Hearts/Game.cpp2
-rw-r--r--Userland/Games/Hearts/Player.h2
2 files changed, 3 insertions, 1 deletions
diff --git a/Userland/Games/Hearts/Game.cpp b/Userland/Games/Hearts/Game.cpp
index 08a74ff8ac..a365889320 100644
--- a/Userland/Games/Hearts/Game.cpp
+++ b/Userland/Games/Hearts/Game.cpp
@@ -111,7 +111,7 @@ void Game::setup(String player_name)
}
player.hand.append(card);
}
- quick_sort(player.hand, hearts_card_less);
+ player.sort_hand();
auto card_position = player.first_card_position;
for (auto& card : player.hand) {
card->set_position(card_position);
diff --git a/Userland/Games/Hearts/Player.h b/Userland/Games/Hearts/Player.h
index 3688bcb626..11d33c5e53 100644
--- a/Userland/Games/Hearts/Player.h
+++ b/Userland/Games/Hearts/Player.h
@@ -30,6 +30,8 @@ public:
size_t pick_last_card();
bool has_card_of_type(Card::Type type);
+ void sort_hand() { quick_sort(hand, hearts_card_less); }
+
Vector<RefPtr<Card>> hand;
Vector<RefPtr<Card>> cards_taken;
Gfx::IntPoint first_card_position;