3 function mymail($To,$Subject,$message)
9 $message = str_replace("\n","<br />",$message);
10 echo "<br />To: $To<br />Subject: $Subject <br />$message<br />\n";
13 mail($To,$Subject,$message);
17 function is_trump($c) { return (($c<27) ? 1:0);}
18 function is_club($c) { return (in_array($c,array('27','28','29','30','31','32','33','34')));}
19 function is_spade($c) { return (in_array($c,array('35','36','37','38','39','40','41','42')));}
20 function is_heart($c) { return (in_array($c,array('43','44','45','46','47','48')));}
22 function compare_cards($a,$b)
24 /* if a is higher than b return 1, else 0, a being the card first played */
26 /* first map all cards to the odd number */
27 if( $a/2 - (int)($a/2) != 0.5)
29 if( $b/2 - (int)($b/2) != 0.5)
32 if(is_trump($a) && $a<=$b)
34 else if(is_trump($a) && $a>$b)
37 { /*$a is not a trump */
43 if( is_club($a) && is_club($b))
49 if( is_spade($a) && is_spade($b))
55 if( is_heart($a) && is_heart($b))
66 function get_winner($p)
68 /* get all 4 cards played in a trick */
74 /* find out who won */
75 if( compare_cards($c1,$c2) && compare_cards($c1,$c3) && compare_cards($c1,$c4) )
77 if( compare_cards($c2,$c3) && compare_cards($c2,$c4) )
79 if( compare_cards($c3,$c4) )
84 function count_nines($cards)
90 if($c == "25" || $c == "26") $nines++;
91 else if($c == "33" || $c == "34") $nines++;
92 else if($c == "41" || $c == "42") $nines++;
93 else if($c == "47" || $c == "48") $nines++;
99 function check_wedding($cards)
102 if( in_array("3",$cards) && in_array("2",$cards) )
108 function count_trump($cards)
112 /* count each trump */
113 foreach($cards as $c)
118 if( in_array("19",$cards))
120 if( in_array("20",$cards) )
122 /* add one, in case the player has both foxes (schweinchen) */
123 if( in_array("19",$cards) && in_array("20",$cards) )
129 function card_to_name($card)
135 return "ten of hearts";
138 return "queen of clubs";
141 return "queen of spades";
144 return "queen of hearts";
147 return "queen of diamonds";
150 return "jack of clubs";
153 return "jack of spades";
156 return "jack of hearts";
159 return "jack of diamonds";
162 return "ace of diamonds";
165 return "ten of diamonds";
168 return "king of diamonds";
171 return "nine of diamonds";;
174 return "ace of clubs";
177 return "ten of clubs";
180 return "king of clubs";
183 return "nine of clubs";
186 return "ace of spades";
189 return "ten of spades";
192 return "king of spades";
195 return "nine of spades";
198 return "ace of hearts";
201 return "king of hearts";
204 return "nine of hearts";
206 return "something went wrong, please contact the admin. Error: code1.";
210 function card_value($card)
223 case 9: /* diamonds */
226 case 11: /* clubes */
228 case 13: /* spades */
230 case 15: /* hearts */
232 case 17: /* diamonds */
235 case 19: /* diamonds */
239 case 35: /* spades */
241 case 43: /* hearts */
244 case 21: /* diamonds */
248 case 37: /* spades */
251 case 23: /* diamonds */
255 case 39: /* spades */
257 case 45: /* hearts */
260 case 25: /* diamonds */
264 case 41: /* spades */
266 case 47: /* hearts */
270 echo "something went wrong, please contact the admin. ErrorCode: 2<br>";
275 function display_card($card)
277 /* cards are only availabl for the odd values, e.g. 1.png, 3.png, ...
278 * convert even cards to the matching odd value */
280 if( $card/2 - (int)($card/2) == 0.5)
281 echo "<img src=\"cards/".$card.".png\" alt=\"".card_to_name($card)."\" />\n";
283 echo "<img src=\"cards/".($card-1).".png\" alt=\"".card_to_name($card-1)."\" />\n";
288 function display_link_card($card)
290 if( $card/2 - (int)($card/2) == 0.5)
291 echo "<input type=\"radio\" name=\"card\" value=\"".$card."\" /><img src=\"cards/".$card.".png\" alt=\"\" />\n";
293 echo "<input type=\"radio\" name=\"card\" value=\"".$card."\" /><img src=\"cards/".($card-1).".png\" alt=\"\" />\n";
297 function create_array_of_random_numbers()
305 $r = array_rand($a,48);
310 function check_want_to_play($me)
313 <form action="index.php" method="post">
314 Do you want to play a game of DoKo?
315 yes<input type="radio" name="in" value="yes" />
316 no<input type="radio" name="in" value="no" /> <br />
318 Do you want to get an email for every card played or only if it your move?
319 every card<input type="radio" name="update" value="card" />
320 only on my turn<input type="radio" name="update" value="turn" /> <br />
322 echo "<input type=\"hidden\" name=\"me\" value=\"$me\" />\n";
324 echo "<input type=\"submit\" value=\"count me in\" />\n";
330 function check_for_sickness($me,$mycards)
333 <p> nothing implemented so far, but give it a try anyway ;) </p>
335 <form action="index.php" method="post">
337 do you want to play solo?
338 <select name="solo" size="1">
340 <option>trumpless</option>
341 <option>trump</option>
342 <option>queen</option>
343 <option>jack</option>
344 <option>club</option>
345 <option>spade</option>
346 <option>heart</option>
353 if(check_wedding($mycards))
355 echo " yes<input type=\"radio\" name=\"wedding\" value=\"yes\" />";
356 echo " no <input type=\"radio\" name=\"wedding\" value=\"no\" /> <br />\n";
360 echo " no <input type=\"hidden\" name=\"wedding\" value=\"no\" /> <br />\n";
363 echo "do you have poverty?";
364 if(count_trump($mycards)<4)
366 echo " yes<input type=\"radio\" name=\"poverty\" value=\"yes\" />";
367 echo " no <input type=\"radio\" name=\"poverty\" value=\"no\" /> <br />\n";
371 echo " no <input type=\"hidden\" name=\"poverty\" value=\"no\" /> <br />\n";
374 echo "do you have too many nines?";
375 if(count_nines($mycards)>4)
377 echo " yes<input type=\"radio\" name=\"nines\" value=\"yes\" />";
378 echo " no <input type=\"radio\" name=\"nines\" value=\"no\" /> <br />\n";
382 echo " no <input type=\"hidden\" name=\"nines\" value=\"no\" /> <br />\n";
385 echo "<input type=\"hidden\" name=\"me\" value=\"$me\" />\n";
386 echo "<input type=\"submit\" value=\"count me in\" />\n";
393 function display_status()
395 echo "<div class=\"info\">";
396 echo " is someone playing solo, etc?";
402 function display_news()
405 echo "<div class=\"bug\"> ".
406 "Please hit shift+reload.<br /><hr />".
407 "Fixed a few bugs, comments might be working again <br /><hr />".
408 "If you find more bugs, please list them in the <a href=\"".$wiki.
409 "\">wiki</a>.</div>\n";
413 function display_cards($me,$myturn)
418 function return_timezone($offset)
423 $zone = "Europe/Berlin";
426 $zone = "America/Vancouver";
429 $zone = "Pacific/Auckland";
432 $zone = "Europe/London";