Cribbage Trainer

"; // print "\$gamePosition: $gamePosition
"; if ($gamePosition == 1){ checkNumberDiscards(); if (!$tooManyDiscards){ $gamePosition++; } // end if $tooManyDiscards } // end if // print "***--- Cribbage Trainer Test ---***
"; // print "\$gamePosition: $gamePosition
"; setGamePosition(); // print "***--- Cribbage Trainer Test ---***
"; // print "\$gamePosition: $gamePosition
"; switch ($gamePosition){ case 1: setHand(); // $card1 = '5c'; // $card2 = 'jc'; // $card3 = '5d'; // $card4 = '5h'; // $card5 = '9d'; // $card6 = 'ad'; // $card7 = '5s'; printGame(); break; case 2: printGame(); break; case 3: discardCrib(); printGame(); break; case 4: checkScore(); printGame(); break; } // end switch function checkNumberDiscards(){ global $cardsDiscarded, $chkDiscard1, $chkDiscard2, $chkDiscard3, $chkDiscard4, $chkDiscard5, $chkDiscard6, $tooManyDiscards; $chkDiscard = array($chkDiscard1, $chkDiscard2, $chkDiscard3, $chkDiscard4, $chkDiscard5, $chkDiscard6); $cardsDiscarded = 0; $tooManyDiscards = FALSE; // print "***--- function checkNumberDiscards ---***
"; for ($i = 0; $i < 6; $i++){ if ($chkDiscard[$i]){ // print "\$chkDiscard[$i]: $chkDiscard[$i]
"; $cardsDiscarded++; // print "\$cardsDiscarded: $cardsDiscarded
"; } // end if } // end for if ($cardsDiscarded != 2){ // print "\$cardsDiscarded: $cardsDiscarded
"; $tooManyDiscards = TRUE; // print "\$tooManyDiscards: $tooManyDiscards
"; } // end if $cardsDiscarded } // end function checkNumberDiscards function setGamePosition(){ global $gamePosition; // print "***--- setGamePosition ---***
"; if ($gamePosition == NULL){ $gamePosition = 1; } else { $gamePosition++; } // end if // print "\$gamePosition: $gamePosition
"; } // end function setGamePosition function setHand(){ global $card1, $card2, $card3, $card4, $card5, $card6, $card7; $cardNum = array("2c", "2d", "2h", "2s", "3c", "3d", "3h", "3s", "4c", "4d", "4h", "4s", "5c", "5d", "5h", "5s", "6c", "6d", "6h", "6s", "7c", "7d", "7h", "7s", "8c", "8d", "8h", "8s", "9c", "9d", "9h", "9s", "tc", "td", "th", "ts", "jc", "jd", "jh", "js", "qc", "qd", "qh", "qs", "kc", "kd", "kh", "ks", "ac", "ad", "ah", "as"); // print "***--- function setHand ---***
"; $num1 = rand(0, 51); $j = 0; for ($i = 0; $i < 52; $i++){ if ($i != $num1){ $cardNum2[$j] = $cardNum[$i]; $j++; } else { $card1 = $cardNum[$i]; } // end if } // end for loop // print "\$num1 : $num1
"; // print "\$card1: $card1
"; $num2 = rand(0, 50); $j = 0; for ($i = 0; $i < 51; $i++){ if ($i != $num2){ $cardNum3[$j] = $cardNum2[$i]; $j++; } else { $card2 = $cardNum2[$i]; } // end if } // end for loop // print "\$num2 : $num2
"; // print "\$card2: $card2
"; $num3 = rand(0, 49); $j = 0; for ($i = 0; $i < 50; $i++){ if ($i != $num3){ $cardNum4[$j] = $cardNum3[$i]; $j++; } else { $card3 = $cardNum3[$i]; } // end if } // end for loop // print "\$num3 : $num3
"; // print "\$card3: $card3
"; $num4 = rand(0, 48); $j = 0; for ($i = 0; $i < 49; $i++){ if ($i != $num4){ $cardNum5[$j] = $cardNum4[$i]; $j++; } else { $card4 = $cardNum4[$i]; } // end if } // end for loop // print "\$num4 : $num4
"; // print "\$card4: $card4
"; $num5 = rand(0, 47); $j = 0; for ($i = 0; $i < 48; $i++){ if ($i != $num5){ $cardNum6[$j] = $cardNum5[$i]; $j++; } else { $card5 = $cardNum5[$i]; } // end if } // end for loop // print "\$num5 : $num5
"; // print "\$card5: $card5
"; $num6 = rand(0, 46); $j = 0; for ($i = 0; $i < 47; $i++){ if ($i != $num6){ $cardNum7[$j] = $cardNum6[$i]; $j++; } else { $card6 = $cardNum6[$i]; } // end if } // end for loop // print "\$num6 : $num6
"; // print "\$card6: $card6
"; $num7 = rand(0, 45); $card7 = $cardNum7[$num7]; // print "\$num7 : $num7
"; // print "\$card7: $card7
"; } // end function setHand function printGame(){ global $card1, $card2, $card3, $card4, $card5, $card6, $card7, $gamePosition, $score, $txtScore, $combinations; print << HERE; if ($gamePosition == 1){ print <<

Place a check below the two cards you wish to discard into the crib.

HERE; } // end if $gamePosition 1 if ($gamePosition == 2){ print <<

There were too many or too few cards choosen. Place a check below the
two cards you wish to discard into the crib.

HERE; } // end if $gamePosition 2 if ($gamePosition == 3){ print <<

Count the hand and click the numbered button corresponding to
your answer to see if you have counted correct.

HERE; } print << HERE; if (($gamePosition == 1) or ($gamePosition == 2)){ $gamePosition = 1; print <<
HERE; } if ($gamePosition == 3){ print <<
HERE; } // end if if ($gamePosition == 4){ if ($txtScore == $score){ print << Congratulations! $score is the correct answer! If you want to try
another, click the Go Again button to start over.
HERE; } else { print << That was the wrong answer. This hand is $score. Click the browsers
back button and count em again.
HERE; }// end if $gamePosition = NULL; print << HERE; } // end if print << HERE; if ($gamePosition == NULL){ print $combinations; } } // end function printGame function discardCrib(){ global $card1, $card2, $card3, $card4, $card5, $card6, $card7, $chkDiscard1, $chkDiscard2, $chkDiscard3, $chkDiscard4, $chkDiscard5, $chkDiscard6; $chkDiscard = array($chkDiscard1, $chkDiscard2, $chkDiscard3, $chkDiscard4, $chkDiscard5, $chkDiscard6); $card = array($card1, $card2, $card3, $card4, $card5, $card6); // print "***--- function discardCrib ---***
"; for ($i = 0; $i < 6; $i++){ if ($chkDiscard[$i]){ $card[$i] = NULL; } // end if $chkDiscard } // end for $j = 0; for ($i = 0; $i < 6; $i++){ // print "before \$card[$i]: $card[$i]
"; if ($card[$i] != NULL){ $newCard[$j] = $card[$i]; // print "after \$newCard[$j]: $newCard[$j]
"; $j++; } // end card move if } // end for $card array $card1 = $newCard[0]; $card2 = $newCard[1]; $card3 = $newCard[2]; $card4 = $newCard[3]; $card5 = NULL; $card6 = NULL; } // end function discardCrib function checkScore(){ global $txtScore, $score, $card1, $card2, $card3, $card4, $card7, $cardVal1, $cardVal2, $cardVal3, $cardVal4, $cardVal5, $combinations; $score = 0; // print "***--- function checkScore ---***
"; $combinations = ""; $combinations .= "\n"; check15s(); setCardVal(); checkPairs(); checkRuns(); checkFlush(); checkNobs(); $combinations .= "
"; } // end function enterScore function check15s(){ global $txtScore, $score, $card1, $card2, $card3, $card4, $card7, $cardVal1, $cardVal2, $cardVal3, $cardVal4, $cardVal7, $combinations; $card = array($card1, $card2, $card3, $card4, $card7); $cardVal = array($cardVal1, $cardVal2, $cardVal3, $cardVal4, $cardVal7); // print "***--- function check15s ---***
"; for ($i = 0; $i < 5; $i++){ if (($card[$i] == '2d') or ($card[$i] == '2h') or ($card[$i] == '2c') or ($card[$i] == '2s')){ $cardVal[$i] = 2; } if (($card[$i] == '3d') or ($card[$i] == '3h') or ($card[$i] == '3c') or ($card[$i] == '3s')){ $cardVal[$i] = 3; } if (($card[$i] == '4d') or ($card[$i] == '4h') or ($card[$i] == '4c') or ($card[$i] == '4s')){ $cardVal[$i] = 4; } if (($card[$i] == '5d') or ($card[$i] == '5h') or ($card[$i] == '5c') or ($card[$i] == '5s')){ $cardVal[$i] = 5; } if (($card[$i] == '6d') or ($card[$i] == '6h') or ($card[$i] == '6c') or ($card[$i] == '6s')){ $cardVal[$i] = 6; } if (($card[$i] == '7d') or ($card[$i] == '7h') or ($card[$i] == '7c') or ($card[$i] == '7s')){ $cardVal[$i] = 7; } if (($card[$i] == '8d') or ($card[$i] == '8h') or ($card[$i] == '8c') or ($card[$i] == '8s')){ $cardVal[$i] = 8; } if (($card[$i] == '9d') or ($card[$i] == '9h') or ($card[$i] == '9c') or ($card[$i] == '9s')){ $cardVal[$i] = 9; } if (($card[$i] == 'td') or ($card[$i] == 'th') or ($card[$i] == 'tc') or ($card[$i] == 'ts')){ $cardVal[$i] = 10; } if (($card[$i] == 'jd') or ($card[$i] == 'jh') or ($card[$i] == 'jc') or ($card[$i] == 'js')){ $cardVal[$i] = 10; } if (($card[$i] == 'qd') or ($card[$i] == 'qh') or ($card[$i] == 'qc') or ($card[$i] == 'qs')){ $cardVal[$i] = 10; } if (($card[$i] == 'kd') or ($card[$i] == 'kh') or ($card[$i] == 'kc') or ($card[$i] == 'ks')){ $cardVal[$i] = 10; } if (($card[$i] == 'ad') or ($card[$i] == 'ah') or ($card[$i] == 'ac') or ($card[$i] == 'as')){ $cardVal[$i] = 1; } // print "\$cardVal[$i]: $cardVal[$i]
"; } // end for $card1 = $card[0]; $card2 = $card[1]; $card3 = $card[2]; $card4 = $card[3]; $card7 = $card[4]; $cardVal1 = $cardVal[0]; $cardVal2 = $cardVal[1]; $cardVal3 = $cardVal[2]; $cardVal4 = $cardVal[3]; $cardVal7 = $cardVal[4]; // // check for 15's if (($cardVal1 + $cardVal2) == 15){ $score = $score + 2; $combinations .= "\n"; $combinations .= "\n"; $combinations .= "\n"; $combinations .= "\n"; $combinations .= "Fifteen for $score.\n"; // print "15s combination 1
"; // print "\$score: $score
"; } if (($cardVal1 + $cardVal3) == 15){ $score = $score + 2; $combinations .= "\n"; $combinations .= "\n"; $combinations .= "\n"; $combinations .= "\n"; $combinations .= "Fifteen for $score.\n"; // print "15s combination 2
"; // print "\$score: $score
"; } if (($cardVal1 + $cardVal4) == 15){ $score = $score + 2; $combinations .= "\n"; $combinations .= "\n"; $combinations .= "\n"; $combinations .= "\n"; $combinations .= "Fifteen for $score.\n"; // print "15s combination 3
"; // print "\$score: $score
"; } if (($cardVal1 + $cardVal7) == 15){ $score = $score + 2; $combinations .= "\n"; $combinations .= "\n"; $combinations .= "\n"; $combinations .= "\n"; $combinations .= "Fifteen for $score.\n"; // print "15s combination 4
"; // print "\$score: $score
"; } if (($cardVal2 + $cardVal3) == 15){ $score = $score + 2; $combinations .= "\n"; $combinations .= "\n"; $combinations .= "\n"; $combinations .= "\n"; $combinations .= "Fifteen for $score.\n"; // print "15s combination 5
"; // print "\$score: $score
"; } if (($cardVal2 + $cardVal4) == 15){ $score = $score + 2; $combinations .= "\n"; $combinations .= "\n"; $combinations .= "\n"; $combinations .= "\n"; $combinations .= "Fifteen for $score.\n"; // print "15s combination 6
"; // print "\$score: $score
"; } if (($cardVal2 + $cardVal7) == 15){ $score = $score + 2; $combinations .= "\n"; $combinations .= "\n"; $combinations .= "\n"; $combinations .= "\n"; $combinations .= "Fifteen for $score.\n"; // print "15s combination 7
"; // print "\$score: $score
"; } if (($cardVal3 + $cardVal4) == 15){ $score = $score + 2; $combinations .= "\n"; $combinations .= "\n"; $combinations .= "\n"; $combinations .= "\n"; $combinations .= "Fifteen for $score.\n"; // print "15s combination 8
"; // print "\$score: $score
"; } if (($cardVal3 + $cardVal7) == 15){ $score = $score + 2; $combinations .= "\n"; $combinations .= "\n"; $combinations .= "\n"; $combinations .= "\n"; $combinations .= "Fifteen for $score.\n"; // print "15s combination 9
"; // print "\$score: $score
"; } if (($cardVal4 + $cardVal7) == 15){ $score = $score + 2; $combinations .= "\n"; $combinations .= "\n"; $combinations .= "\n"; $combinations .= "\n"; $combinations .= "Fifteen for $score.\n"; // print "15s combination 10
"; // print "\$score: $score
"; } if (($cardVal1 + $cardVal2 + $cardVal3) == 15){ $score = $score + 2; $combinations .= "\n"; $combinations .= "\n"; $combinations .= "\n"; $combinations .= "\n"; $combinations .= "\n"; $combinations .= "Fifteen for $score.\n"; // print "15s combination 11
"; // print "\$score: $score
"; } if (($cardVal1 + $cardVal2 + $cardVal4) == 15){ $score = $score + 2; $combinations .= "\n"; $combinations .= "\n"; $combinations .= "\n"; $combinations .= "\n"; $combinations .= "\n"; $combinations .= "Fifteen for $score.\n"; // print "15s combination 12
"; // print "\$score: $score
"; } if (($cardVal1 + $cardVal2 + $cardVal7) == 15){ $score = $score + 2; $combinations .= "\n"; $combinations .= "\n"; $combinations .= "\n"; $combinations .= "\n"; $combinations .= "\n"; $combinations .= "Fifteen for $score.\n"; // print "15s combination 13
"; // print "\$score: $score
"; } if (($cardVal1 + $cardVal3 + $cardVal4) == 15){ $score = $score + 2; $combinations .= "\n"; $combinations .= "\n"; $combinations .= "\n"; $combinations .= "\n"; $combinations .= "\n"; $combinations .= "Fifteen for $score.\n"; // print "15s combination 14
"; // print "\$score: $score
"; } if (($cardVal1 + $cardVal3 + $cardVal7) == 15){ $score = $score + 2; $combinations .= "\n"; $combinations .= "\n"; $combinations .= "\n"; $combinations .= "\n"; $combinations .= "\n"; $combinations .= "Fifteen for $score.\n"; // print "15s combination 15
"; // print "\$score: $score
"; } if (($cardVal1 + $cardVal4 + $cardVal7) == 15){ $score = $score + 2; $combinations .= "\n"; $combinations .= "\n"; $combinations .= "\n"; $combinations .= "\n"; $combinations .= "\n"; $combinations .= "Fifteen for $score.\n"; // print "15s combination 16
"; // print "\$score: $score
"; } if (($cardVal2 + $cardVal3 + $cardVal4) == 15){ $score = $score + 2; $combinations .= "\n"; $combinations .= "\n"; $combinations .= "\n"; $combinations .= "\n"; $combinations .= "\n"; $combinations .= "Fifteen for $score.\n"; // print "15s combination 17
"; // print "\$score: $score
"; } if (($cardVal2 + $cardVal3 + $cardVal7) == 15){ $score = $score + 2; $combinations .= "\n"; $combinations .= "\n"; $combinations .= "\n"; $combinations .= "\n"; $combinations .= "\n"; $combinations .= "Fifteen for $score.\n"; // print "15s combination 18
"; // print "\$score: $score
"; } if (($cardVal2 + $cardVal4 + $cardVal7) == 15){ $score = $score + 2; $combinations .= "\n"; $combinations .= "\n"; $combinations .= "\n"; $combinations .= "\n"; $combinations .= "\n"; $combinations .= "Fifteen for $score.\n"; // print "15s combination 19
"; // print "\$score: $score
"; } if (($cardVal3 + $cardVal4 + $cardVal7) == 15){ $score = $score + 2; $combinations .= "\n"; $combinations .= "\n"; $combinations .= "\n"; $combinations .= "\n"; $combinations .= "\n"; $combinations .= "Fifteen for $score.\n"; // print "15s combination 20
"; // print "\$score: $score
"; } if (($cardVal1 + $cardVal2 + $cardVal3 + $cardVal4) == 15){ $score = $score + 2; $combinations .= "\n"; $combinations .= "\n"; $combinations .= "\n"; $combinations .= "\n"; $combinations .= "\n"; $combinations .= "\n"; $combinations .= "Fifteen for $score.\n"; // print "15s combination 21
"; // print "\$score: $score
"; } if (($cardVal1 + $cardVal2 + $cardVal3 + $cardVal7) == 15){ $score = $score + 2; $combinations .= "\n"; $combinations .= "\n"; $combinations .= "\n"; $combinations .= "\n"; $combinations .= "\n"; $combinations .= "\n"; $combinations .= "Fifteen for $score.\n"; // print "15s combination 22
"; // print "\$score: $score
"; } if (($cardVal1 + $cardVal2 + $cardVal4 + $cardVal7) == 15){ $score = $score + 2; $combinations .= "\n"; $combinations .= "\n"; $combinations .= "\n"; $combinations .= "\n"; $combinations .= "\n"; $combinations .= "\n"; $combinations .= "Fifteen for $score.\n"; // print "15s combination 23
"; // print "\$score: $score
"; } if (($cardVal1 + $cardVal3 + $cardVal4 + $cardVal7) == 15){ $score = $score + 2; $combinations .= "\n"; $combinations .= "\n"; $combinations .= "\n"; $combinations .= "\n"; $combinations .= "\n"; $combinations .= "\n"; $combinations .= "Fifteen for $score.\n"; // print "15s combination 24
"; // print "\$score: $score
"; } if (($cardVal2 + $cardVal3 + $cardVal4 + $cardVal7) == 15){ $score = $score + 2; $combinations .= "\n"; $combinations .= "\n"; $combinations .= "\n"; $combinations .= "\n"; $combinations .= "\n"; $combinations .= "\n"; $combinations .= "Fifteen for $score.\n"; // print "15s combination 25
"; // print "\$score: $score
"; } if (($cardVal1 + $cardVal2 + $cardVal3 + $cardVal4 + $cardVal7) == 15){ $score = $score + 2; $combinations .= "\n"; $combinations .= "\n"; $combinations .= "\n"; $combinations .= "\n"; $combinations .= "\n"; $combinations .= "\n"; $combinations .= "\n"; $combinations .= "Fifteen for $score.\n"; // print "15s combination 26
"; // print "\$score: $score
"; } // print "\$score: $score
"; } // end check15s function setCardVal(){ global $card1, $card2, $card3, $card4, $card7, $cardVal1, $cardVal2, $cardVal3, $cardVal4, $cardVal7; $card = array($card1, $card2, $card3, $card4, $card7); $cardVal = array($cardVal1, $cardVal2, $cardVal3, $cardVal4, $cardVal7); // print "***--- function setCardVal ---***
"; for ($i = 0; $i < 6; $i++){ if (($card[$i] == '2d') or ($card[$i] == '2h') or ($card[$i] == '2c') or ($card[$i] == '2s')){ $cardVal[$i] = 2; } if (($card[$i] == '3d') or ($card[$i] == '3h') or ($card[$i] == '3c') or ($card[$i] == '3s')){ $cardVal[$i] = 3; } if (($card[$i] == '4d') or ($card[$i] == '4h') or ($card[$i] == '4c') or ($card[$i] == '4s')){ $cardVal[$i] = 4; } if (($card[$i] == '5d') or ($card[$i] == '5h') or ($card[$i] == '5c') or ($card[$i] == '5s')){ $cardVal[$i] = 5; } if (($card[$i] == '6d') or ($card[$i] == '6h') or ($card[$i] == '6c') or ($card[$i] == '6s')){ $cardVal[$i] = 6; } if (($card[$i] == '7d') or ($card[$i] == '7h') or ($card[$i] == '7c') or ($card[$i] == '7s')){ $cardVal[$i] = 7; } if (($card[$i] == '8d') or ($card[$i] == '8h') or ($card[$i] == '8c') or ($card[$i] == '8s')){ $cardVal[$i] = 8; } if (($card[$i] == '9d') or ($card[$i] == '9h') or ($card[$i] == '9c') or ($card[$i] == '9s')){ $cardVal[$i] = 9; } if (($card[$i] == 'td') or ($card[$i] == 'th') or ($card[$i] == 'tc') or ($card[$i] == 'ts')){ $cardVal[$i] = 10; } if (($card[$i] == 'jd') or ($card[$i] == 'jh') or ($card[$i] == 'jc') or ($card[$i] == 'js')){ $cardVal[$i] = 11; } if (($card[$i] == 'qd') or ($card[$i] == 'qh') or ($card[$i] == 'qc') or ($card[$i] == 'qs')){ $cardVal[$i] = 12; } if (($card[$i] == 'kd') or ($card[$i] == 'kh') or ($card[$i] == 'kc') or ($card[$i] == 'ks')){ $cardVal[$i] = 13; } if (($card[$i] == 'ad') or ($card[$i] == 'ah') or ($card[$i] == 'ac') or ($card[$i] == 'as')){ $cardVal[$i] = 1; } } // end for $cardVal1 = $cardVal[0]; $cardVal2 = $cardVal[1]; $cardVal3 = $cardVal[2]; $cardVal4 = $cardVal[3]; $cardVal7 = $cardVal[4]; // print "\$cardVal1: $cardVal1
"; // print "\$cardVal2: $cardVal2
"; // print "\$cardVal3: $cardVal3
"; // print "\$cardVal4: $cardVal4
"; // print "\$cardVal7: $cardVal7
"; } // end function setCardVal function checkRuns(){ global $score, $val1, $val2, $val3, $val4, $val5, $cardVal1, $cardVal2, $cardVal3, $cardVal4, $cardVal7, $runOfFive, $runOfFour, $runOfThree, $combinations; // print "***--- function checkRuns ---***
"; // print "\$score: $score
"; $runOfFive = FALSE; $runOfFour = FALSE; $runOfThree = FALSE; checkRunOfFive(); if (!$runOfFive){ checkRunOfFour(); } // end if // print "***--- function checkRuns 2 ---***
"; // print "\$runOfFive: $runOfFive
"; // print "\$runOfFour: $runOfFour
"; if ((!$runOfFive) and (!$runOfFour)){ checkRunOfThree(); } // end if // print "\$score: $score
"; } // end function checkRuns function checkRunOfFive(){ global $score, $val1, $val2, $val3, $val4, $val7, $cardVal1, $cardVal2, $cardVal3, $cardVal4, $cardVal7, $runOfFive, $runOfFour, $runOfThree, $combinations, $card1, $card2, $card3, $card4, $card7; setCheckVals(); // print "***--- function checkRunOfFive ---***
"; // run-of-five for ($i = 0; $i < 10; $i++){ if ((($cardVal1 == $val1) or ($cardVal1 == $val2) or ($cardVal1 == $val3) or ($cardVal1 == $val4) or ($cardVal1 == $val7)) and (($cardVal2 == $val1) or ($cardVal2 == $val2) or ($cardVal2 == $val3) or ($cardVal2 == $val4) or ($cardVal2 == $val7)) and (($cardVal3 == $val1) or ($cardVal3 == $val2) or ($cardVal3 == $val3) or ($cardVal3 == $val4) or ($cardVal3 == $val7)) and (($cardVal4 == $val1) or ($cardVal4 == $val2) or ($cardVal4 == $val3) or ($cardVal4 == $val4) or ($cardVal4 == $val7)) and (($cardVal7 == $val1) or ($cardVal7 == $val2) or ($cardVal7 == $val3) or ($cardVal7 == $val4) or ($cardVal7 == $val7)) and (($cardVal1 != $cardVal2) and ($cardVal1 != $cardVal3) and ($cardVal1 != $cardVal4) and ($cardVal1 != $cardVal7) and ($cardVal2 != $cardVal3) and ($cardVal2 != $cardVal4) and ($cardVal2 != $cardVal7) and ($cardVal3 != $cardVal4) and ($cardVal3 != $cardVal7) and ($cardVal4 != $cardVal7))){ $score = $score + 5; $runOfFive = TRUE; $combinations .= "\n"; $combinations .= "\n"; $combinations .= "\n"; $combinations .= "\n"; $combinations .= "\n"; $combinations .= "\n"; $combinations .= "\n"; $combinations .= "Run of five for for $score.\n"; // print "\$runOfFive: $runOfFive
"; // print "\$score: $score
"; } // end if run-of-five $val1 = $val1 + 1; $val2 = $val2 + 1; $val3 = $val3 + 1; $val4 = $val4 + 1; $val7 = $val7 + 1; } // end for } // end function checkRunOfFive function checkRunOfFour(){ global $score, $val1, $val2, $val3, $val4, $val7, $cardVal1, $cardVal2, $cardVal3, $cardVal4, $cardVal7, $runOfFive, $runOfFour, $runOfThree, $combinations, $card1, $card2, $card3, $card4, $card7; setCheckVals(); // print "***--- function checkRunOfFour ---***
"; // print "\$cardVal1: $cardVal1
"; // print "\$cardVal2: $cardVal2
"; // print "\$cardVal3: $cardVal3
"; // print "\$cardVal4: $cardVal4
"; // print "\$cardVal7: $cardVal7
"; // Ace, two, three, four for ($i = 0; $i < 11; $i++){ if ((($cardVal1 == $val1) or ($cardVal1 == $val2) or ($cardVal1 == $val3) or ($cardVal1 == $val4)) and (($cardVal2 == $val1) or ($cardVal2 == $val2) or ($cardVal2 == $val3) or ($cardVal2 == $val4)) and (($cardVal3 == $val1) or ($cardVal3 == $val2) or ($cardVal3 == $val3) or ($cardVal3 == $val4)) and (($cardVal4 == $val1) or ($cardVal4 == $val2) or ($cardVal4 == $val3) or ($cardVal4 == $val4)) and (($cardVal1 != $cardVal2) and ($cardVal1 != $cardVal3) and ($cardVal1 != $cardVal4) and ($cardVal2 != $cardVal3) and ($cardVal2 != $cardVal4) and ($cardVal3 != $cardVal4))){ $score = $score + 4; $runOfFour = TRUE; $combinations .= "\n"; $combinations .= "\n"; $combinations .= "\n"; $combinations .= "\n"; $combinations .= "\n"; $combinations .= "\n"; $combinations .= "Run of four for $score.\n"; // print "If 1, run of Four
"; // print "\$score: $score
"; } if ((($cardVal1 == $val1) or ($cardVal1 == $val2) or ($cardVal1 == $val3) or ($cardVal1 == $val4)) and (($cardVal2 == $val1) or ($cardVal2 == $val2) or ($cardVal2 == $val3) or ($cardVal2 == $val4)) and (($cardVal3 == $val1) or ($cardVal3 == $val2) or ($cardVal3 == $val3) or ($cardVal3 == $val4)) and (($cardVal7 == $val1) or ($cardVal7 == $val2) or ($cardVal7 == $val3) or ($cardVal7 == $val4)) and (($cardVal1 != $cardVal2) and ($cardVal1 != $cardVal3) and ($cardVal1 != $cardVal7) and ($cardVal2 != $cardVal3) and ($cardVal2 != $cardVal7) and ($cardVal3 != $cardVal7))){ $score = $score + 4; $runOfFour = TRUE; $combinations .= "\n"; $combinations .= "\n"; $combinations .= "\n"; $combinations .= "\n"; $combinations .= "\n"; $combinations .= "\n"; $combinations .= "Run of four for $score.\n"; // print "If 2, run of Four
"; // print "\$score: $score
"; } if ((($cardVal1 == $val1) or ($cardVal1 == $val2) or ($cardVal1 == $val3) or ($cardVal1 == $val4)) and (($cardVal2 == $val1) or ($cardVal2 == $val2) or ($cardVal2 == $val3) or ($cardVal2 == $val4)) and (($cardVal4 == $val1) or ($cardVal4 == $val2) or ($cardVal4 == $val3) or ($cardVal4 == $val4)) and (($cardVal7 == $val1) or ($cardVal7 == $val2) or ($cardVal7 == $val3) or ($cardVal7 == $val4)) and (($cardVal1 != $cardVal2) and ($cardVal1 != $cardVal4) and ($cardVal1 != $cardVal7) and ($cardVal2 != $cardVal4) and ($cardVal2 != $cardVal7) and ($cardVal4 != $cardVal7))){ $score = $score + 4; $runOfFour = TRUE; $combinations .= "\n"; $combinations .= "\n"; $combinations .= "\n"; $combinations .= "\n"; $combinations .= "\n"; $combinations .= "\n"; $combinations .= "Run of four for $score.\n"; // print "If 3, run of Four
"; // print "\$score: $score
"; } if ((($cardVal1 == $val1) or ($cardVal1 == $val2) or ($cardVal1 == $val3) or ($cardVal1 == $val4)) and (($cardVal3 == $val1) or ($cardVal3 == $val2) or ($cardVal3 == $val3) or ($cardVal3 == $val4)) and (($cardVal4 == $val1) or ($cardVal4 == $val2) or ($cardVal4 == $val3) or ($cardVal4 == $val4)) and (($cardVal7 == $val1) or ($cardVal7 == $val2) or ($cardVal7 == $val3) or ($cardVal7 == $val4)) and (($cardVal1 != $cardVal3) and ($cardVal1 != $cardVal4) and ($cardVal1 != $cardVal7) and ($cardVal3 != $cardVal4) and ($cardVal3 != $cardVal7) and ($cardVal4 != $cardVal7))){ $score = $score + 4; $runOfFour = TRUE; $combinations .= "\n"; $combinations .= "\n"; $combinations .= "\n"; $combinations .= "\n"; $combinations .= "\n"; $combinations .= "\n"; $combinations .= "Run of four for $score.\n"; // print "If 4, run of Four
"; // print "\$score: $score
"; } if ((($cardVal2 == $val1) or ($cardVal2 == $val2) or ($cardVal2 == $val3) or ($cardVal2 == $val4)) and (($cardVal3 == $val1) or ($cardVal3 == $val2) or ($cardVal3 == $val3) or ($cardVal3 == $val4)) and (($cardVal4 == $val1) or ($cardVal4 == $val2) or ($cardVal4 == $val3) or ($cardVal4 == $val4)) and (($cardVal7 == $val1) or ($cardVal7 == $val2) or ($cardVal7 == $val3) or ($cardVal7 == $val4)) and (($cardVal2 != $cardVal3) and ($cardVal2 != $cardVal4) and ($cardVal2 != $cardVal7) and ($cardVal3 != $cardVal4) and ($cardVal3 != $cardVal7) and ($cardVal4 != $cardVal7))){ $score = $score + 4; $runOfFour = TRUE; $combinations .= "\n"; $combinations .= "\n"; $combinations .= "\n"; $combinations .= "\n"; $combinations .= "\n"; $combinations .= "\n"; $combinations .= "Run of four for $score.\n"; // print "If 5, run of Four
"; // print "\$score: $score
"; } $val1 = $val1 + 1; $val2 = $val2 + 1; $val3 = $val3 + 1; $val4 = $val4 + 1; } // end for run-of-four // print "\$runOfFour: $runOfFour
"; } // end function checkRunOfFour function checkRunOfThree(){ global $score, $val1, $val2, $val3, $val4, $val7, $cardVal1, $cardVal2, $cardVal3, $cardVal4, $cardVal7, $runOfFive, $runOfFour, $runOfThree, $combinations, $card1, $card2, $card3, $card4, $card7; setCheckVals(); // print "***--- function checkRunOfThree ---***
"; // run-of-three for ($i = 0; $i < 12; $i++){ if ((($cardVal1 == $val1) or ($cardVal1 == $val2) or ($cardVal1 == $val3)) and (($cardVal2 == $val1) or ($cardVal2 == $val2) or ($cardVal2 == $val3)) and (($cardVal3 == $val1) or ($cardVal3 == $val2) or ($cardVal3 == $val3)) and (($cardVal1 != $cardVal2) and ($cardVal1 != $cardVal3) and ($cardVal2 != $cardVal3))){ $score = $score + 3; $runOfThree = TRUE; $combinations .= "\n"; $combinations .= "\n"; $combinations .= "\n"; $combinations .= "\n"; $combinations .= "\n"; $combinations .= "Run of three for $score.\n"; // print "If 1, run of Three
"; // print "\$score: $score
"; } if ((($cardVal1 == $val1) or ($cardVal1 == $val2) or ($cardVal1 == $val3)) and (($cardVal2 == $val1) or ($cardVal2 == $val2) or ($cardVal2 == $val3)) and (($cardVal4 == $val1) or ($cardVal4 == $val2) or ($cardVal4 == $val3)) and (($cardVal1 != $cardVal2) and ($cardVal1 != $cardVal4) and ($cardVal2 != $cardVal4))){ $score = $score + 3; $runOfThree = TRUE; $combinations .= "\n"; $combinations .= "\n"; $combinations .= "\n"; $combinations .= "\n"; $combinations .= "\n"; $combinations .= "Run of three for $score.\n"; // print "If 2, run of Three
"; // print "\$score: $score
"; } if ((($cardVal1 == $val1) or ($cardVal1 == $val2) or ($cardVal1 == $val3)) and (($cardVal2 == $val1) or ($cardVal2 == $val2) or ($cardVal2 == $val3)) and (($cardVal7 == $val1) or ($cardVal7 == $val2) or ($cardVal7 == $val3)) and (($cardVal1 != $cardVal2) and ($cardVal1 != $cardVal7) and ($cardVal2 != $cardVal7))){ $score = $score + 3; $runOfThree = TRUE; $combinations .= "\n"; $combinations .= "\n"; $combinations .= "\n"; $combinations .= "\n"; $combinations .= "\n"; $combinations .= "Run of three for $score.\n"; // print "If 3, run of Three
"; // print "\$score: $score
"; } if ((($cardVal1 == $val1) or ($cardVal1 == $val2) or ($cardVal1 == $val3)) and (($cardVal3 == $val1) or ($cardVal3 == $val2) or ($cardVal3 == $val3)) and (($cardVal4 == $val1) or ($cardVal4 == $val2) or ($cardVal4 == $val3)) and (($cardVal1 != $cardVal3) and ($cardVal1 != $cardVal4) and ($cardVal3 != $cardVal4))){ $score = $score + 3; $runOfThree = TRUE; $combinations .= "\n"; $combinations .= "\n"; $combinations .= "\n"; $combinations .= "\n"; $combinations .= "\n"; $combinations .= "Run of three for $score.\n"; // print "If 4, run of Three
"; // print "\$score: $score
"; } if ((($cardVal1 == $val1) or ($cardVal1 == $val2) or ($cardVal1 == $val3)) and (($cardVal3 == $val1) or ($cardVal3 == $val2) or ($cardVal3 == $val3)) and (($cardVal7 == $val1) or ($cardVal7 == $val2) or ($cardVal7 == $val3)) and (($cardVal1 != $cardVal3) and ($cardVal1 != $cardVal7) and ($cardVal3 != $cardVal7))){ $score = $score + 3; $runOfThree = TRUE; $combinations .= "\n"; $combinations .= "\n"; $combinations .= "\n"; $combinations .= "\n"; $combinations .= "\n"; $combinations .= "Run of three for $score.\n"; // print "If 5, run of Three
"; // print "\$score: $score
"; } if ((($cardVal1 == $val1) or ($cardVal1 == $val2) or ($cardVal1 == $val3)) and (($cardVal4 == $val1) or ($cardVal4 == $val2) or ($cardVal4 == $val3)) and (($cardVal7 == $val1) or ($cardVal7 == $val2) or ($cardVal7 == $val3)) and (($cardVal1 != $cardVal4) and ($cardVal1 != $cardVal7) and ($cardVal4 != $cardVal7))){ $score = $score + 3; $runOfThree = TRUE; $combinations .= "\n"; $combinations .= "\n"; $combinations .= "\n"; $combinations .= "\n"; $combinations .= "\n"; $combinations .= "Run of three for $score.\n"; // print "If 6, run of Three
"; // print "\$score: $score
"; } if ((($cardVal2 == $val1) or ($cardVal2 == $val2) or ($cardVal2 == $val3)) and (($cardVal3 == $val1) or ($cardVal3 == $val2) or ($cardVal3 == $val3)) and (($cardVal4 == $val1) or ($cardVal4 == $val2) or ($cardVal4 == $val3)) and (($cardVal2 != $cardVal3) and ($cardVal2 != $cardVal4) and ($cardVal3 != $cardVal4))){ $score = $score + 3; $runOfThree = TRUE; $combinations .= "\n"; $combinations .= "\n"; $combinations .= "\n"; $combinations .= "\n"; $combinations .= "\n"; $combinations .= "Run of three for $score.\n"; // print "If 7, run of Three
"; // print "\$score: $score
"; } if ((($cardVal2 == $val1) or ($cardVal2 == $val2) or ($cardVal2 == $val3)) and (($cardVal3 == $val1) or ($cardVal3 == $val2) or ($cardVal3 == $val3)) and (($cardVal7 == $val1) or ($cardVal7 == $val2) or ($cardVal7 == $val3)) and (($cardVal2 != $cardVal3) and ($cardVal2 != $cardVal7) and ($cardVal3 != $cardVal7))){ $score = $score + 3; $runOfThree = TRUE; $combinations .= "\n"; $combinations .= "\n"; $combinations .= "\n"; $combinations .= "\n"; $combinations .= "\n"; $combinations .= "Run of three for $score.\n"; // print "If 8, run of Three
"; // print "\$score: $score
"; } if ((($cardVal2 == $val1) or ($cardVal2 == $val2) or ($cardVal2 == $val3)) and (($cardVal4 == $val1) or ($cardVal4 == $val2) or ($cardVal4 == $val3)) and (($cardVal7 == $val1) or ($cardVal7 == $val2) or ($cardVal7 == $val3)) and (($cardVal2 != $cardVal4) and ($cardVal2 != $cardVal7) and ($cardVal4 != $cardVal7))){ $score = $score + 3; $runOfThree = TRUE; $combinations .= "\n"; $combinations .= "\n"; $combinations .= "\n"; $combinations .= "\n"; $combinations .= "\n"; $combinations .= "Run of three for $score.\n"; // print "If 9, run of Three
"; // print "\$score: $score
"; } if ((($cardVal3 == $val1) or ($cardVal3 == $val2) or ($cardVal3 == $val3)) and (($cardVal4 == $val1) or ($cardVal4 == $val2) or ($cardVal4 == $val3)) and (($cardVal7 == $val1) or ($cardVal7 == $val2) or ($cardVal7 == $val3)) and (($cardVal3 != $cardVal4) and ($cardVal3 != $cardVal7) and ($cardVal4 != $cardVal7))){ $score = $score + 3; $runOfThree = TRUE; $combinations .= "\n"; $combinations .= "\n"; $combinations .= "\n"; $combinations .= "\n"; $combinations .= "\n"; $combinations .= "Run of three for $score.\n"; // print "If 10, run of Three
"; // print "\$score: $score
"; } $val1 = $val1 + 1; $val2 = $val2 + 1; $val3 = $val3 + 1; } // end for run-of-three // print "\$runOfFive: $runOfThree
"; } // end function checkRunOfThree function setCheckVals(){ global $val1, $val2, $val3, $val4, $val7; $val1 = 1; $val2 = 2; $val3 = 3; $val4 = 4; $val7 = 5; // print "***--- function setCheckVals ---***
"; } // end function setCheckVals function checkPairs(){ global $score, $card1, $card2, $card3, $card4, $card7, $cardVal1, $cardVal2, $cardVal3, $cardVal4, $cardVal7, $combinations; // print "***--- function checkPairs ---***
"; if ($cardVal1 == $cardVal2){ $score = $score + 2; $combinations .= "\n"; $combinations .= "\n"; $combinations .= "\n"; $combinations .= "\n"; $combinations .= "A Pair for $score.\n"; // print "pair combination 1
"; // print "\$score: $score
"; } if ($cardVal1 == $cardVal3){ $score = $score + 2; $combinations .= "\n"; $combinations .= "\n"; $combinations .= "\n"; $combinations .= "\n"; $combinations .= "A Pair for $score.\n"; // print "pair combination 2
"; // print "\$score: $score
"; } if ($cardVal1 == $cardVal4){ $score = $score + 2; $combinations .= "\n"; $combinations .= "\n"; $combinations .= "\n"; $combinations .= "\n"; $combinations .= "A Pair for $score.\n"; // print "pair combination 3
"; // print "\$score: $score
"; } if ($cardVal1 == $cardVal7){ $score = $score + 2; $combinations .= "\n"; $combinations .= "\n"; $combinations .= "\n"; $combinations .= "\n"; $combinations .= "A Pair for $score.\n"; // print "pair combination 4
"; // print "\$score: $score
"; } if ($cardVal2 == $cardVal3){ $score = $score + 2; $combinations .= "\n"; $combinations .= "\n"; $combinations .= "\n"; $combinations .= "\n"; $combinations .= "A Pair for $score.\n"; // print "pair combination 5
"; // print "\$score: $score
"; } if ($cardVal2 == $cardVal4){ $score = $score + 2; $combinations .= "\n"; $combinations .= "\n"; $combinations .= "\n"; $combinations .= "\n"; $combinations .= "A Pair for $score.\n"; // print "pair combination 6
"; // print "\$score: $score
"; } if ($cardVal2 == $cardVal7){ $score = $score + 2; $combinations .= "\n"; $combinations .= "\n"; $combinations .= "\n"; $combinations .= "\n"; $combinations .= "A Pair for $score.\n"; // print "pair combination 7
"; // print "\$score: $score
"; } if ($cardVal3 == $cardVal4){ $score = $score + 2; $combinations .= "\n"; $combinations .= "\n"; $combinations .= "\n"; $combinations .= "\n"; $combinations .= "A Pair for $score.\n"; // print "pair combination 8
"; // print "\$score: $score
"; } if ($cardVal3 == $cardVal7){ $score = $score + 2; $combinations .= "\n"; $combinations .= "\n"; $combinations .= "\n"; $combinations .= "\n"; $combinations .= "A Pair for $score.\n"; // print "pair combination 9
"; // print "\$score: $score
"; } if ($cardVal4 == $cardVal7){ $score = $score + 2; $combinations .= "\n"; $combinations .= "\n"; $combinations .= "\n"; $combinations .= "\n"; $combinations .= "A Pair for $score.\n"; // print "pair combination 10
"; // print "\$score: $score
"; } // print "\$score: $score
"; } // end function checkPairs function checkFlush() { global $score, $card1, $card2, $card3, $card4, $card7, $combinations; $card = array($card1, $card2, $card3, $card4, $card7); // print "***--- function checkFlush ---***
"; for ($i = 0; $i < 5; $i++){ $suit[$i] = substr($card[$i], 1, 1); } if (($suit[0] == $suit[1]) and ($suit[1] == $suit[2]) and ($suit[2] == $suit[3]) and ($suit[3] == $suit[4])){ $score = $score + 5; $combinations .= "\n"; $combinations .= "\n"; $combinations .= "\n"; $combinations .= "\n"; $combinations .= "\n"; $combinations .= "\n"; $combinations .= "\n"; $combinations .= "A Flush for $score.\n"; } else if (($suit[0] == $suit[1]) and ($suit[1] == $suit[2]) and ($suit[2] == $suit[3])){ $score = $score + 4; $combinations .= "\n"; $combinations .= "\n"; $combinations .= "\n"; $combinations .= "\n"; $combinations .= "\n"; $combinations .= "\n"; $combinations .= "A Flush for $score.\n"; } // print "\$score: $score
"; // print "\$suit[0]: $suit[0]
"; // print "\$suit[1]: $suit[1]
"; // print "\$suit[2]: $suit[2]
"; // print "\$suit[3]: $suit[3]
"; // print "\$suit[4]: $suit[4]
"; // print "\$score: $score
"; } // end function checkFlush function checkNobs(){ global $score, $card1, $card2, $card3, $card4, $card7, $combinations; $card = array($card1, $card2, $card3, $card4, $card7); // print "***--- function checkNobs ---***
"; $suit = substr($card7, 1, 1); for ($i = 0; $i < 4; $i++){ if (($card[$i] == 'jc') and ($suit == 'c')){ $score = $score + 1; $combinations .= "\n"; $combinations .= "\n"; $combinations .= "\n"; $combinations .= "\n"; $combinations .= "And Nobs for $score.\n"; } if (($card[$i] == 'jd') and ($suit == 'd')){ $score = $score + 1; $combinations .= "\n"; $combinations .= "\n"; $combinations .= "\n"; $combinations .= "\n"; $combinations .= "And Nobs for $score.\n"; } if (($card[$i] == 'jh') and ($suit == 'h')){ $score = $score + 1; $combinations .= "\n"; $combinations .= "\n"; $combinations .= "\n"; $combinations .= "\n"; $combinations .= "And Nobs for $score.\n"; } if (($card[$i] == 'js') and ($suit == 's')){ $score = $score + 1; $combinations .= "\n"; $combinations .= "\n"; $combinations .= "\n"; $combinations .= "\n"; $combinations .= "And Nobs for $score.\n"; } // end if // print "\$card[$i]: $card[$i]
"; // print "\$suit : $suit
"; } // end for // print "\$score: $score
"; } // end function checkNobs ?>