1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-28 01:17:46 +00:00

Hearts: Move sorting helper from Player::pick_lead_card into a method

This commit is contained in:
Gunnar Beutner 2021-05-24 14:15:52 +02:00 committed by Andreas Kling
parent 4ba9cc82c0
commit 89d38b7e94
2 changed files with 16 additions and 7 deletions

View file

@ -7,12 +7,18 @@
#pragma once
#include "Helpers.h"
#include <AK/QuickSort.h>
#include <LibCards/Card.h>
using Cards::Card;
namespace Hearts {
struct CardWithIndex {
NonnullRefPtr<Card> card;
size_t index;
};
struct Player {
AK_MAKE_NONMOVABLE(Player);
@ -29,6 +35,7 @@ public:
Optional<size_t> pick_specific_card(Card::Type type, CardValue value);
size_t pick_last_card();
bool has_card_of_type(Card::Type type);
Vector<CardWithIndex> hand_sorted_by_points_and_value() const;
void sort_hand() { quick_sort(hand, hearts_card_less); }