1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-27 14:57:35 +00:00

LibCards+Games: Replace card "value" int with a Rank enum

Because `card->value() == 11` is a lot less clear than `card->rank() ==
Cards::Rank::Queen`, and also safer.

Put this, along with the `Suit` enum, in the `Cards` namespace directly
instead of inside `Cards::Card`. Slightly less typing that way.
This commit is contained in:
Sam Atkins 2022-08-20 20:21:33 +01:00 committed by Andreas Kling
parent 163a74e3e2
commit aac2488d5c
9 changed files with 121 additions and 75 deletions

View file

@ -35,13 +35,13 @@ public:
NonnullRefPtrVector<Card> pick_cards_to_pass(PassingDirection);
size_t pick_lead_card(Function<bool(Card&)>, Function<bool(Card&)>);
Optional<size_t> pick_low_points_high_value_card(Optional<Card::Suit> suit = {});
Optional<size_t> pick_low_points_high_value_card(Optional<Cards::Suit> suit = {});
Optional<size_t> pick_lower_value_card(Card& other_card);
Optional<size_t> pick_slightly_higher_value_card(Card& other_card);
size_t pick_max_points_card(Function<bool(Card&)>);
Optional<size_t> pick_specific_card(Card::Suit suit, CardValue value);
Optional<size_t> pick_specific_card(Cards::Suit suit, CardValue value);
size_t pick_last_card();
bool has_card_of_suit(Card::Suit suit);
bool has_card_of_suit(Cards::Suit suit);
Vector<CardWithIndex> hand_sorted_by_fn(bool (*)(CardWithIndex&, CardWithIndex&)) const;
void sort_hand() { quick_sort(hand, hearts_card_less); }