- if(isset($_REQUEST["a"]))
- {
- $a = $_REQUEST["a"];
-
- if( ereg("[is]",$player[$a]["option"]) && $game["init"]<4)
- {
- echo "just wait for the game to start";
- }
- else if( !ereg("[is]",$player[$a]["option"]) )
- {
- ?>
- <form action="index.php" method="post">
- Do you want to play a game of DoKo?
- yes<input type="radio" name="in" value="yes" />
- no<input type="radio" name="in" value="no" /> <br />
-
- Do you want to get an email for every card played or only if it your move?
- every card<input type="radio" name="update" value="card" />
- only on my turn<input type="radio" name="update" value="turn" /> <br />
-<?php
- echo "<input type=\"hidden\" name=\"b\" value=\"$a\" />\n";
- echo "\n";
- echo "<input type=\"submit\" value=\"count me in\" />\n";
- echo " </form>\n";
- }
- }
-/* ***
- * * *
- * ***
- * * *
- * ***
- * yes? email him his hand, ask for solo, poverty, email every move or every card?
- */
- if(isset($_REQUEST["b"]))
- {
- $b = $_REQUEST["b"];
-
- if( ereg("s",$player[$b]["option"]) && $game["init"]<4)
- { /* the player already filled out everything */
- echo "just wait for the game to start";
- }
- else if( (!isset($_REQUEST["in"])|| !isset($_REQUEST["update"])) && !ereg("i",$player[$b]["option"]))
- { /* the player didn't fill out the form at "a" correctly */
- echo "go back to ";
- echo "<a href=\"index.php?a=$b\"> here and fill out the form </a> <br />\n";
- }
- else
- { /* show the hand and check if the player is sick*/
- if($_REQUEST["in"]=="no")
- { /* player doesn't want to play, cancel the game */
- for($i=0;$i<4;$i++)
- {
- $message = "Hello ".$player[$hash[$i]]["name"].",\n\n".
- "the game has been canceled due to the request of one of the players.\n";
- mymail($player[$hash[$i]]["email"],"[DoKo-Debug] the game has been canceled",$message);
- }
- /* canceling the game is as easy as removing the contents of the status file*/
- $output = fopen("status.txt","w");
- if($output)
- fclose($output);
- else
- echo "problem opening file";
- }
- else
- {
- /* player wants to play, save information from "a"*/
- if($_REQUEST["update"]=="card")
- $player[$b]["option"] .= "c";
- else
- $player[$b]["option"] .= "t";
-
- $player[$b]["option"] .= "i"; /* player finished stage "a" */
-
- save_status();
-
- $allcards = $player[$b]["cards"];
- $mycards = explode(";",$allcards);
-
- sort($mycards);
- echo "<p class=\"mycards\">your cards are: <br />\n";
- foreach($mycards as $card)
- display_card($card);
- echo "</p>\n";
- ?>
- <p> aehm... at the moment poverty is not implented. so I guess you need to play a normal game, even if you have less than 3 trump :(...sorry </p>
-
- <form action="index.php" method="post">
-
- do you want to play solo?
- <select name="solo" size="1">
- <option>No</option>
- <option>No trump</option>
- <option>Normal solo</option>
- <option>Queen solo</option>
- <option>Jack solo</option>
- <option>Club solo</option>
- <option>Spade solo</option>
- <option>Heart solo</option>
- </select>
- <br />
-
-<?php
-
- echo "wedding?";
- if(check_wedding($player[$b]["cards"]))
- {
- echo " yes<input type=\"radio\" name=\"wedding\" value=\"yes\" />";
- echo " no <input type=\"radio\" name=\"wedding\" value=\"no\" /> <br />\n";
- }
- else
- {
- echo " no <input type=\"hidden\" name=\"wedding\" value=\"no\" /> <br />\n";
- };
-
- echo "do you have poverty?";
- if(count_trump($player[$b]["cards"])<4)
- {
- echo " yes<input type=\"radio\" name=\"poverty\" value=\"yes\" />";
- echo " no <input type=\"radio\" name=\"poverty\" value=\"no\" /> <br />\n";
- }
- else
- {
- echo " no <input type=\"hidden\" name=\"poverty\" value=\"no\" /> <br />\n";
- };
-
- echo "do you have too many nines?";
- if(count_nines($player[$b]["cards"])>4)
- {
- echo " yes<input type=\"radio\" name=\"nines\" value=\"yes\" />";
- echo " no <input type=\"radio\" name=\"nines\" value=\"no\" /> <br />\n";
- }
- else
- {
- echo " no <input type=\"hidden\" name=\"nines\" value=\"no\" /> <br />\n";
- };
-
- echo "<input type=\"hidden\" name=\"c\" value=\"$b\" />\n";
- echo "<input type=\"submit\" value=\"count me in\" />\n";
-
- echo "</form>\n";
- }
- }
- }
-
- if(isset($_REQUEST["c"]))
- {
- $c = $_REQUEST["c"];
-
-
- if( ereg("s",$player[$c]["option"]) && $game["init"]<4 )
- { /* the player already filled out everything */
- echo "<p>just wait for the game to start</p>\n";
- }
- else if(!isset($_REQUEST["solo"]) ||
- !isset($_REQUEST["wedding"]) ||
- !isset($_REQUEST["poverty"]) ||
- !isset($_REQUEST["nines"]) )
- {/* player still needs to fill out the form */
- echo "go back to ";
- echo "<a href=\"index.php?b=$c\"> here and fill out the form </a> <br />\n";
- }
- else if($game["init"]<4)
- { /* save information */
- if( $_REQUEST["solo"]!="No")
- {
- switch($_REQUEST["solo"])
- {
- case "No trump":
- $player[$c]["option"].="O";
- break;
- case "Normal solo":
- $player[$c]["option"].="S";
- break;
- case "Queen solo":
- $player[$c]["option"].="Q";
- break;
- case "Jack solo":
- $player[$c]["option"].="J";
- break;
- case "Club solo":
- $player[$c]["option"].="C";
- break;
- case "Spade solo":
- $player[$c]["option"].="A";
- break;
- case "Hear solo":
- $player[$c]["option"].="H";
- break;
- }
- }
- else if($_REQUEST["wedding"] == "yes")
- {
- echo "wedding was chosen<br />\n";
- $player[$c]["option"].="W";
- }
- else if($_REQUEST["poverty"] == "yes")
- {
- echo "poverty was chosen<br />\n";
- $player[$c]["option"].="P";
- }
- else if($_REQUEST["nines"] == "yes")
- {
- echo "nines was chosen<br />\n";
- $player[$c]["option"].="N";
- }
-
- /* player finished setup */
- $player[$c]["option"].="s";
-
- save_status();
- /* reread status file, to get the correct startplayer, etc */
- if(file_exists("status.txt"))
- $lines = file("status.txt");
- else
- die("no file");
- parse_status();
-
- if($game["init"]==4 && $player[$c]["number"]==$game["startplayer"])
- {
- echo "<p> The game can start now, it's your turn, please use this <a href=\"".
- $host."?me=".$hash[$c]."\">link</a> to play a card.</p>\n";
- }
- else if($game["init"]==4)
- {
- $message = "The game can start now, it's your turn, please use this link to play a card:\n".
- $host."?me=".$hash[$game["startplayer"]]."\n";
- mymail($player[$hash[$game["startplayer"]]]["email"],"[DoKo-debug] let's go",$message);
- echo "<p> The game has started. An email has been sent out to the first player.</p>\n";
- }
- else
- {
- echo "<p>You're in. Once everyone has filled out the form, ".
- "the game will start and you'll get an eamil on your turn.</p>\n";
- }
- }
- }
- /* END SETUP */
-
- /* the game */
- if($game["init"]==4)
- {
- /* check for sickness, only would need to do this on the first trick really...*/
- /***** someone has 5 nines and no one is playing solo => cancel game */
- if($game["nines"]>=0 && $game["solo-who"]<0)
- {
- $message = $player[$hash[$game["poverty"]]]["nines"]." has more than 4 nines. Game aborted!\n";
- for($i=0;$i<4;$i++)
- mymail($player[$hash[$i]]["email"],"[DoKo-debug] the game has been canceled",$message);
-
- $output = fopen("status.txt","w");
- if($output)
- fclose($output);
- else
- echo "problem opening file";
- };
-
- /* who is requesting this*/
- if(!isset($_REQUEST["me"]))
- {
- if(!isset($_REQUEST["recovery"]))
- {
- echo "A game is in progress and kibitzing is not allowed. Sorry!.<br />\n";
- echo "In case you are playing, but lost your email or can't access the game anymore, please input your email here:<br />\n";
- ?>
- <form action="index.php" method="post">
- recorvery: <input name="recovery" type="text" size="20" maxlength="30" /> <br />
- <input type="submit" value="get me back into the game" />
- </form>
-<?php
- }
- else
- {
- $recovery = $_REQUEST["recovery"];
- $ok = -1;
- for($i=0;$i<4;$i++)
- if(trim($recovery)==trim($player[$hash[$i]]["email"]))
- $ok = $i;
- if($ok>=0)
- {
- $message = "Please try this link: ".$host."?me=".$hash[$ok]."\n".
- "\n if this doesn't work, contact the admin.error4\n";
- mymail($recovery,"[DoKo-Debug] recovery ",$message);
- echo "<p> An email with the game information has been sent.</p>\n";
- }
- else
- {
- echo "<p> can't find this email address, sorry.</p>\n";
- };
- } /* end recovery */
- }
- else
- { /* $me is set */
- $me = $_REQUEST["me"];
-
- /* show history */
- /* old tricks as list */
- echo "<ul class=\"oldtrick\">\n";
- echo " <li> History: </li>\n";
- $j=0;
- foreach($history as $play)
- {
- $j++;
- $trick = explode(":",$play);
-
- /* found old trick, display it */
- if(sizeof($trick)==5)
- echo " <li onclick=\"hl('$j');\"><a href=\"#\">Trick $j</a>\n <div class=\"table\" id=\"trick".$j."\">\n <img class=\"table\" src=\"pics/table".$play[0].".png\" alt=\"table\" />\n";
- else
- {
- /* display current trick */
- echo "<li onclick=\"hl('$j');\"><a href=\"#\">Current Trick</a>\n <div class=\"table\" id=\"trick".$j."\">\n <img class=\"table\" src=\"pics/table".$play[0].".png\" alt=\"table\" />";
- }
- for($i=0;$i<sizeof($trick)-1;$i++)
- {
- $card = $trick[$i];
-
- $last=-2;
- /* has a card been played? */
- if(ereg("->",$card))
- {
- $tmp = explode("->",$card);