Brunot
Loading...
Searching...
No Matches
HandRating.h
Go to the documentation of this file.
1
12// ____ __ __ __
13// /\__ _\/\ \ /\ \/\ \
14// \/_/\ \/\ \ \___ __ \ \ \_\ \ ___ __ __ ____ __
15// \ \ \ \ \ _ `\ /'__`\ \ \ _ \ / __`\/\ \/\ \ /',__\ /'__`\
16// \ \ \ \ \ \ \ \/\ __/ \ \ \ \ \/\ \L\ \ \ \_\ \/\__, `\/\ __/
17// \ \_\ \ \_\ \_\ \____\ \ \_\ \_\ \____/\ \____/\/\____/\ \____\
18// \/_/ \/_/\/_/\/____/ \/_/\/_/\/___/ \/___/ \/___/ \/____/
19
20
21#pragma once
22#include "Framework/System.h"
23#include "Component/Card.h"
24
25struct CategorizedHand;
26
27struct PlayerHand;
28
30{
31
32public:
33 // Enum of all possible hand types
34 enum class HandType : std::uint8_t
35 {
37 quads = 'Q', // Four of a kind
39 flush = 'F',
40 straight = 'S',
41 trips = 'T', // Three of a kind
42 two_pair = '2',
43 pair = 'P',
44 high_card = 'I',
45 nothing = 'N'
46 };
47
52 static auto Sort(PlayerHand& cards) -> void;
53
58 static auto checkHand(const PlayerHand& playerCards) -> CategorizedHand;
59
64 static auto CheckHands(const std::vector<PlayerHand>& hands) -> std::vector<CategorizedHand>;
65
66private:
72 static auto straightCheck(const PlayerHand& cards) -> bool;
73
79 static auto flushCheck(const PlayerHand& cards) -> bool;
80
84 static auto sameRankCheck(const PlayerHand& cards, const PlayerHand& originalCards, bool isVertical) -> CategorizedHand;
85
92 static auto checkContribution(const std::vector<Card*>::const_iterator& begin,
93 const std::vector<Card*>::const_iterator& end) -> bool;
94
95};
The card component that is moved around on the board.
Definition HandRating.h:30
static auto Sort(PlayerHand &cards) -> void
Sorts the cards in a player hand into ascending order.
Definition HandRating.cpp:24
static auto flushCheck(const PlayerHand &cards) -> bool
Analyzes a given hand and determines if it contains a flush or not.
Definition HandRating.cpp:132
HandType
Definition HandRating.h:35
@ trips
Definition HandRating.h:41
@ full_house
Definition HandRating.h:38
@ pair
Definition HandRating.h:43
@ quads
Definition HandRating.h:37
@ straight
Definition HandRating.h:40
@ nothing
Definition HandRating.h:45
@ straight_flush
Definition HandRating.h:36
@ flush
Definition HandRating.h:39
@ two_pair
Definition HandRating.h:42
@ high_card
Definition HandRating.h:44
static auto checkHand(const PlayerHand &playerCards) -> CategorizedHand
Analyzes a given hand and determines what kind of HandType it is worth.
Definition HandRating.cpp:33
static auto checkContribution(const std::vector< Card * >::const_iterator &begin, const std::vector< Card * >::const_iterator &end) -> bool
Checks if the current player contributed to the hand (if a card in it was played this turn).
Definition HandRating.cpp:326
static auto sameRankCheck(const PlayerHand &cards, const PlayerHand &originalCards, bool isVertical) -> CategorizedHand
Checks how many cards have the same rank and determines the best HandType available.
Definition HandRating.cpp:149
static auto CheckHands(const std::vector< PlayerHand > &hands) -> std::vector< CategorizedHand >
Analyzes a given vector of hands and determines what kind of HandType it is worth.
Definition HandRating.cpp:96
static auto straightCheck(const PlayerHand &cards) -> bool
Analyzes a given hand and determines if it contains a straight or not.
Definition HandRating.cpp:107
Definition CategorizedHand.h:32
Definition HandFinder.h:20