From 4e3a1f2da9a20c40421eec033c379b9275a5b77d Mon Sep 17 00:00:00 2001 From: Gunnar Beutner Date: Mon, 24 May 2021 10:27:05 +0200 Subject: [PATCH] Hearts: Move hand sorting functionality into a method --- Userland/Games/Hearts/Game.cpp | 2 +- Userland/Games/Hearts/Player.h | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) 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> hand; Vector> cards_taken; Gfx::IntPoint first_card_position;