Every thing works perfectly only it will not check for a full house. Ive tried to figure out what the problem was by rewriting pair checking and three of a kind checking but the same result always. The function simply returns an integer corresponding to the hand stength given a 5 card hand.
in sCard iValue is an integer of the face value of the card. 1 = 2 and 13 = ace. The iSuit is an integer of the suit of the card. 0 = spades and 3 = diamonds. Everything else should be self explanatory. What happens is when there is a full house it returns as a three of a kind.

int GetHandValue(sHand5 Hand){
        int GetHandValue(sHand5 Hand){
        sCard PairCards[4];
        sCard ThreeOfAKindCard;
        sCard FourOfAKindCard;
        sCard Switch;
        bool Flush;
        bool Straight;
        int HandValue;
        //quickly check for flush
        for (int i = 0; i <= 3; i++){
            if (Hand.Card[i].iSuit == Hand.Card[i + 1].iSuit){if (!Flush){Flush = true;}}
            else {Flush = false; break;}
        }
        //do a bubble sort algorithm to sort the cards from smallest to biggest
        //temporarily use Straight bool for finish shorting trigger
        //and use Switch to switch two cards
        Straight = true;
        while(Straight){
            if (Hand.Card[0].iValue > Hand.Card[1].iValue){
                Switch = Hand.Card[0];
                Hand.Card[0] = Hand.Card[1];
                Hand.Card[1] = Switch;
            }
            else if (Hand.Card[1].iValue > Hand.Card[2].iValue){
                Switch = Hand.Card[1];
                Hand.Card[1] = Hand.Card[2];
                Hand.Card[2] = Switch;
            }
            else if (Hand.Card[2].iValue > Hand.Card[3].iValue){
                Switch = Hand.Card[2];
                Hand.Card[2] = Hand.Card[3];
                Hand.Card[3] = Switch;
            }
            else if (Hand.Card[3].iValue > Hand.Card[4].iValue){
                Switch = Hand.Card[3];
                Hand.Card[3] = Hand.Card[4];
                Hand.Card[4] = Switch;
            }
            else {Straight = false;}//the cards are now sorted
        }

        //check for a straight and check for 5 high straight (A 2 3 4 5)
        if (Hand.Card[0].iValue == Hand.Card[1].iValue - 1 &&
            Hand.Card[1].iValue == Hand.Card[2].iValue - 1 &&
            Hand.Card[2].iValue == Hand.Card[3].iValue - 1 &&
            Hand.Card[3].iValue == Hand.Card[4].iValue - 1){Straight = true;}
        else{Straight = false;}
        if (!Straight){
            if (Hand.Card[0].iValue == 1 && Hand.Card[1].iValue == 2 &&
                Hand.Card[2].iValue == 3 && Hand.Card[3].iValue == 4 &&
                Hand.Card[4].iValue == 13){Straight = true;}
        }

        //check for pairs
        int pairs = 0;// to tell which pair card to use
        if (Hand.Card[4].iValue == Hand.Card[3].iValue){pairs++; PairCards[0] = Hand.Card[4];}
        else if (Hand.Card[3].iValue == Hand.Card[2].iValue){
            pairs++;
            if (pairs == 2){PairCards[1] = Hand.Card[3];}
            else{PairCards[0] = Hand.Card[3];}
        }
        else if (Hand.Card[2].iValue == Hand.Card[1].iValue){
            pairs++;
            if (pairs == 3){PairCards[2] = Hand.Card[2];}
            else if (pairs == 2){PairCards[1] = Hand.Card[2];}
            else{PairCards[0] = Hand.Card[2];}
        }
        else if (Hand.Card[1].iValue == Hand.Card[0].iValue){
            pairs++;
            if (pairs == 4){PairCards[3] = Hand.Card[1];}
            else if (pairs == 3){PairCards[2] = Hand.Card[1];}
            else if (pairs == 2){PairCards[1] = Hand.Card[1];}
            else{PairCards[0] = Hand.Card[1];}
        }


        //check for three of a kind
        if (Hand.Card[4].iValue == Hand.Card[3].iValue &&
            Hand.Card[4].iValue == Hand.Card[2].iValue){ThreeOfAKindCard = Hand.Card[4];}
        else if (Hand.Card[3].iValue == Hand.Card[2].iValue &&
                 Hand.Card[3].iValue == Hand.Card[1].iValue){ThreeOfAKindCard = Hand.Card[3];}
        else if (Hand.Card[2].iValue == Hand.Card[1].iValue &&
                 Hand.Card[2].iValue == Hand.Card[0].iValue){ThreeOfAKindCard = Hand.Card[2];}
        else{ThreeOfAKindCard.iValue = 0;}

        //check for four of a kind
        if (Hand.Card[0].iValue == Hand.Card[1].iValue &&
            Hand.Card[1].iValue == Hand.Card[2].iValue &&
            Hand.Card[2].iValue == Hand.Card[3].iValue){FourOfAKindCard = Hand.Card[0];}
        else if (Hand.Card[1].iValue == Hand.Card[2].iValue &&
                 Hand.Card[2].iValue == Hand.Card[3].iValue &&
                 Hand.Card[3].iValue == Hand.Card[4].iValue){FourOfAKindCard = Hand.Card[1];}
        else{FourOfAKindCard.iValue = 0;}
        HandValue = 0;
        for (int i = 0; i <= 4; i++){HandValue += Hand.Card[i].iValue;}

        //set the hand value based on the information gathered
        if (Straight && Flush){HandValue += 8000;}
        else if (FourOfAKindCard.iValue != 0){HandValue += 7000;}
        else if (pairs == 2 && ThreeOfAKindCard.iValue != 0){HandValue += 6000;}
        else if (Flush){HandValue += 5000;}
        else if (Straight){HandValue += 4000;}
        else if (ThreeOfAKindCard.iValue != 0){HandValue += 3000 + (ThreeOfAKindCard.iValue * 15);}
        else if (pairs == 2){HandValue += 2000 + (PairCards[0].iValue * 15)+ (PairCards[1].iValue * 15);}
        else if (pairs == 1){HandValue += 1000 + (PairCards[0].iValue * 15);}
        return HandValue;

    }

Thank you for any help you give me.

Edited 6 Years Ago by noey699: code update

Did you try branching off from your 3 of a kind method?

bool FullHouse;
if (Hand.Card[4].iValue == Hand.Card[3].iValue && Hand.Card[4].iValue == Hand.Card[2].iValue)
{    
      if(Hand.Card[1].iValue == Hand.Card[5].iValue)
             FullHouse = true;
      else
      ThreeOfAKindCard = Hand.Card[4];
}
else if (...) etc.

I know it doesn't combine your pairs check with the three of a kind but if you don't "sequester" the three of a kind cards they'd be counted by the pair finder too. A solution would be to have a pair finding function that you could call both for both finding the pairs and finding the full house.

I didn't even think of that. I implemented it and it works perfectly. Thank you for the help.

This question has already been answered. Start a new discussion instead.