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);
19 /* returns 1 if all names passed as args are defined by a GET or POST statement,
24 $args = func_get_args();
26 foreach($args as $arg)
28 $ok = $ok * isset($_REQUEST[$arg]);
29 /* echo "$arg: ok = $ok <br />";
35 function pos_array($c,$arr)
52 function is_trump($c,$game)
57 if(in_array($c,array('3','4','5','6','7','8','9','10')))
63 return (($c<27) ? 1:0);
68 function is_same_suite($c1,$c2,$game)
74 if(in_array($c1,array('11','12','27','28','29','30','31','32','33','34')) &&
75 in_array($c2,array('11','12','27','28','29','30','31','32','33','34')) )
78 if(in_array($c1,array('13','14','35','36','37','38','39','40','41','42')) &&
79 in_array($c2,array('13','14','35','36','37','38','39','40','41','42')) )
82 if(in_array($c1,array( '1', '2','15','16','43','44','45','46','47','48')) &&
83 in_array($c2,array( '1', '2','15','16','43','44','45','46','47','48')) )
86 if(in_array($c1,array('17','18','19','20','21','22','23','24','25','26')) &&
87 in_array($c2,array('17','18','19','20','21','22','23','24','25','26')) )
94 if(in_array($c1,array('27','28','29','30','31','32','33','34')) &&
95 in_array($c2,array('27','28','29','30','31','32','33','34')) )
98 if(in_array($c1,array('35','36','37','38','39','40','41','42')) &&
99 in_array($c2,array('35','36','37','38','39','40','41','42')) )
102 if(in_array($c1,array('43','44','45','46','47','48')) &&
103 in_array($c2,array('43','44','45','46','47','48')) )
111 function compare_cards($a,$b,$game)
113 /* if "a" is higher than "b" return 1, else 0, "a" being the card first played */
115 /* first map all cards to the odd number,
116 * this insure that the first card wins the trick
117 * if they are the same card
119 if( $a/2 - (int)($a/2) != 0.5)
121 if( $b/2 - (int)($b/2) != 0.5)
131 if(is_trump($a,$game) && is_trump($b,$game) && $a<=$b)
133 else if(is_trump($a,$game) && is_trump($b,$game) )
136 { /*$a is not a trump */
137 if(is_trump($b,$game))
140 { /* both no trump */
142 $posA = pos_array($a,array('27','28','29','30','31','32','11','12','33','34'));
143 $posB = pos_array($b,array('27','28','29','30','31','32','11','12','33','34'));
150 $posA = pos_array($a,array('35','36','37','38','39','40','13','14','41','42'));
151 $posB = pos_array($b,array('35','36','37','38','39','40','13','14','41','42'));
158 $posA = pos_array($a,array('43','44','15','16','45','46', '1', '2','47','48'));
159 $posB = pos_array($b,array('43','44','15','16','45','46', '1', '2','47','48'));
166 $posA = pos_array($a,array('19','20','21','22','23','24','17','18','25','26'));
167 $posB = pos_array($b,array('19','20','21','22','23','24','17','18','25','26'));
174 /* not the same suit and no trump: a wins */
188 if($a==1 && $b==1) /* both 10 of hearts */
189 return 0; /* second one wins. TODO should be able to set this at the start of a new game */
190 if(is_trump($a,$game) && $a<=$b)
192 else if(is_trump($a,$game))
195 { /*$a is not a trump */
196 if(is_trump($b,$game))
200 if(is_same_suite($a,$b,$game))
206 /* not the same suit and no trump: a wins */
213 function get_winner($p,$mode)
215 /* get all 4 cards played in a trick */
221 /* find out who won */
222 if( compare_cards($c1,$c2,$mode) && compare_cards($c1,$c3,$mode) && compare_cards($c1,$c4,$mode) )
224 if( !compare_cards($c1,$c2,$mode) && compare_cards($c2,$c3,$mode) && compare_cards($c2,$c4,$mode) )
226 if( !compare_cards($c1,$c3,$mode) && !compare_cards($c2,$c3,$mode) && compare_cards($c3,$c4,$mode) )
231 function count_nines($cards)
235 foreach($cards as $c)
237 if($c == "25" || $c == "26") $nines++;
238 else if($c == "33" || $c == "34") $nines++;
239 else if($c == "41" || $c == "42") $nines++;
240 else if($c == "47" || $c == "48") $nines++;
246 function check_wedding($cards)
249 if( in_array("3",$cards) && in_array("2",$cards) )
255 function count_trump($cards)
259 /* count each trump */
260 foreach($cards as $c)
265 if( in_array("19",$cards))
267 if( in_array("20",$cards) )
269 /* add one, in case the player has both foxes (schweinchen) */
270 if( in_array("19",$cards) && in_array("20",$cards) )
276 function card_to_name($card)
282 return "ten of hearts";
285 return "queen of clubs";
288 return "queen of spades";
291 return "queen of hearts";
294 return "queen of diamonds";
297 return "jack of clubs";
300 return "jack of spades";
303 return "jack of hearts";
306 return "jack of diamonds";
309 return "ace of diamonds";
312 return "ten of diamonds";
315 return "king of diamonds";
318 return "nine of diamonds";;
321 return "ace of clubs";
324 return "ten of clubs";
327 return "king of clubs";
330 return "nine of clubs";
333 return "ace of spades";
336 return "ten of spades";
339 return "king of spades";
342 return "nine of spades";
345 return "ace of hearts";
348 return "king of hearts";
351 return "nine of hearts";
353 return "something went wrong, please contact the admin. Error: code1.";
357 function card_value($card)
370 case 9: /* diamonds */
373 case 11: /* clubes */
375 case 13: /* spades */
377 case 15: /* hearts */
379 case 17: /* diamonds */
382 case 19: /* diamonds */
386 case 35: /* spades */
388 case 43: /* hearts */
391 case 21: /* diamonds */
395 case 37: /* spades */
398 case 23: /* diamonds */
402 case 39: /* spades */
404 case 45: /* hearts */
407 case 25: /* diamonds */
411 case 41: /* spades */
413 case 47: /* hearts */
417 echo "something went wrong, please contact the admin. ErrorCode: 2<br>";
423 function create_array_of_random_numbers()
431 $r = array_rand($a,48);
439 function display_cards($me,$myturn)
444 function return_timezone($offset)
449 $zone = "Europe/Berlin";
452 $zone = "America/Vancouver";
455 $zone = "Pacific/Auckland";
458 $zone = "Europe/London";