Jump to content

reference only


Recommended Posts

<?phpsession_start();error_reporting(0);?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /><title>Caitlin's Acey Ducey</title><link rel="stylesheet" type="text/css" href="style.css" /></head><body><div class="roundedBox"><div class="top"><div class="bottom"><div class="left"><div class="right"><div class="topLeft"><div class="topRight"><div class="bottomLeft"><div class="bottomRight"><div class="boxContent"><div id="content"><form method='post'><?php$nextaction = isset($_POST['dowhat']) ? $_POST['dowhat'] : '';/************ SCORING SYSTEM */if (empty($_SESSION)){$_SESSION['potscore']=200;  //$potscore= $_SESSION['potscore'];$_SESSION['blackscore']=900;  //$blackscore=$_SESSION['blackscore'];$_SESSION['goldscore']=900;  //$goldscore= $_SESSION['goldscore'];//var_dump($_SESSION);}function maxcard_displayfunc(){//var_dump($_SESSION);  $highcard=$_SESSION['maxcardsess'];  switch ($highcard)   {   case 1:    return $maxcard_display="<img class='card_display' src='images/A.jpg' alt=' ' />";	 break;   case 2:    return $maxcard_display="<img class='card_display' src='images/2.jpg' alt=' ' />";	 break;   case 3:    return $maxcard_display="<img class='card_display' src='images/3.jpg' alt=' ' />";	 break;   case 4:    return $maxcard_display="<img class='card_display' src='images/4.jpg' alt=' ' />";	 break;   case 5:    return $maxcard_display="<img class='card_display' src='images/5.jpg' alt=' ' />";	 break;   case 6:    return $maxcard_display="<img class='card_display' src='images/6.jpg' alt=' ' />";	 break;   case 7:    return $maxcard_display="<img class='card_display' src='images/7.jpg' alt=' ' />";	 break;   case 8:    return $maxcard_display="<img class='card_display' src='images/8.jpg' alt=' ' />";	 break;   case 9:    return $maxcard_display="<img class='card_display' src='images/9.jpg' alt=' ' />";	 break;   case 10:    return $maxcard_display="<img class='card_display' src='images/10.jpg' alt=' ' />";	 break;   case 14:    return $maxcard_display="<img class='card_display' src='images/A.jpg' alt=' ' />";	 break;   case 11:	 return $maxcard_display="<img class='card_display' src='images/J.jpg' alt=' ' />";	 break;   case 12:	 return $maxcard_display="<img class='card_display' src='images/Q.jpg' alt=' ' />";   break;   case 13:	 return $maxcard_display="<img class='card_display' src='images/K.jpg' alt=' ' />";	 break;   default:	 return $maxcard_display=$highcard;   }}function mincard_displayfunc(){// var_dump($_SESSION);$lowcard=$_SESSION['mincardsess'];switch ($lowcard)   {   case 1:    return $mincard_display="<img class='card_display' src='images/A.jpg' alt=' ' />";	 break;   case 2:    return $mincard_display="<img class='card_display' src='images/2.jpg' alt=' ' />";	 break;   case 3:    return $mincard_display="<img class='card_display' src='images/3.jpg' alt=' ' />";	 break;   case 4:    return $mincard_display="<img class='card_display' src='images/4.jpg' alt=' ' />";	 break;   case 5:    return $mincard_display="<img class='card_display' src='images/5.jpg' alt=' ' />";	 break;   case 6:    return $mincard_display="<img class='card_display' src='images/6.jpg' alt=' ' />";	 break;   case 7:    return $mincard_display="<img class='card_display' src='images/7.jpg' alt=' ' />";	 break;   case 8:    return $mincard_display="<img class='card_display' src='images/8.jpg' alt=' ' />";	 break;   case 9:    return $mincard_display="<img class='card_display' src='images/9.jpg' alt=' ' />";	 break;   case 10:    return $mincard_display="<img class='card_display' src='images/10.jpg' alt=' ' />";	 break;   case 11:	 return $mincard_display="<img class='card_display' src='images/J.jpg' alt=' ' />";	 break;   case 12:	 return $mincard_display="<img class='card_display' src='images/Q.jpg' alt=' ' />";   break;   case 13:	 return $mincard_display="<img class='card_display' src='images/K.jpg' alt=' ' />";;	 break;   case 14:    return $mincard_display="<img class='card_display' src='images/A.jpg' alt=' ' />";	 break;   default:	 return $mincard_display=$lowcard;   }}function wincardfunc($wincard){  switch ($wincard)   {   case 1:    return $wincard_display="<img class='card_display' src='images/A.jpg' alt=' ' />";	 break;   case 2:    return $wincard_display="<img class='card_display' src='images/2.jpg' alt=' ' />";	 break;   case 3:    return $wincard_display="<img class='card_display' src='images/3.jpg' alt=' ' />";	 break;   case 4:    return $wincard_display="<img class='card_display' src='images/4.jpg' alt=' ' />";	 break;   case 5:    return $wincard_display="<img class='card_display' src='images/5.jpg' alt=' ' />";	 break;   case 6:    return $wincard_display="<img class='card_display' src='images/6.jpg' alt=' ' />";	 break;   case 7:    return $wincard_display="<img class='card_display' src='images/7.jpg' alt=' ' />";	 break;   case 8:    return $wincard_display="<img class='card_display' src='images/8.jpg' alt=' ' />";	 break;   case 9:    return $wincard_display="<img class='card_display' src='images/9.jpg' alt=' ' />";	 break;   case 10:    return $wincard_display="<img class='card_display' src='images/10.jpg' alt=' ' />";	 break;   case 11:	 return $wincard_display="<img class='card_display' src='images/J.jpg' alt=' ' />";	 break;   case 12:	 return $wincard_display="<img class='card_display' src='images/Q.jpg' alt=' ' />";   break;   case 13:	 return $wincard_display="<img class='card_display' src='images/K.jpg' alt=' ' />";	 break;   case 14:    return $wincard_display="<img class='card_display' src='images/A.jpg' alt=' ' />";	 break;   default:	 return $wincard_display=$wincard;   }}function whosturn(){if(!isset($_SESSION['turnsess']) || $_SESSION['turnsess']=="gold"){  return $_SESSION['turnsess']="black";}else{  return $_SESSION['turnsess']="gold";}}print"<h1 id='header'>Acey-Ducey</h1>";maincontent();/*print "<div class='right_side'><h2>Score:</h2><br/><h3 class='pot'>POT</h3><h3 class='pot'>" .$_SESSION['potscore']. "</h3></br><h3 class='black'>Black</h3><h3 class='black'>" .$_SESSION['blackscore']. "</h3></br><h3 class='gold'>Gold</h3><h3 class='gold'>" .$_SESSION['goldscore']. "</h3></br></div>";*/ function maincontent(){global $nextaction;if (!$nextaction || ($nextaction=="PASS") || ($nextaction=="NEXT DRAW") || ($nextaction=="CLEAR/PLAY AGAIN")){ ################### SCREEN 1#################  if($nextaction=="CLEAR/PLAY AGAIN"){  $_SESSION['potscore']=200;  $_SESSION['blackscore']=900;  $_SESSION['goldscore']=900;   }   $target1=rand(2,14);  $target2=rand(2,14);  //$wincard=rand(1,14);   $maxcard=max($target1,$target2);  $mincard=min($target1,$target2);   $_SESSION['maxcardsess']=$maxcard;  $_SESSION['mincardsess']=$mincard;  $maxcard_value=$_SESSION['maxcardsess'];  $mincard_value=$_SESSION['mincardsess'];    //change the way value is displayed (to look like a card J,K,Q,A)  $maxcard_display=maxcard_displayfunc();  $mincard_display=mincard_displayfunc();    ////////////////////////////////////////////////////////  //  If card is an ace, change value of ace to 1 or 14,  //  whichever is more favorable to user.  ////////////////////////////////////////////////////////   if($maxcard_display=="A"){   $othercard=$_SESSION['mincardsess'];     if($othercard-1 > 14-$othercard){    $acecard=1;    $_SESSION['maxcardsess']=max($othercard,$acecard);    $_SESSION['mincardsess']=min($othercard,$acecard);    print "</br>Ace will have a value of $acecard, because it favors your bet.";   }else{    $acecard=14;    $_SESSION['maxcardsess']=max($othercard,$acecard);    $_SESSION['mincardsess']=min($othercard,$acecard);    print "</br>Ace will have a value of $acecard, because it favors your bet.";   }   }else if($mincard_display=="A"){   $othercard=$_SESSION['maxcardsess'];     if($othercard-1 > 14-$othercard){    $acecard=1;    $_SESSION['maxcardsess']=max($othercard,$acecard);    $_SESSION['mincardsess']=min($othercard,$acecard);    print "</br>Ace will have a value of $acecard, because it favors your bet.";   }   else{    $acecard=14;    $_SESSION['maxcardsess']=max($othercard,$acecard);    $_SESSION['mincardsess']=min($othercard,$acecard);    print "</br>Ace will have a value of $acecard, because it favors your bet.";  }}   /// 	 /////////////////////////////////////////////////////  //  If cards are too close in value, generate new set  ////////////////////////////////////////////////////////  if(($maxcard_value-$mincard_value==0) || ($maxcard_value-$mincard_value==1)){   maincontent();  }else{   $turn=whosturn();  print "<div class='right_side'><p>It is <b>$turn</b> team's turn.</p> <br /></div>";  print "<div class='cards'><div class='cardboxes'>high card=<br/>$maxcard_display </div>";  print "<div class='cardboxes'>low card=<br/>$mincard_display</div></div><br /><br />";  print "<div class='input'>Input your bet (with a value of 1 to " .$_SESSION['potscore']. "): <input type='text' name='betvalue'></div>";  print "<div class='buttons'><input type='submit' name='dowhat' value='BET'>";  print "<input type='submit' name='dowhat' value='PASS'>";  print "<input type='submit' name='dowhat' value='CLEAR/PLAY AGAIN'></div>";   print "<div class='right_side'><h2>Score:</h2><br/><h3 class='pot'>POT</h3><h3 class='pot'>" .$_SESSION['potscore']. "</h3></br><h3 class='black'>Black</h3><h3 class='black'>" .$_SESSION['blackscore']. "</h3></br><h3 class='gold'>Gold</h3><h3 class='gold'>" .$_SESSION['goldscore']. "</h3></br></div>";  } }else if ($nextaction=="BET"){  ####################  # SCREEN TWO  ####################  $_SESSION['inputbet']=intval($_POST['betvalue']);  $turn=$_SESSION['turnsess'];  print "<div class='right_side'><p>It is <b>$turn</b> team's turn.</p> <br /></div>";  $wincard=rand(2,14);   $wincard_display=wincardfunc($wincard);   $maxcard_display=maxcard_displayfunc();  $mincard_display=mincard_displayfunc();   $maxvalue=$_SESSION['maxcardsess'];  $minvalue=$_SESSION['mincardsess'];   print "<div class='cards'><div class='cardboxes'>highcard=<br/>$maxcard_display </div>";  print "<div class='cardboxes'>target=<br/>$wincard_display </div>";  print "<div class='cardboxes'>lowcard=<br/>$mincard_display </div></div>";   if (($wincard<$maxvalue) && ($wincard>$minvalue))  {   print "<div class='buttons'><br /><br/><p class='bigtext'>You win!</p><br/>";  /**********SCORING SYSTEM*/    $_SESSION["{$turn}score"] += $_SESSION['inputbet'];   $_SESSION['potscore'] -= $_SESSION['inputbet'];    }else{   print "<div class='buttons'><br /><br/><p class='bigtext'>You lose!</p><br/>";  /**********SCORING SYSTEM*/   $_SESSION["{$turn}score"] -= $_SESSION['inputbet'];   $_SESSION['potscore'] += $_SESSION['inputbet'];    }   print "<input type='submit' name='dowhat' value='NEXT DRAW'></div>";/***********SCORING SYSTEM*/   //run out of money in pot   if($_SESSION['potscore']==0){    $_SESSION['potscore']=200;    $_SESSION['blackscore'] -= 100;    $_SESSION['goldscore'] -= 100;   }print "<div class='right_side'><h2>Score:</h2><br/><h3 class='pot'>POT</h3><h3 class='pot'>" .$_SESSION['potscore']. "</h3></br><h3 class='black'>Black</h3><h3 class='black'>" .$_SESSION['blackscore']. "</h3></br><h3 class='gold'>Gold</h3><h3 class='gold'>" .$_SESSION['goldscore']. "</h3></br></div>";   //winner loser  }else if($_SESSION['goldscore']==0){    print "<p class='bigtext'>Black team wins!</p>";      }else if($_SESSION['blackscore']==0){    print"<p class='bigtext'>Gold team wins!</p>";      } else{  print "Error 100: nextaction=$nextaction, but I don't know what to do.";}}?><tt>Website and program by Caitlin Havener. <br/>Card graphics from http://sopapeldeparede.com.br.</tt></form></div></div></div></div></div></div></div></div></div></div></div></body></html>

Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...