Texas holdem straight check values
<p>I'm have a small issue with evaluating a straight in a seven card hand, where you want to get the highest 5 card straight.</p>

<p>I can get highest 5 card straight as long as there is not a pair in the hand so for example:</p>

<p>Hole cards: 2h,3d<br>
community cards:4h, 5s, 6s, 8d, 9d,<br>
Output: 2h,3d,4h,5s,6s</p>

<p>Because there is no pair within the straight it counts and outputs just fine.
The problem occurs when there is a pair within the straight
for example:</p>

<p>Hole cards: 2h, 3d,<br>
community cards: 4h, 4c, 5s, 6s, 8d<br>
Output: 2h,3d,4h,4c,5s</p>

<p>So it is counting the pair in the straight, I need a way to skip past one of the paired cards and select only one. This happens with 3 of a kind as well.</p>

<p>It makes complete sense to me why it is doing this, but for the life of me I can't think of a way to fix it.</p>

<p>Here is the function:</p>

<pre><code>bool Player::checkForStraight()
{
//Loops through the ranks from greatest to least 0 is NONE is the enum class
for (int i = FACES; i &gt;= 1; i--)
{
    //Checks to see if a straight exists (_checkNumfaces is an array[13] to
    //hold the amount of each card
    if ((_checkNumFaces[i - 1] &gt;= 1) &amp;&amp; (_checkNumFaces[i - 2] &gt;= 1) &amp;&amp;
        (_checkNumFaces[i - 3] &gt;= 1) &amp;&amp; (_checkNumFaces[i - 4] &gt;= 1) &amp;&amp;
        (_checkNumFaces[i - 5] &gt;= 1))
    {
        //If a straight exists loop through the cards(sorted in another 
        //function from lowest to highest
        for (int j = 6; j &gt;= 0; j--)
        {
                //if the face matches the enum value of i then we have a
                //straight there down because I checked if the straight
                //existed already
                if ((*p_playerHand[j])-&gt;face == (Face)(i))
                {
                    //PlayerHighCards out of the seven
                    p_playerHighFive[4] = p_playerHand[j];
                    p_playerHighFive[3] = p_playerHand[j - 1];
                    p_playerHighFive[2] = p_playerHand[j - 2];
                    p_playerHighFive[1] = p_playerHand[j - 3];
                    p_playerHighFive[0] = p_playerHand[j - 4];
                    return true;
                }
            }
    }
}
return false;
}
</code></pre>

<p>Sorry about the shoddy formatting at the bottom but its only curly braces and they are fine in my code.</p>

<p>I know how to check for A,2,3,4,5 straight I just havnt coded yet, I am just really stumped on how to move past one of the pairs that I was on about. Its not just pairs, this occurs with 3 of a kind as well (so if there's 3 of a kind in the straight) or more than one pair for that matter so 2 pairs. Doesn't happen outside of this because there's not physically enough cards to be concerned about it.</p>

<p>Sorry if my code is not that elegant and if there's a better way then let me know. I havnt learned templates or the stl yet as I have only just started the language so a solution not using these would be great.</p>

<p>I tried to be as descriptive as possible but, I'm new to this so if you have any questions just ask:)</p>

<p>Here is the function for counting the different cards in the deck</p>

<pre><code>    void Player::countNumFaces(const int&amp; size)
{

for (int i = 0; i &lt; (size); i++)
{
    switch((*p_playerHand[i])-&gt;face)
    {
    case Face::NONE:    std::cout &lt;&lt; "Joker" &lt;&lt; std::endl;
    case Face::TWO:     _checkNumFaces[0]  ++;  break;
    case Face::THREE:   _checkNumFaces[1]  ++;  break;
    case Face::FOUR:    _checkNumFaces[2]  ++;  break;
    case Face::FIVE:    _checkNumFaces[3]  ++;  break;
    case Face::SIX:     _checkNumFaces[4]  ++;  break;
    case Face::SEVEN:   _checkNumFaces[5]  ++;  break;
    case Face::EIGHT:   _checkNumFaces[6]  ++;  break;
    case Face::NINE:    _checkNumFaces[7]  ++;  break;
    case Face::TEN:     _checkNumFaces[8]  ++;  break;
    case Face::JACK:    _checkNumFaces[9]  ++;  break;
    case Face::QUEEN:   _checkNumFaces[10] ++;  break;
    case Face::KING:    _checkNumFaces[11] ++;  break;
    case Face::ACE:     _checkNumFaces[12] ++;  break;
    }
}

std::cout &lt;&lt; "| 2 || 3 || 4 || 5 || 6 || 7 || 8 || 9 | 10 || J || Q || K || A |" &lt;&lt; std::endl;      //Print for testing
for (int i = 0; i &lt; FACES; i++) { std::cout &lt;&lt; "| " &lt;&lt; _checkNumFaces[i] &lt;&lt; " |"; }                  //Print for testing
}
</code></pre>