Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // evaluate this players hand
- public void DoHandEval()
- {
- // reset hand eval
- heartSum = 0;
- diamondSum = 0;
- clubSum = 0;
- spadeSum = 0;
- evalCards = new cardScript[7];
- handValue = new HandValue();
- // evaluate current hand
- evaluatedHand = EvaluateHand();
- // display the evaluated hand
- print(this.gameObject.ToString() + " Hand: " + evaluatedHand);
- }
- // stored hand evaluation variable
- public Hand EvaluateHand()
- {
- // collect player cards and community cards and set into cards array
- evalCards[0] = card1.GetComponent<cardScript>();
- evalCards[1] = card2.GetComponent<cardScript>();
- evalCards[2] = gm.communityCard1.GetComponent<cardScript>();
- evalCards[3] = gm.communityCard2.GetComponent<cardScript>();
- evalCards[4] = gm.communityCard3.GetComponent<cardScript>();
- evalCards[5] = gm.communityCard4.GetComponent<cardScript>();
- evalCards[6] = gm.communityCard5.GetComponent<cardScript>();
- // get the number of each suit on hand
- getNumberOfSuit();
- // evaluate the hand for conditions
- if (RoyalFlush())
- return Hand.RoyalFlush;
- else if (StraightFlush())
- return Hand.StraightFlush;
- else if (FourOfKind())
- return Hand.FourKind;
- else if (FullHouse())
- return Hand.FullHouse;
- else if (Flush())
- return Hand.Flush;
- else if (Straight())
- return Hand.Straight;
- else if (ThreeOfKind())
- return Hand.ThreeKind;
- else if (TwoPairs())
- return Hand.TwoPairs;
- else if (OnePair())
- return Hand.OnePair;
- // if hand == nothing then hand with highest card wins
- // sort the cards in order of value
- evalCards = evalCards.OrderBy(x => x.myValue).ToArray();
- handValue.Kicker1 = (int)evalCards[6].myValue;
- handValue.Kicker2 = (int)evalCards[5].myValue;
- handValue.Kicker3 = (int)evalCards[4].myValue;
- handValue.Kicker4 = (int)evalCards[3].myValue;
- handValue.Kicker5 = (int)evalCards[2].myValue;
- return Hand.HighCard;
- }
- // count the number of cards of each suit
- private void getNumberOfSuit()
- {
- foreach (var element in evalCards)
- {
- if (element.mySuit == cardScript.suit.Heart)
- heartSum++;
- else if (element.mySuit == cardScript.suit.Diamond)
- diamondSum++;
- else if (element.mySuit == cardScript.suit.Club)
- clubSum++;
- else if (element.mySuit == cardScript.suit.Spade)
- spadeSum++;
- }
- }
- // evaulate cards for a royal flush
- private bool RoyalFlush()
- {
- // if all suits are the same
- if (heartSum == 5 || diamondSum == 5 || clubSum == 5 || spadeSum == 5)
- {
- // make a new array to store all suit cards in flush for checking
- cardScript[] suitArray = new cardScript[5];
- // sort the cards in order of suit
- evalCards = evalCards.OrderBy(x => x.mySuit).ToArray();
- // if first 5 evalCards are same suit
- if (evalCards[0].mySuit == evalCards[4].mySuit)
- {
- // store evalCards in suitArray for checking
- suitArray[0] = evalCards[0];
- suitArray[1] = evalCards[1];
- suitArray[2] = evalCards[2];
- suitArray[3] = evalCards[3];
- suitArray[4] = evalCards[4];
- // reorder suitArray cards in order of value
- suitArray = suitArray.OrderBy(x => x.myValue).ToArray();
- // if evalCards == royal flush
- if (suitArray[0].myValue == cardScript.value.Ten &&
- suitArray[1].myValue == cardScript.value.Jack &&
- suitArray[2].myValue == cardScript.value.Queen &&
- suitArray[3].myValue == cardScript.value.King &&
- suitArray[4].myValue == cardScript.value.Ace)
- {
- // player with the highest value last card wins
- handValue.Total = (int)suitArray[4].myValue;
- return true;
- }
- }
- // if evalCards 2 to 6 are same suit
- else if (evalCards[1].mySuit == evalCards[5].mySuit)
- {
- // store evalCards in suitArray for checking
- suitArray[0] = evalCards[1];
- suitArray[1] = evalCards[2];
- suitArray[2] = evalCards[3];
- suitArray[3] = evalCards[4];
- suitArray[4] = evalCards[5];
- // reorder suitArray cards in order of value
- suitArray = suitArray.OrderBy(x => x.myValue).ToArray();
- // if evalCards == royal flush
- if (suitArray[0].myValue == cardScript.value.Ten &&
- suitArray[1].myValue == cardScript.value.Jack &&
- suitArray[2].myValue == cardScript.value.Queen &&
- suitArray[3].myValue == cardScript.value.King &&
- suitArray[4].myValue == cardScript.value.Ace)
- {
- // player with the highest value last card wins
- handValue.Total = (int)suitArray[4].myValue;
- return true;
- }
- }
- // if evalCards 3 to 7 are same suit
- else if (evalCards[2].mySuit == evalCards[6].mySuit)
- {
- // store evalCards in suitArray for checking
- suitArray[0] = evalCards[2];
- suitArray[1] = evalCards[3];
- suitArray[2] = evalCards[4];
- suitArray[3] = evalCards[5];
- suitArray[4] = evalCards[6];
- // reorder suitArray cards in order of value
- suitArray = suitArray.OrderBy(x => x.myValue).ToArray();
- // if evalCards == royal flush
- if (suitArray[0].myValue == cardScript.value.Ten &&
- suitArray[1].myValue == cardScript.value.Jack &&
- suitArray[2].myValue == cardScript.value.Queen &&
- suitArray[3].myValue == cardScript.value.King &&
- suitArray[4].myValue == cardScript.value.Ace)
- {
- // player with the highest value last card wins
- handValue.Total = (int)suitArray[4].myValue;
- return true;
- }
- }
- }
- return false;
- }
- // evaulate cards for a straight flush
- private bool StraightFlush()
- {
- // if all suits are the same
- if (heartSum == 5 || diamondSum == 5 || clubSum == 5 || spadeSum == 5)
- {
- // make a new array to store all suit cards in flush for checking
- cardScript[] suitArray = new cardScript[5];
- // sort the cards in order of suit
- evalCards = evalCards.OrderBy(x => x.mySuit).ToArray();
- // if first 5 evalCards are same suit
- if (evalCards[0].mySuit == evalCards[4].mySuit)
- {
- // store evalCards in suitArray for checking
- suitArray[0] = evalCards[0];
- suitArray[1] = evalCards[1];
- suitArray[2] = evalCards[2];
- suitArray[3] = evalCards[3];
- suitArray[4] = evalCards[4];
- // reorder suitArray cards in order of value
- suitArray = suitArray.OrderBy(x => x.myValue).ToArray();
- // if 5 consecutive valued evalCards
- if (suitArray[0].myValue + 1 == suitArray[1].myValue &&
- suitArray[1].myValue + 1 == suitArray[2].myValue &&
- suitArray[2].myValue + 1 == suitArray[3].myValue &&
- suitArray[3].myValue + 1 == suitArray[4].myValue)
- {
- // player with the highest value last card wins
- handValue.Total = (int)suitArray[4].myValue;
- return true;
- }
- // if low Ace straight
- else if (suitArray[4].myValue - 11 == suitArray[0].myValue &&
- suitArray[0].myValue + 1 == suitArray[1].myValue &&
- suitArray[1].myValue + 1 == suitArray[2].myValue &&
- suitArray[2].myValue + 1 == suitArray[3].myValue)
- {
- // player with the highest value last card wins
- handValue.Total = (int)suitArray[3].myValue;
- return true;
- }
- }
- // if evalCards 2 to 6 are same suit
- else if (evalCards[1].mySuit == evalCards[5].mySuit)
- {
- // store evalCards in suitArray for checking
- suitArray[0] = evalCards[1];
- suitArray[1] = evalCards[2];
- suitArray[2] = evalCards[3];
- suitArray[3] = evalCards[4];
- suitArray[4] = evalCards[5];
- // reorder suitArray cards in order of value
- suitArray = suitArray.OrderBy(x => x.myValue).ToArray();
- // if 5 consecutive valued evalCards
- if (suitArray[0].myValue + 1 == suitArray[1].myValue &&
- suitArray[1].myValue + 1 == suitArray[2].myValue &&
- suitArray[2].myValue + 1 == suitArray[3].myValue &&
- suitArray[3].myValue + 1 == suitArray[4].myValue)
- {
- // player with the highest value last card wins
- handValue.Total = (int)suitArray[4].myValue;
- return true;
- }
- // if low Ace straight
- else if (suitArray[4].myValue - 11 == suitArray[0].myValue &&
- suitArray[0].myValue + 1 == suitArray[1].myValue &&
- suitArray[1].myValue + 1 == suitArray[2].myValue &&
- suitArray[2].myValue + 1 == suitArray[3].myValue)
- {
- // player with the highest value last card wins
- handValue.Total = (int)suitArray[3].myValue;
- return true;
- }
- }
- // if evalCards 3 to 7 are same suit
- else if (evalCards[2].mySuit == evalCards[6].mySuit)
- {
- // store evalCards in suitArray for checking
- suitArray[0] = evalCards[2];
- suitArray[1] = evalCards[3];
- suitArray[2] = evalCards[4];
- suitArray[3] = evalCards[5];
- suitArray[4] = evalCards[6];
- // reorder suitArray cards in order of value
- suitArray = suitArray.OrderBy(x => x.myValue).ToArray();
- // if 5 consecutive valued evalCards
- if (suitArray[0].myValue + 1 == suitArray[1].myValue &&
- suitArray[1].myValue + 1 == suitArray[2].myValue &&
- suitArray[2].myValue + 1 == suitArray[3].myValue &&
- suitArray[3].myValue + 1 == suitArray[4].myValue)
- {
- // player with the highest value last card wins
- handValue.Total = (int)suitArray[4].myValue;
- return true;
- }
- // if low Ace straight
- else if (suitArray[4].myValue - 11 == suitArray[0].myValue &&
- suitArray[0].myValue + 1 == suitArray[1].myValue &&
- suitArray[1].myValue + 1 == suitArray[2].myValue &&
- suitArray[2].myValue + 1 == suitArray[3].myValue)
- {
- // player with the highest value last card wins
- handValue.Total = (int)suitArray[3].myValue;
- return true;
- }
- }
- }
- return false;
- }
- // evaulate cards for four of a kind
- private bool FourOfKind()
- {
- // sort the cards in order of value
- evalCards = evalCards.OrderBy(x => x.myValue).ToArray();
- // if the first card and 4th card values are identical we have 4 of a kind
- if (evalCards[0].myValue == evalCards[3].myValue)
- {
- handValue.Total = (int)evalCards[0].myValue * 4;
- handValue.Kicker1 = (int)evalCards[6].myValue;
- return true;
- }
- // if the second and 5th card values are identical we have 4 of a kind
- else if (evalCards[1].myValue == evalCards[4].myValue)
- {
- handValue.Total = (int)evalCards[1].myValue * 4;
- handValue.Kicker1 = (int)evalCards[6].myValue;
- return true;
- }
- // if the third and sixth card values are identical we have 4 of a kind
- else if (evalCards[2].myValue == evalCards[5].myValue)
- {
- handValue.Total = (int)evalCards[2].myValue * 4;
- handValue.Kicker1 = (int)evalCards[6].myValue;
- return true;
- }
- // if the fourth and seveth card values are identical we have 4 of a kind
- else if (evalCards[3].myValue == evalCards[6].myValue)
- {
- handValue.Total = (int)evalCards[3].myValue * 4;
- handValue.Kicker1 = (int)evalCards[2].myValue;
- return true;
- }
- return false;
- }
- // evaluate cards for a full house
- private bool FullHouse()
- {
- // sort the cards in order of value
- evalCards = evalCards.OrderBy(x => x.myValue).ToArray();
- // if evalCards 1 through 3 are the same
- if (evalCards[0].myValue == evalCards[2].myValue)
- {
- // and if evalCards 4 and 5 are the same
- if (evalCards[3].myValue == evalCards[4].myValue)
- {
- // if 2 or more players have a full house the player with the best three of a kind wins
- handValue.Total = (int)evalCards[0].myValue * 3;
- // 2 of or more players have the same three of a kind the best pair wins
- handValue.Kicker1 = (int)evalCards[3].myValue * 2;
- return true;
- }
- // or if evalCards 5 and 6 are the same
- else if (evalCards[4].myValue == evalCards[5].myValue)
- {
- // if 2 or more players have a full house the player with the best three of a kind wins
- handValue.Total = (int)evalCards[0].myValue * 3;
- // 2 of or more players have the same three of a kind the best pair wins
- handValue.Kicker1 = (int)evalCards[4].myValue * 2;
- return true;
- }
- // or if evalCards 6 and 7 are the same
- else if (evalCards[5].myValue == evalCards[6].myValue)
- {
- // if 2 or more players have a full house the player with the best three of a kind wins
- handValue.Total = (int)evalCards[0].myValue * 3;
- // 2 of or more players have the same three of a kind the best pair wins
- handValue.Kicker1 = (int)evalCards[5].myValue * 2;
- return true;
- }
- }
- // or if evalCards 2 through 4 are the same
- else if (evalCards[1].myValue == evalCards[3].myValue)
- {
- // and evalCards 5 and 6 are the same
- if (evalCards[4].myValue == evalCards[5].myValue)
- {
- // if 2 or more players have a full house the player with the best three of a kind wins
- handValue.Total = (int)evalCards[1].myValue * 3;
- // 2 of or more players have the same three of a kind the best pair wins
- handValue.Kicker1 = (int)evalCards[4].myValue * 2;
- return true;
- }
- // or evalCards 6 and 7 are the same
- else if (evalCards[5].myValue == evalCards[6].myValue)
- {
- // if 2 or more players have a full house the player with the best three of a kind wins
- handValue.Total = (int)evalCards[1].myValue * 3;
- // 2 of or more players have the same three of a kind the best pair wins
- handValue.Kicker1 = (int)evalCards[5].myValue * 2;
- return true;
- }
- }
- // or if evalCards 3 through 5 are the same
- else if (evalCards[2].myValue == evalCards[4].myValue)
- {
- // and evalCards 6 and 7 are the same
- if (evalCards[5].myValue == evalCards[6].myValue)
- {
- // if 2 or more players have a full house the player with the best three of a kind wins
- handValue.Total = (int)evalCards[2].myValue * 3;
- // 2 of or more players have the same three of a kind the best pair wins
- handValue.Kicker1 = (int)evalCards[5].myValue * 2;
- return true;
- }
- // or evalCards 1 and 2 are the same
- else if (evalCards[0].myValue == evalCards[1].myValue)
- {
- // if 2 or more players have a full house the player with the best three of a kind wins
- handValue.Total = (int)evalCards[2].myValue * 3;
- // 2 of or more players have the same three of a kind the best pair wins
- handValue.Kicker1 = (int)evalCards[0].myValue * 2;
- return true;
- }
- }
- // or if evalCards 4 through 6 are the same
- else if (evalCards[3].myValue == evalCards[5].myValue)
- {
- // and evalCards 1 and 2 are the same
- if (evalCards[0].myValue == evalCards[1].myValue)
- {
- // if 2 or more players have a full house the player with the best three of a kind wins
- handValue.Total = (int)evalCards[3].myValue * 3;
- // 2 of or more players have the same three of a kind the best pair wins
- handValue.Kicker1 = (int)evalCards[0].myValue * 2;
- return true;
- }
- // or evalCards 2 and 3 are the same
- else if (evalCards[1].myValue == evalCards[2].myValue)
- {
- // if 2 or more players have a full house the player with the best three of a kind wins
- handValue.Total = (int)evalCards[3].myValue * 3;
- // 2 of or more players have the same three of a kind the best pair wins
- handValue.Total = (int)evalCards[1].myValue * 2;
- return true;
- }
- }
- // or if evalCards 5 through 7 are the same
- else if (evalCards[4].myValue == evalCards[6].myValue)
- {
- // amd evalCards 1 and 2 are the same
- if (evalCards[0].myValue == evalCards[1].myValue)
- {
- // if 2 or more players have a full house the player with the best three of a kind wins
- handValue.Total = (int)evalCards[4].myValue * 3;
- // 2 of or more players have the same three of a kind the best pair wins
- handValue.Kicker1 = (int)evalCards[0].myValue * 2;
- return true;
- }
- // or if evalCards 2 and 3 are the same
- else if (evalCards[1].myValue == evalCards[2].myValue)
- {
- // if 2 or more players have a full house the player with the best three of a kind wins
- handValue.Total = (int)evalCards[4].myValue * 3;
- // 2 of or more players have the same three of a kind the best pair wins
- handValue.Kicker1 = (int)evalCards[1].myValue * 2;
- return true;
- }
- // or if evalCards 3 and 4 are the same
- else if (evalCards[2].myValue == evalCards[3].myValue)
- {
- // if 2 or more players have a full house the player with the best three of a kind wins
- handValue.Total = (int)evalCards[4].myValue * 3;
- // 2 of or more players have the same three of a kind the best pair wins
- handValue.Kicker1 = (int)evalCards[2].myValue * 2;
- return true;
- }
- }
- return false;
- }
- // evaluate cards for a flush
- private bool Flush()
- {
- // if all suits are the same
- if (heartSum == 5 || diamondSum == 5 || clubSum == 5 || spadeSum == 5)
- {
- // make a new array to store all suit cards in flush for checking
- cardScript[] suitArray = new cardScript[5];
- // sort the cards in order of suit
- evalCards = evalCards.OrderBy(x => x.mySuit).ToArray();
- // if first 5 evalCards are same suit
- if (evalCards[0].mySuit == evalCards[4].mySuit)
- {
- // store evalCards in suitArray for checking
- suitArray[0] = evalCards[0];
- suitArray[1] = evalCards[1];
- suitArray[2] = evalCards[2];
- suitArray[3] = evalCards[3];
- suitArray[4] = evalCards[4];
- // reorder suitArray cards in order of value
- suitArray = suitArray.OrderBy(x => x.myValue).ToArray();
- // if flush, the player with the higher cards wins
- handValue.Total = (int)suitArray[0].myValue + (int)suitArray[1].myValue + (int)suitArray[2].myValue + (int)suitArray[3].myValue + (int)suitArray[4].myValue;
- handValue.Kicker1 = (int)evalCards[4].myValue;
- handValue.Kicker2 = (int)evalCards[3].myValue;
- handValue.Kicker3 = (int)evalCards[2].myValue;
- handValue.Kicker4 = (int)evalCards[1].myValue;
- handValue.Kicker5 = (int)evalCards[0].myValue;
- return true;
- }
- // if evalCards 2 to 6 are same suit
- else if (evalCards[1].mySuit == evalCards[5].mySuit)
- {
- // store evalCards in suitArray for checking
- suitArray[0] = evalCards[1];
- suitArray[1] = evalCards[2];
- suitArray[2] = evalCards[3];
- suitArray[3] = evalCards[4];
- suitArray[4] = evalCards[5];
- // reorder suitArray cards in order of value
- suitArray = suitArray.OrderBy(x => x.myValue).ToArray();
- // if flush, the player with the higher cards wins
- handValue.Total = (int)suitArray[0].myValue + (int)suitArray[1].myValue + (int)suitArray[2].myValue + (int)suitArray[3].myValue + (int)suitArray[4].myValue;
- handValue.Kicker1 = (int)evalCards[5].myValue;
- handValue.Kicker2 = (int)evalCards[4].myValue;
- handValue.Kicker3 = (int)evalCards[3].myValue;
- handValue.Kicker4 = (int)evalCards[2].myValue;
- handValue.Kicker5 = (int)evalCards[1].myValue;
- return true;
- }
- // if evalCards 3 to 7 are same suit
- else if (evalCards[2].mySuit == evalCards[6].mySuit)
- {
- // store evalCards in suitArray for checking
- suitArray[0] = evalCards[2];
- suitArray[1] = evalCards[3];
- suitArray[2] = evalCards[4];
- suitArray[3] = evalCards[5];
- suitArray[4] = evalCards[6];
- // reorder suitArray cards in order of value
- suitArray = suitArray.OrderBy(x => x.myValue).ToArray();
- // if flush, the player with the higher cards wins
- handValue.Total = (int)suitArray[0].myValue + (int)suitArray[1].myValue + (int)suitArray[2].myValue + (int)suitArray[3].myValue + (int)suitArray[4].myValue;
- handValue.Kicker1 = (int)evalCards[6].myValue;
- handValue.Kicker2 = (int)evalCards[5].myValue;
- handValue.Kicker3 = (int)evalCards[4].myValue;
- handValue.Kicker4 = (int)evalCards[3].myValue;
- handValue.Kicker5 = (int)evalCards[2].myValue;
- return true;
- }
- }
- return false;
- }
- // evaluate cards for a straight
- private bool Straight()
- {
- // sort the evalCards in order of value
- evalCards = evalCards.OrderBy(x => x.myValue).ToArray();
- // if 5 consecutive valued evalCards
- if (evalCards[0].myValue + 1 == evalCards[1].myValue &&
- evalCards[1].myValue + 1 == evalCards[2].myValue &&
- evalCards[2].myValue + 1 == evalCards[3].myValue &&
- evalCards[3].myValue + 1 == evalCards[4].myValue)
- {
- // player with the highest value last card wins
- handValue.Total = (int)evalCards[4].myValue;
- return true;
- }
- else if (evalCards[1].myValue + 1 == evalCards[2].myValue &&
- evalCards[2].myValue + 1 == evalCards[3].myValue &&
- evalCards[3].myValue + 1 == evalCards[4].myValue &&
- evalCards[4].myValue + 1 == evalCards[5].myValue)
- {
- // player with the highest value last card wins
- handValue.Total = (int)evalCards[5].myValue;
- return true;
- }
- else if (evalCards[2].myValue + 1 == evalCards[3].myValue &&
- evalCards[3].myValue + 1 == evalCards[4].myValue &&
- evalCards[4].myValue + 1 == evalCards[5].myValue &&
- evalCards[5].myValue + 1 == evalCards[6].myValue)
- {
- // player with the highest value last card wins
- handValue.Total = (int)evalCards[6].myValue;
- return true;
- }
- // check for low Ace straight
- else if (evalCards[6].myValue - 11 == evalCards[0].myValue &&
- evalCards[0].myValue + 1 == evalCards[1].myValue &&
- evalCards[1].myValue + 1 == evalCards[2].myValue &&
- evalCards[2].myValue + 1 == evalCards[3].myValue)
- {
- // player with the highest value last card wins
- handValue.Total = (int)evalCards[3].myValue;
- return true;
- }
- return false;
- }
- // evaulate cards for three of a kind
- private bool ThreeOfKind()
- {
- // sort the evalCards in order of value
- evalCards = evalCards.OrderBy(x => x.myValue).ToArray();
- // if first 3 evalCards are the same
- if (evalCards[0].myValue == evalCards[2].myValue)
- {
- handValue.Total = (int)evalCards[2].myValue * 3;
- handValue.Kicker1 = (int)evalCards[6].myValue;
- handValue.Kicker2 = (int)evalCards[5].myValue;
- return true;
- }
- // OR 2-3-4 evalCards are the same
- else if (evalCards[1].myValue == evalCards[3].myValue)
- {
- handValue.Total = (int)evalCards[3].myValue * 3;
- handValue.Kicker1 = (int)evalCards[6].myValue;
- handValue.Kicker2 = (int)evalCards[5].myValue;
- return true;
- }
- // OR 3-4-5 are the same
- else if (evalCards[2].myValue == evalCards[4].myValue)
- {
- handValue.Total = (int)evalCards[4].myValue * 3;
- handValue.Kicker1 = (int)evalCards[6].myValue;
- handValue.Kicker2 = (int)evalCards[5].myValue;
- return true;
- }
- // OR 4-5-6 are the same
- else if (evalCards[3].myValue == evalCards[5].myValue)
- {
- handValue.Total = (int)evalCards[5].myValue * 3;
- handValue.Kicker1 = (int)evalCards[6].myValue;
- handValue.Kicker2 = (int)evalCards[2].myValue;
- return true;
- }
- // OR 5-6-7 are the same
- else if (evalCards[4].myValue == evalCards[6].myValue)
- {
- handValue.Total = (int)evalCards[6].myValue * 3;
- handValue.Kicker1 = (int)evalCards[3].myValue;
- handValue.Kicker2 = (int)evalCards[2].myValue;
- return true;
- }
- return false;
- }
- // evaulate cards for two pairs
- private bool TwoPairs()
- {
- // sort the evalCards in order of value
- evalCards = evalCards.OrderBy(x => x.myValue).ToArray();
- // if evalCards 5,6 are same
- if (evalCards[6].myValue == evalCards[5].myValue)
- {
- // and evalCards 3/4 are same
- if (evalCards[4].myValue == evalCards[3].myValue)
- {
- // determine value of highes value pair cards in hand
- handValue.Total = (int)evalCards[6].myValue * 2;
- // determine value of second pair of cards in player hand
- handValue.Kicker1 = (int)evalCards[4].myValue * 2;
- // determine value of remaining kicker
- handValue.Kicker2 = (int)evalCards[2].myValue;
- return true;
- }
- // or evalCards 2/3 are the same
- else if (evalCards[3].myValue == evalCards[2].myValue)
- {
- // determine value of highes value pair cards in hand
- handValue.Total = (int)evalCards[6].myValue * 2;
- // determine value of second pair of cards in player hand
- handValue.Kicker1 = (int)evalCards[3].myValue * 2;
- // determine value of remaining kicker
- handValue.Kicker2 = (int)evalCards[4].myValue;
- return true;
- }
- // or evalCards 1/2 are the same
- else if (evalCards[2].myValue == evalCards[1].myValue)
- {
- // determine value of highes value pair cards in hand
- handValue.Total = (int)evalCards[6].myValue * 2;
- // determine value of second pair of cards in player hand
- handValue.Kicker1 = (int)evalCards[2].myValue * 2;
- // determine value of remaining kicker
- handValue.Kicker2 = (int)evalCards[4].myValue;
- return true;
- }
- // or evalCards 0/1 are the same
- else if (evalCards[1].myValue == evalCards[0].myValue)
- {
- // determine value of highes value pair cards in hand
- handValue.Total = (int)evalCards[6].myValue * 2;
- // determine value of second pair of cards in player hand
- handValue.Kicker1 = (int)evalCards[1].myValue * 2;
- // determine value of remaining kicker
- handValue.Kicker2 = (int)evalCards[4].myValue;
- return true;
- }
- }
- // if evalCards 4/5 are the same
- else if (evalCards[5].myValue == evalCards[4].myValue)
- {
- // and evalCards 2/3 are the same
- if (evalCards[3].myValue == evalCards[2].myValue)
- {
- // determine value of highes value pair cards in hand
- handValue.Total = (int)evalCards[5].myValue * 2;
- // determine value of second pair of cards in player hand
- handValue.Kicker1 = (int)evalCards[3].myValue * 2;
- // determine value of remaining kicker
- handValue.Kicker2 = (int)evalCards[6].myValue;
- return true;
- }
- // or evalCards 1/2 are the same
- else if (evalCards[2].myValue == evalCards[1].myValue)
- {
- // determine value of highes value pair cards in hand
- handValue.Total = (int)evalCards[5].myValue * 2;
- // determine value of second pair of cards in player hand
- handValue.Kicker1 = (int)evalCards[2].myValue * 2;
- // determine value of remaining kicker
- handValue.Kicker2 = (int)evalCards[6].myValue;
- return true;
- }
- // or evalCards 0/1 are the same
- else if (evalCards[1].myValue == evalCards[0].myValue)
- {
- // determine value of highes value pair cards in hand
- handValue.Total = (int)evalCards[5].myValue * 2;
- // determine value of second pair of cards in player hand
- handValue.Kicker1 = (int)evalCards[1].myValue * 2;
- // determine value of remaining kicker
- handValue.Kicker2 = (int)evalCards[6].myValue;
- return true;
- }
- }
- // if cards 3/4 are the same
- else if (evalCards[4].myValue == evalCards[3].myValue)
- {
- // and cards 1/2 are the same
- if (evalCards[2].myValue == evalCards[1].myValue)
- {
- // determine value of highes value pair cards in hand
- handValue.Total = (int)evalCards[4].myValue * 2;
- // determine value of second pair of cards in player hand
- handValue.Kicker1 = (int)evalCards[2].myValue * 2;
- // determine value of remaining kicker
- handValue.Kicker2 = (int)evalCards[6].myValue;
- return true;
- }
- // or cards 0/1 are the same
- else if (evalCards[1].myValue == evalCards[0].myValue)
- {
- // determine value of highes value pair cards in hand
- handValue.Total = (int)evalCards[4].myValue * 2;
- // determine value of second pair of cards in player hand
- handValue.Kicker1 = (int)evalCards[1].myValue * 2;
- // determine value of remaining kicker
- handValue.Kicker2 = (int)evalCards[6].myValue;
- return true;
- }
- }
- // if cards 2/3 are the same
- else if (evalCards[3].myValue == evalCards[2].myValue)
- {
- // and cards 0/1 are the same
- if (evalCards[1].myValue == evalCards[0].myValue)
- {
- // determine value of highes value pair cards in hand
- handValue.Total = (int)evalCards[3].myValue * 2;
- // determine value of second pair of cards in player hand
- handValue.Kicker1 = (int)evalCards[1].myValue * 2;
- // determine value of remaining kicker
- handValue.Kicker2 = (int)evalCards[6].myValue;
- return true;
- }
- }
- return false;
- }
- // evaulate cards for one pair
- private bool OnePair()
- {
- // sort the evalCards in order of value
- evalCards = evalCards.OrderBy(x => x.myValue).ToArray();
- // if 1/2 are same
- if (evalCards[0].myValue == evalCards[1].myValue)
- {
- handValue.Total = (int)evalCards[1].myValue * 2;
- handValue.Kicker1 = (int)evalCards[6].myValue;
- handValue.Kicker2 = (int)evalCards[5].myValue;
- handValue.Kicker3 = (int)evalCards[4].myValue;
- return true;
- }
- // if 2/3 are same
- else if (evalCards[1].myValue == evalCards[2].myValue)
- {
- handValue.Total = (int)evalCards[2].myValue * 2;
- handValue.Kicker1 = (int)evalCards[6].myValue;
- handValue.Kicker2 = (int)evalCards[5].myValue;
- handValue.Kicker3 = (int)evalCards[4].myValue;
- return true;
- }
- // if 3/4 are same
- else if (evalCards[2].myValue == evalCards[3].myValue)
- {
- handValue.Total = (int)evalCards[3].myValue * 2;
- handValue.Kicker1 = (int)evalCards[6].myValue;
- handValue.Kicker2 = (int)evalCards[5].myValue;
- handValue.Kicker3 = (int)evalCards[4].myValue;
- return true;
- }
- // if 4/5 are same
- else if (evalCards[3].myValue == evalCards[4].myValue)
- {
- handValue.Total = (int)evalCards[4].myValue * 2;
- handValue.Kicker1 = (int)evalCards[6].myValue;
- handValue.Kicker2 = (int)evalCards[5].myValue;
- handValue.Kicker3 = (int)evalCards[2].myValue;
- return true;
- }
- // if 5/6 are same
- else if (evalCards[4].myValue == evalCards[5].myValue)
- {
- handValue.Total = (int)evalCards[5].myValue * 2;
- handValue.Kicker1 = (int)evalCards[6].myValue;
- handValue.Kicker2 = (int)evalCards[3].myValue;
- handValue.Kicker3 = (int)evalCards[2].myValue;
- return true;
- }
- // if 6/7 are same
- else if (evalCards[5].myValue == evalCards[6].myValue)
- {
- handValue.Total = (int)evalCards[6].myValue * 2;
- handValue.Kicker1 = (int)evalCards[4].myValue;
- handValue.Kicker2 = (int)evalCards[3].myValue;
- handValue.Kicker3 = (int)evalCards[2].myValue;
- return true;
- }
- return false;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement