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 is_trump($c,$game)
40 if(in_array($c,array('3','4','5','6','7','8','9','10')))
46 return (($c<27) ? 1:0);
51 function is_same_suite($c1,$c2,$game)
57 if(in_array($c1,array('11','12','27','28','29','30','31','32','33','34')) &&
58 in_array($c2,array('11','12','27','28','29','30','31','32','33','34')) )
61 if(in_array($c1,array('13','14','35','36','37','38','39','40','41','42')) &&
62 in_array($c2,array('13','14','35','36','37','38','39','40','41','42')) )
65 if(in_array($c1,array( '1', '2','15','16','43','44','45','46','47','48')) &&
66 in_array($c2,array( '1', '2','15','16','43','44','45','46','47','48')) )
69 if(in_array($c1,array('17','18','19','20','21','22','23','24','25','26')) &&
70 in_array($c2,array('17','18','19','20','21','22','23','24','25','26')) )
77 if(in_array($c1,array('27','28','29','30','31','32','33','34')) &&
78 in_array($c2,array('27','28','29','30','31','32','33','34')) )
81 if(in_array($c1,array('35','36','37','38','39','40','41','42')) &&
82 in_array($c2,array('35','36','37','38','39','40','41','42')) )
85 if(in_array($c1,array('43','44','45','46','47','48')) &&
86 in_array($c2,array('43','44','45','46','47','48')) )
94 function compare_cards($a,$b,$game)
96 /* if "a" is higher than "b" return 1, else 0, "a" being the card first played */
98 /* first map all cards to the odd number,
99 * this insure that the first card wins the trick
100 * if they are the same card
102 if( $a/2 - (int)($a/2) != 0.5)
104 if( $b/2 - (int)($b/2) != 0.5)
114 if(is_trump($a,$game) && $a<=$b)
116 else if(is_trump($a,$game))
119 { /*$a is not a trump */
120 if(is_trump($b,$game))
124 if(is_same_suite($a,$b,$game))
130 /* not the same suit and no trump: a wins */
144 if($a==1 && $b==1) /* both 10 of hearts */
145 return 0; /* second one wins. TODO should be able to set this at the start of a new game */
146 if(is_trump($a,$game) && $a<=$b)
148 else if(is_trump($a,$game))
151 { /*$a is not a trump */
152 if(is_trump($b,$game))
156 if(is_same_suite($a,$b,$game))
162 /* not the same suit and no trump: a wins */
169 function get_winner($p,$mode)
171 /* get all 4 cards played in a trick */
177 /* find out who won */
178 if( compare_cards($c1,$c2,$mode) && compare_cards($c1,$c3,$mode) && compare_cards($c1,$c4,$mode) )
180 if( !compare_cards($c1,$c2,$mode) && compare_cards($c2,$c3,$mode) && compare_cards($c2,$c4,$mode) )
182 if( !compare_cards($c1,$c3,$mode) && !compare_cards($c2,$c3,$mode) && compare_cards($c3,$c4,$mode) )
187 function count_nines($cards)
191 foreach($cards as $c)
193 if($c == "25" || $c == "26") $nines++;
194 else if($c == "33" || $c == "34") $nines++;
195 else if($c == "41" || $c == "42") $nines++;
196 else if($c == "47" || $c == "48") $nines++;
202 function check_wedding($cards)
205 if( in_array("3",$cards) && in_array("2",$cards) )
211 function count_trump($cards)
215 /* count each trump */
216 foreach($cards as $c)
221 if( in_array("19",$cards))
223 if( in_array("20",$cards) )
225 /* add one, in case the player has both foxes (schweinchen) */
226 if( in_array("19",$cards) && in_array("20",$cards) )
232 function card_to_name($card)
238 return "ten of hearts";
241 return "queen of clubs";
244 return "queen of spades";
247 return "queen of hearts";
250 return "queen of diamonds";
253 return "jack of clubs";
256 return "jack of spades";
259 return "jack of hearts";
262 return "jack of diamonds";
265 return "ace of diamonds";
268 return "ten of diamonds";
271 return "king of diamonds";
274 return "nine of diamonds";;
277 return "ace of clubs";
280 return "ten of clubs";
283 return "king of clubs";
286 return "nine of clubs";
289 return "ace of spades";
292 return "ten of spades";
295 return "king of spades";
298 return "nine of spades";
301 return "ace of hearts";
304 return "king of hearts";
307 return "nine of hearts";
309 return "something went wrong, please contact the admin. Error: code1.";
313 function card_value($card)
326 case 9: /* diamonds */
329 case 11: /* clubes */
331 case 13: /* spades */
333 case 15: /* hearts */
335 case 17: /* diamonds */
338 case 19: /* diamonds */
342 case 35: /* spades */
344 case 43: /* hearts */
347 case 21: /* diamonds */
351 case 37: /* spades */
354 case 23: /* diamonds */
358 case 39: /* spades */
360 case 45: /* hearts */
363 case 25: /* diamonds */
367 case 41: /* spades */
369 case 47: /* hearts */
373 echo "something went wrong, please contact the admin. ErrorCode: 2<br>";
379 function create_array_of_random_numbers()
387 $r = array_rand($a,48);
395 function display_cards($me,$myturn)
400 function return_timezone($offset)
405 $zone = "Europe/Berlin";
408 $zone = "America/Vancouver";
411 $zone = "Pacific/Auckland";
414 $zone = "Europe/London";