2 "-//W3C//DTD XHTML 1.1 plus MathML 2.0 plus SVG 1.1//EN"
3 "http://www.w3.org/2002/04/xhtml-math-svg/xhtml-math-svg.dtd">
4 <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
6 <title>Doko via email</title>
7 <link rel="stylesheet" type="text/css" href="standard.css"/>
10 <h1> Welcome to E-Doko </h1>
13 /* check for status file and read it, if possible */
15 if(file_exists("status.txt"))
16 $lines = file("status.txt");
20 /* check if we want to start a new game */
21 if( isset($_REQUEST["PlayerA"]) &&
22 isset($_REQUEST["PlayerB"]) &&
23 isset($_REQUEST["PlayerC"]) &&
24 isset($_REQUEST["PlayerD"]) &&
25 isset($_REQUEST["EmailA"]) &&
26 isset($_REQUEST["EmailB"]) &&
27 isset($_REQUEST["EmailC"]) &&
28 isset($_REQUEST["EmailD"]) )
30 $PlayerA = $_REQUEST["PlayerA"];
31 $PlayerB = $_REQUEST["PlayerB"];
32 $PlayerC = $_REQUEST["PlayerC"];
33 $PlayerD = $_REQUEST["PlayerD"];
34 $EmailA = $_REQUEST["EmailA"] ;
35 $EmailB = $_REQUEST["EmailB"] ;
36 $EmailC = $_REQUEST["EmailC"] ;
37 $EmailD = $_REQUEST["EmailD"] ;
39 /* send out email, check for error with email */
40 echo "send out emails to everyone, asking if they want to join";
42 echo "<a href=\"index.php?a=hash1\"> player 1</a> <br />";
43 echo "<a href=\"index.php?a=hash2\"> player 2</a> <br />";
44 echo "<a href=\"index.php?a=hash3\"> player 3</a> <br />";
45 echo "<a href=\"index.php?a=hash4\"> player 4</a> <br />";
46 /* read in random.txt */
47 if(file_exists("random.txt"))
48 $random = file("random.txt");
50 die("no random file");
52 $randomNR = explode( ":", $random[1] );
54 /* write status into file */
55 $output = fopen("status.txt","w");
58 fwrite($output, "0\n");
60 fwrite($output, "hash1:".$PlayerA.":".$EmailA."::" );
62 fwrite($output,";$randomNR[$i]" );
65 fwrite($output, "hash2:$PlayerB:$EmailB::" );
67 fwrite($output,";$randomNR[$i]" );
70 fwrite($output, "hash3:$PlayerC:$EmailC::" );
72 fwrite($output,";$randomNR[$i]" );
75 fwrite($output, "hash4:$PlayerD:$EmailD::");
77 fwrite($output,";$randomNR[$i]" );
83 echo "can't open file for writing";
86 /* test if a game is running, else output everything for a new game */
90 <p> no game in progress, please input 4 names and email addresses </p>
91 <form action="index.php" method="post">
92 Name: <input name="PlayerA" type="text" size="10" maxlength="20" />
93 Email: <input name="EmailA" type="text" size="10" maxlength="20" /> <br />
95 Name: <input name="PlayerB" type="text" size="10" maxlength="20" />
96 Email: <input name="EmailB" type="text" size="10" maxlength="20" /> <br />
98 Name: <input name="PlayerC" type="text" size="10" maxlength="20" />
99 Email: <input name="EmailC" type="text" size="10" maxlength="20" /> <br />
101 Name: <input name="PlayerD" type="text" size="10" maxlength="20" />
102 Email: <input name="EmailD" type="text" size="10" maxlength="20" /> <br />
104 <input type="submit" value="start game" />
109 { /* load game status */
110 $tmp = explode( ":",$lines[1]);
111 $player[$tmp[0]]["name"] = $tmp[1];
112 $player[$tmp[0]]["email"] = $tmp[2];
113 $player[$tmp[0]]["option"] = $tmp[3];
114 $player[$tmp[0]]["cards"] = $tmp[4];
116 $tmp = explode( ":",$lines[2]);
117 $player[$tmp[0]]["name"] = $tmp[1];
118 $player[$tmp[0]]["email"] = $tmp[2];
119 $player[$tmp[0]]["option"] = $tmp[3];
120 $player[$tmp[0]]["cards"] = $tmp[4];
122 $tmp = explode( ":",$lines[3]);
123 $player[$tmp[0]]["name"] = $tmp[1];
124 $player[$tmp[0]]["email"] = $tmp[2];
125 $player[$tmp[0]]["option"] = $tmp[3];
126 $player[$tmp[0]]["cards"] = $tmp[4];
128 $tmp = explode( ":",$lines[4]);
129 $player[$tmp[0]]["name"] = $tmp[1];
130 $player[$tmp[0]]["email"] = $tmp[2];
131 $player[$tmp[0]]["option"] = $tmp[3];
132 $player[$tmp[0]]["cards"] = $tmp[4];
135 /* check if a player wants to accept a game */
136 if(isset($_REQUEST["a"]))
140 <form action="index.php" method="post">
141 Do you want to play a game of DoKo?
142 yes<input type="radio" name="in" value="yes" />
143 no<input type="radio" name="in" value="no" /> <br />
145 Do you want to get an email for every card played or only if it your move?
146 every card<input type="radio" name="update" value="card" />
147 only on my turn<input type="radio" name="update" value="turn" /> <br />
149 echo "<input type=\"hidden\" name=\"b\" value=\"$a\" />\n";
151 echo "<input type=\"submit\" value=\"count me in\" />\n";
154 /* yes? email him his hand, ask for solo, poverty, email every move or every card? */
155 if(isset($_REQUEST["b"]))
158 echo "hash is $b <br>";
159 if(!isset($_REQUEST["in"])|| !isset($_REQUEST["update"]) )
162 echo "<a href=\"index.php?a=$b\"> here and fill out the form </a> <br />";
165 { /* show the hand */
166 echo $player[$b]["cards"];
167 $tmp = $player[$b]["cards"];
168 $cards = explode( ":",$tmp);
169 echo "your cards are";
170 foreach($cards as $card) echo " $card ";
173 <form action="index.php" method="post">
175 do you want to play solo?
176 yes<input type="radio" name="solo" value="yes" />
177 no<input type="radio" name="solo" value="no" /> <br />
179 do you have a wedding?
180 yes<input type="radio" name="wedding" value="yes" />
181 no<input type="radio" name="wedding" value="no" /> <br />
184 yes<input type="radio" name="poverty" value="yes" />
185 no<input type="radio" name="poverty" value="no" /> <br />
188 <input type="hidden" name="c" value="$b" />
190 <input type="submit" value="count me in" />
196 } /* is this the last player that needs to accept? */
197 /* yes, figure out who starts, send out email to first player */
198 /* no, email the rest to cancel game */
200 /* player wants to make a move? */
201 /* check if it is this players turn it is (if it's the players turn, convert cards into links) */
202 /* if it is the last card played*/
203 /* add checkbox for who one the trick */
204 /* email next player */
205 /* last card played? */
206 /* count score for each player */