Advertisement
Guest User

Untitled

a guest
May 27th, 2017
82
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 2.77 KB | None | 0 0
  1. <?php
  2.  
  3. $card_one_suit = $_POST['card_one_suit'];
  4. $card_two_suit = $_POST['card_two_suit'];
  5. $card_three_suit = $_POST['card_three_suit'];
  6. $card_four_suit = $_POST['card_four_suit'];
  7. $card_five_suit = $_POST['card_five_suit'];
  8.  
  9. $card_one = $_POST['card_one'];
  10. $card_two = $_POST['card_two'];
  11. $card_three = $_POST['card_three'];
  12. $card_four = $_POST['card_four'];
  13. $card_five = $_POST['card_five'];
  14.  
  15. $player = $_POST['name'];
  16. $total_card_amount = $card_one + $card_two + $card_three + $card_four + $card_five;
  17.  
  18. $card_list = array();
  19. array_push($card_list, $card_one, $card_two, $card_three, $card_four, $card_five);
  20. $card_suits = array();
  21. array_push($card_suits, $card_one_suit, $card_two_suit, $card_three_suit,         $card_four_suit, $card_five_suit);
  22. $rank = 0;
  23.  
  24. foreach($card_list as $card)
  25. {
  26.    $count_values[$card]++;
  27. }
  28.  
  29. foreach($card_suits as $cards)
  30. {
  31.     $count_suit_values[$cards]++;
  32. }
  33.  
  34. //echo "$count_suit_values[$card_one_suit]";
  35.  
  36. //print_r($count_suit_values);
  37.  
  38. // ROYAL FLUSH
  39. if(($total_card_amount == "60") && ($count_suit_values[$card_one_suit] == 5))
  40. {
  41. $rank = 1;
  42. echo "ROYAL FLUSH";
  43. }
  44. // STRAIGHT FLUSH
  45. else if (($total_card_amount == "20" || $total_card_amount == "25" || $total_card_amount == "30" || $total_card_amount == "35" || $total_card_amount == "40") &&
  46. ($count_suit_values[$card_one_suit] == 5))
  47. {
  48. $rank = 2;
  49. echo "STRAIGHT FLUSH";
  50. }
  51. // FOUR OF A KIND
  52. else if ($count_values[$card_one] == 4 || $count_values[$card_two] == 4 ||   $count_values[$card_three] == 4)
  53. {
  54. $rank = 3;
  55. echo "FOUR OF A KIND";
  56. }
  57. // FULL HOUSE
  58. // HOW TO FIGURE THIS OUT?
  59. // FLUSH
  60. else if ($count_suit_values[$card_one_suit] == 5 || $count_suit_values[$card_two_suit] == 5 || $count_suit_values[$card_three_suit] == 5)
  61. {
  62. $rank = 5;
  63. echo "FLUSH";
  64. }
  65. // STRAIGHT
  66. else if ($total_card_amount == "20" || $total_card_amount == "25" || $total_card_amount == "30" || $total_card_amount == "35" || $total_card_amount == "40")
  67. {
  68. $rank = 6;
  69. echo "STRAIGHT";
  70. }
  71. // THREE OF A KIND
  72. else if ($count_values[$card_one] == 3 || $count_values[$card_two] == 3 ||   $count_values[$card_three] == 3 || $count_values[$card_four] == 3)
  73. {
  74. $rank = 7;
  75. echo "THREE OF A KIND";
  76. }
  77. // TWO PAIR
  78. else if ($count_values[$card_one] == 2 && $count_values[$card_two] == 2 || $count_values[$card_one] == 2 && $count_values[$card_three] == 2
  79. || $count_values[$card_one] == 2 && $count_values[$card_five] == 2 ||   $count_values[$card_two] == 2 && $count_values[$card_three] == 2)
  80. {
  81. $rank = 8;
  82. echo "TWO PAIR";
  83. }
  84. // ONE PAIR
  85. else if ($count_values[$card_one] == 2 || $count_values[$card_two] == 2 ||  $count_values[$card_three] == 2 || $count_values[$card_four] == 2)
  86. {
  87. $rank = 9;
  88. echo "ONE PAIR";
  89. }
  90. // HIGH CARD
  91. else
  92. {
  93. $rank = 10;
  94. echo "NO MATCHES. DETERMINE HIGH CARD";
  95. }
  96.  
  97. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement