88cbf6b18d376c76a59594d37a35ab3f54e0e228
[e-DoKo.git] / include / output.php
1 <?php
2 /* Copyright 2006, 2007, 2008, 2009, 2010 Arun Persaud <arun@nubati.net>
3  *
4  *   This file is part of e-DoKo.
5  *
6  *   e-DoKo is free software: you can redistribute it and/or modify
7  *   it under the terms of the GNU General Public License as published by
8  *   the Free Software Foundation, either version 3 of the License, or
9  *   (at your option) any later version.
10  *
11  *   e-DoKo is distributed in the hope that it will be useful,
12  *   but WITHOUT ANY WARRANTY; without even the implied warranty of
13  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14  *   GNU General Public License for more details.
15  *
16  *   You should have received a copy of the GNU General Public License
17  *   along with e-DoKo.  If not, see <http://www.gnu.org/licenses/>.
18  *
19  */
20
21 /* make sure that we are not called from outside the scripts,
22  * use a variable defined in config.php to check this
23  */
24 if(!isset($HOST))
25   exit;
26
27 /* functions which only ouput html  */
28
29 function output_ask_for_new_game($playerA,$playerB,$playerC,$playerD,$oldgameid)
30 {
31   global $RULES;
32
33   echo "<div class=\"message\">\n<form action=\"index.php?action=new\" method=\"post\">\n";
34   $output = sprintf(_('Do you want to continue playing? (This will start a new game, with %s starting the game.)'),$playerA);
35   echo $output."\n";
36   echo "  <input type=\"hidden\" name=\"PlayerA\" value=\"$playerA\" />\n";
37   echo "  <input type=\"hidden\" name=\"PlayerB\" value=\"$playerB\" />\n";
38   echo "  <input type=\"hidden\" name=\"PlayerC\" value=\"$playerC\" />\n";
39   echo "  <input type=\"hidden\" name=\"PlayerD\" value=\"$playerD\" />\n";
40   echo "  <input type=\"hidden\" name=\"dullen\"  value=\"".$RULES['dullen']."\" />\n";
41   echo "  <input type=\"hidden\" name=\"schweinchen\" value=\"".$RULES['schweinchen']."\" />\n";
42   echo "  <input type=\"hidden\" name=\"callrule\" value=\"".$RULES['call']."\" />\n";
43   echo "  <input type=\"hidden\" name=\"lowtrump\" value=\"".$RULES['lowtrump']."\" />\n";
44   echo "  <input type=\"hidden\" name=\"followup\" value=\"$oldgameid\" />\n";
45   echo "  <input type=\"submit\" value=\""._('keep playing')."\" />\n";
46   echo "</form>\n</div>";
47   return;
48 }
49
50 function output_form_for_new_game($names)
51 {
52   $copy_names = $names; /* local copy, so that we can delete names from it
53                          * after we selected them to make sure that each name
54                          * only shows up once
55                          */
56   echo '  <form action="index.php?action=new" method="post">';
57   echo '    <h2> '._('Select players (Remember: you need to be one of the players)').' </h2>';
58   echo '   <div class="table">';
59   echo '     <img class="table" src="pics/table.png" alt="table" />';
60
61   /* ask player for names */
62
63   $i=0;
64
65   /* delete players name, since he will be on position D anyway */
66   unset($copy_names[array_search($_SESSION["name"],$copy_names)]);
67
68   srand((float) microtime() * 10000000);
69   foreach( array("PlayerA","PlayerB","PlayerC","PlayerD") as $player)
70     {
71       /* pick 3 names at random and put the players name on position D*/
72       if($i<3)
73         {
74           $randkey = array_rand($copy_names);
75           $rand = $copy_names[$randkey];
76           /* delete this name from the list of possible names */
77           unset($copy_names[$randkey]);
78         }
79       else
80         {
81           $rand = $_SESSION["name"];
82         }
83
84       echo  "     <div class=\"table".$i."\">\n";
85       $i++;
86       echo "       <select name=\"$player\" size=\"1\">  \n";
87       foreach($names as $name)
88         {
89           if($name==$rand)
90             {
91               echo "         <option selected=\"selected\">$name</option>\n";
92             }
93           else
94             echo "         <option>$name</option>\n";
95         }
96       echo "       </select>\n     </div>\n";
97     }
98
99     echo '    </div>';
100     echo '';
101     echo '     <h2 class="rules">'._('Rules').'</h2>';
102     echo '     <h3>'._('Gameplay-related').'</h3>';
103     echo '     <h4>'._('Ten of hearts').':</h4>';
104     echo '     <p>';
105     echo '       <select name="dullen">';
106     echo '         <option value="none"> '._('just normal non-trump').'  </option>';
107     echo '         <option value="firstwins"> '._('first ten of hearts wins the trick').' </option>';
108     echo '         <option value="secondwins" selected="selected"> '.('second ten of hearts wins the trick').' </option>';
109     echo '       </select>';
110     echo '     </p>';
111     echo '     <h4>'._('Schweinchen (both foxes), only in normal games or silent solos').':</h4>';
112     echo '     <p>';
113     echo '       <select name="schweinchen">';
114     echo '         <option value="none" selected="selected"> '._('none').' </option>';
115     echo '       <option value="both"> '._('both become highest trump (automatic call at beginning of the game)').'   </option>';
116     echo '       <option value="second"> '._('first one normal, second one becomes highest (call during the game)').' </option>';
117     echo '       <option value="secondaftercall">  ',_('second one become highest only in case re/contra was announced');
118     echo '       </option>';
119     echo '       </select>';
120     echo '     </p>';
121     echo '     <h4>'._('Call Re/Contra, etc.').':</h4>';
122     echo '     <p>';
123     echo '       <select name="callrule">';
124     echo '       <option value="1st-own-card" selected="selected">  '._('Can call re/contra on the first <strong>own</strong> card played, 90 on the second, etc.').'</option>';
125     echo '       <option value="5th-card"> '._('Can call re/contra until 5th card is played, 90 until 9th card is played, etc.').'</option>';
126     echo '       <option value="9-cards" > '._('Can call re/contra until 5th card is played, 90 if player still has 9 cards, etc.').'</option>';
127     echo '       </select>';
128     echo '     </p>';
129     echo '     <h4>'._('Low trump').'</h4>';
130     echo '     <p>';
131     echo '       '._('Player can\'t trump a fox, that is none of his trump is higher than a fox.');
132     echo '       <select name="lowtrump">';
133     echo '       <option value="poverty">'._('The trump will be treated as poverty and offered to another player.').'</option>';
134     echo '       <option value="cancel"> '._('The game will be canceled unless there is a solo.').'</option>';
135     echo '       <option value="none">   '._('Bad luck, the player needs to play a normal game.').'</option>';
136     echo '       </select>';
137     echo '     </p>';
138     echo '     <h3>'._('Scoring-related').'</h3>';
139     echo '     <h4>'._('(not yet implemented)').'</h4>';
140     echo '     <p><input type="submit" value="'._('start game').'"></p>';
141     echo '     </form>';
142
143 }
144
145 function output_table($data,$caption="",$class="",$id="")
146 {
147
148   $HTML  = "\n<table";
149
150   if($class!="")
151     $HTML.= " class=\"$class\"";
152   if($id!="")
153     $HTML.= " id=\"$id\"";
154
155   $HTML.=">\n";
156
157   $i=0;
158
159   if($caption!="")
160     $HTML .= "  <caption> $caption </caption>\n";
161
162   foreach($data as $record)
163     {
164       if(!$i)
165         $HTML .= "  <thead>\n  <tr>\n";
166       else
167         {
168           if($i==1) $HTML .= "  <tbody>\n";
169           $HTML .= "  <tr>  ";
170         }
171       foreach($record as $point)
172         {
173           if($i)
174             $HTML .= "    <td>$point</td> ";
175           else
176             $HTML .= "    <th>$point</th> ";
177         }
178
179       if(!$i)
180         $HTML .= "  </tr>\n  </thead>\n";
181       else
182         {
183           $HTML .= "  </tr>\n";
184         }
185       $i++;
186     }
187   $HTML .= "  </tbody>\n</table>\n";
188
189   return $HTML;
190 }
191
192 function display_card($card,$dir="english")
193 {
194   /* cards are only availabl for the odd values, e.g. 1.png, 3.png, ...
195    * convert even cards to the matching odd value */
196
197   if( $card/2 - (int)($card/2) == 0.5 || $card == 0)
198     echo "<img src=\"cards/".$dir."/".$card.".png\"  alt=\"".DB_get_card_name($card)."\" />\n";
199   else
200     echo "<img src=\"cards/".$dir."/".($card-1).".png\"  alt=\"".DB_get_card_name($card-1)."\" />\n";
201
202   return;
203 }
204
205 function display_link_card($card,$dir="english",$type="card")
206 {
207   if( $card/2 - (int)($card/2) == 0.5)
208     echo "<div class=\"cardinput\"><input type=\"radio\" name=\"".$type."\" value=\"".$card."\" /><img src=\"cards/".$dir."/".$card.".png\" alt=\"".DB_get_card_name($card)."\" /></div>\n";
209   else
210     echo "<div class=\"cardinput\" ><input type=\"radio\" name=\"".$type."\" value=\"".$card."\" /><img src=\"cards/".$dir."/".($card-1).".png\" alt=\"".DB_get_card_name($card-1)."\" /></div>\n";
211   return;
212 }
213
214 function output_check_for_sickness($me,$mycards)
215 {
216   global $RULES;
217
218   echo '  <div class="sickness"> '._('Thanks for joining the game').'...<br />';
219   echo '';
220   echo '    '._('Do you want to play solo?').'';
221   echo '    <select name="solo" size="1">';
222   echo '      <option selected="selected">'.'No'.'</option>';
223   echo '      <option>'.'trumpless'.'</option>';
224   echo '      <option>'.'trump'.'</option>';
225   echo '      <option>'.'queen'.'</option>';
226   echo '      <option>'.'jack'.'</option>';
227   echo '      <option>'.'club'.'</option>';
228   echo '      <option>'.'spade'.'</option>';
229   echo '      <option>'.'heart'.'</option>';
230   echo '    </select>';
231   echo '    <br />';
232
233   echo _('Wedding?');
234   if(check_wedding($mycards))
235      {
236        echo ' '._('yes')."<input type=\"radio\" name=\"wedding\" value=\"yes\" checked=\"checked\" />";
237        echo ' '._('no')." <input type=\"radio\" name=\"wedding\" value=\"no\" /> <br />\n";
238      }
239    else
240      {
241        echo ' '._('no')." <input type=\"hidden\" name=\"wedding\" value=\"no\" /> <br />\n";
242      };
243
244   echo _('Do you have poverty?');
245   if(count_trump($mycards)<4)
246     {
247       echo ' '._('yes')."<input type=\"radio\" name=\"poverty\" value=\"yes\" checked=\"checked\" />";
248       echo ' '._('no')." <input type=\"radio\" name=\"poverty\" value=\"no\" /> <br />\n";
249     }
250   else
251     {
252       echo ' '._('no')." <input type=\"hidden\" name=\"poverty\" value=\"no\" /> <br />\n";
253     };
254
255   echo _('Do you have too many nines?');
256   if(count_nines($mycards)>4)
257      {
258        echo ' '._('yes')."<input type=\"radio\" name=\"nines\" value=\"yes\" checked=\"checked\" />";
259        echo ' '._('no')." <input type=\"radio\" name=\"nines\" value=\"no\" /> <br />\n";
260      }
261    else
262      {
263        echo ' '._('no')." <input type=\"hidden\" name=\"nines\" value=\"no\" /> <br />\n";
264      };
265
266   if($RULES['lowtrump']=='cancel' || $RULES['lowtrump']=='poverty')
267     {
268       if($RULES['lowtrump']=='cancel')
269         echo _('Do you have low trump (cancel game)?');
270       else
271         echo _('Do you have low trump (poverty)?');
272
273       if(check_low_trump($mycards))
274         {
275           echo ' '._('yes')."<input type=\"radio\" name=\"lowtrump\" value=\"yes\" checked=\"checked\" />";
276           echo ' '._('no')." <input type=\"radio\" name=\"lowtrump\" value=\"no\" /> <br />\n";
277         }
278       else
279         {
280           echo ' '._('no')." <input type=\"hidden\" name=\"lowtrump\" value=\"no\" /> <br />\n";
281         };
282     }
283   else
284     echo "<input type=\"hidden\" name=\"lowtrump\" value=\"no\" />";
285
286    echo "<input type=\"hidden\" name=\"me\" value=\"$me\" />\n";
287    echo "<input type=\"submit\" value=\""._('count me in')."\" />\n";
288
289    echo "</div>\n";
290
291   return;
292 }
293
294 function output_form_calls($me,$myparty)
295 {
296   $highstart = '  <span class="highcall">';
297   $highend   = '</span>';
298
299   $tmp = can_call(120,$me);
300   if( $tmp )
301     {
302       if($tmp==2) echo $highstart;
303       if($myparty=='re')
304         echo '  re (120):';
305       else if ($myparty=='contra')
306         echo '  contra (120):';
307       else
308         echo '  re/contra (120):';
309       echo ' <input type="radio" name="call" value="120" />';
310       if($tmp==2) echo $highend;
311       echo "\n";
312     }
313   $tmp = can_call(90,$me);
314   if( $tmp )
315     {
316       if($tmp==2) echo $highstart;
317       echo '  90:'.
318         ' <input type="radio" name="call" value="90" />';
319       if($tmp==2) echo $highend;
320       echo "\n";
321     }
322   $tmp = can_call(60,$me);
323   if( $tmp )
324     {
325       if($tmp==2) echo $highstart;
326       echo '  60:'.
327         ' <input type="radio" name="call" value="60" />';
328       if($tmp==2) echo $highend;
329       echo "\n";
330     }
331   $tmp = can_call(30,$me);
332   if( $tmp )
333     {
334       if($tmp==2) echo $highstart;
335       echo '  30:'.
336         ' <input type="radio" name="call" value="30" />';
337       if($tmp==2) echo $highend;
338       echo "\n";
339     }
340   $tmp = can_call(0,$me);
341   if( $tmp )
342     {
343       if($tmp==2) echo $highstart;
344       echo '  0:'.
345         ' <input type="radio" name="call" value="0" />';
346       if($tmp==2) echo $highend;
347       echo "\n".
348         '  no call:'.
349         ' <input type="radio" name="call" value="no" />'."\n";
350     }
351 }
352
353 function output_check_want_to_play($me)
354 {
355   echo ' <div class="joingame">';
356   echo '   '._('Do you want to play a game of DoKo?').' <br />';
357   echo '   '._('yes').'<input type="radio" name="in" value="yes" />';
358   echo '   '._('no').'<input type="radio" name="in" value="no" /> <br />';
359   echo "<input type=\"hidden\" name=\"me\" value=\"$me\" />\n";
360   echo "\n";
361   echo "<input type=\"submit\" value=\""._('submit')."\" />\n";
362   echo " </div>\n";
363
364   return;
365 }
366
367 function output_header()
368 {
369    global $REV;
370 ?>
371 <!DOCTYPE html PUBLIC
372     "-//W3C//DTD XHTML 1.1 plus MathML 2.0 plus SVG 1.1//EN"
373     "http://www.w3.org/2002/04/xhtml-math-svg/xhtml-math-svg.dtd">
374 <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
375   <head>
376      <title>e-Doko</title>
377      <meta content="text/html; charset=ISO-8859-1" http-equiv="content-type" />
378      <link rel="shortcut icon" type="image/x-icon" href="pics/edoko-favicon.png" />
379      <link rel="stylesheet" type="text/css" href="css/standard025.css" />
380      <script type="text/javascript" src="include/game.js"> </script>
381      <script type="text/javascript" src="include/jquery.js"> </script>
382      <script type="text/javascript" src="include/jquery.tablesorter.js"></script>
383      <script type="text/javascript">
384         $(document).ready(function()
385            {
386               $("#ScoreTable").tablesorter({ widgets: ['zebra']});
387
388               $(".gameshidesession").click( function () {
389                   $(this).parent().children(".gamessession").toggle(300);
390                 });
391
392               $(".gameshowall").click( function () {
393                   $(".gamessession").show(300);
394                 });
395               $(".gamehideall").click( function () {
396                   $(".gamessession").hide(300);
397                 });
398
399
400            });
401      </script>
402   </head>
403 <body onload="high_last();">
404 <div class="header">
405 <?php
406   echo '<h1> '._('Welcome to E-Doko').' </h1>';
407 ?>
408 </div>
409 <?php
410
411   echo "<div class=\"main\">";
412   return;
413 }
414
415 function output_footer()
416 {
417   global $REV,$PREF;
418
419   echo "</div>\n\n";
420   echo "<div class=\"footer\">\n";
421   echo "  <p class=\"left\"> copyright 2006,2007,2008,2009,2010 Arun Persaud, <a href=\"$INDEX?action=about\">et al.</a> <br />\n".
422     "  Verwendung der [deutschen] Kartenbilder mit Genehmigung <br />der Spielkartenfabrik Altenburg GmbH,(c) ASS Altenburger <br />\n".
423     "  - ASS Altenburger Spielkarten - Spielkartenfabrik Altenburg GmbH <br />\n".
424     "  a Carta Mundi Company Email: info@spielkarten.com Internet: www.spielkarten.com</p>\n";
425  echo " <p class=\"right\"> See the latest changes <a href=\"http://nubati.net/cgi-bin/gitweb.cgi?p=e-DoKo.git;a=summary\">\n".
426     "  via git </a> <br />or download the source via <br />\n'git clone http://nubati.net/git/e-DoKo.git' <br />\n".
427     "  <a href=\"http://www.dreamhost.com/green.cgi\">\n".
428     "  <img  border=\"0\" alt=\"Green Web Hosting! This site hosted by DreamHost.\"".
429     "src=\"https://secure.newdream.net/green1.gif\" height=\"32\" width=\"100\" /></a>\n".
430     "  </p> \n";
431   echo "\n";
432   echo "</div>\n";
433
434   echo "</body>\n";
435   echo "</html>\n";
436
437   return;
438 }
439
440 function output_status()
441 {
442   global $defaulttimezone, $INDEX, $WIKI, $RSS;
443
444   if(isset($_SESSION['name']))
445     {
446       $name = $_SESSION['name'];
447
448       /* last logon time */
449       $myid  = DB_get_userid('name',$name);
450       $zone  = DB_get_user_timezone($myid);
451
452       $time     = DB_get_user_timestamp($myid);
453       date_default_timezone_set($defaulttimezone);
454       $unixtime = strtotime($time);
455       date_default_timezone_set($zone);
456
457       /* rss token */
458       $token = get_user_token($myid);
459
460       /* logout info */
461       echo "\n<div class=\"status\">\n";
462       echo $name,"\n";
463       echo " | <a href=\"".$INDEX."\">"._('mypage')."</a>\n";
464       echo " | <a href=\"".$INDEX."?action=prefs\">"._('settings')."</a>\n";
465       echo " | <a href=\"".$INDEX."?action=new\">"._('new game')."</a>\n";
466       echo " | <a href=\"".$INDEX."?action=stats\">"._('statistics')."</a>\n";
467       echo " | <a href=\"".$WIKI."\">"._('wiki/bugs')."</a>\n";
468       echo " | <a href=\"".$RSS."?uid=".$myid."&amp;token=".$token."\">"._('atom')."</a>\n";
469       echo " |&nbsp;&nbsp;&nbsp; <a href=\"".$INDEX."?action=logout\">"._('logout')."</a>\n";
470       echo "</div>\n";
471
472       echo "<div class=\"lastlogin\"><span>"._('last login').": ".date("r",$unixtime)."</span></div>\n";
473     }
474   else
475     {
476       echo "\n<div class=\"status\">\n";
477       echo "<a href=\"".$INDEX."\">"._('login')."</a>\n";
478       echo "</div>\n";
479     }
480   return;
481 }
482
483 function output_select_timezone($name,$timezone="")
484 {
485   $Tzone = array ("Pacific/Apia"         => "Apia",                /*UTC-11*/
486                   "Pacific/Honolulu"     => "Honolulu",            /*UTC-10*/
487                   "America/Anchorage"    => "Anchorage",           /*UTC-9*/
488                   "America/Vancouver"    => "Berkeley",            /*UTC-8*/
489                   "America/Phoenix"      => "Phoenix",             /*UTC-7*/
490                   "America/Chicago"      => "Chicago",             /*UTC-6*/
491                   "America/New_York"     => "New York",            /*UTC-5*/
492                   "America/Santiago"     => "Santiago",            /*UTC-4*/
493                   "America/Buenos_Aires" => "Buenos Aires",        /*UTC-3*/
494                   "Atlantic/South_Georgia" => "Fernando de Noronha", /*UTC-2*/
495                   "Atlantic/Azores"       => "Azores",             /*UTC-1"*/
496                   "Europe/London"         => "London",             /*UTC*/
497                   "Europe/Berlin"         => "Berlin",             /*UTC+1*/
498                   "Africa/Cairo"          => "Cairo",              /*UTC+2*/
499                   "Europe/Moscow"         => "Moscow",             /*UTC+3*/
500                   "Asia/Tehran"           => "Tehran",             /*UTC+3:30*/
501                   "Asia/Dubai"            => "Dubai",              /*UTC+4*/
502                   "Asia/Karachi"          => "Karachi",            /*UTC+5*/
503                   "Asia/Calcutta"         => "Delhi",              /*UTC+5:30*/
504                   "Asia/Kathmandu"        => "Kathmandu",          /*UTC+5:45*/
505                   "Asia/Dhaka"            => "Dhaka",              /*UTC+6*/
506                   "Asia/Rangoon"          => "Yangon",             /*UTC+6:30*/
507                   "Asia/Bangkok"          => "Bangkok",            /*UTC+7*/
508                   "Asia/Hong_Kong"        => "Beijing",            /*UTC+8*/
509                   "Asia/Tokyo"            => "Tokyo",              /*UTC+9*/
510                   "Australia/Darwin"      => "Darwin",             /*UTC+9:30*/
511                   "Australia/Sydney"      => "Sydney",             /*UTC+10*/
512                   "Asia/Magadan"          => "Magadan",            /*UTC+11*/
513                   "Pacific/Auckland"      => "Wellington" );       /*UTC+12*/
514
515   echo "  <select id=\"$name\" name=\"$name\" size=\"1\">\n";
516
517   foreach($Tzone as $zone=>$city)
518     {
519       if($timezone==$zone)
520         echo "   <option value=\"$zone\" selected=\"selected\">$city</option>\n";
521       else
522         echo "   <option value=\"$zone\">$city</option>\n";
523     }
524   echo "  </select>\n";
525
526   return;
527 }
528
529 function output_select_language($name,$language="")
530 {
531   $LOCALE = array ("English"     => "en",
532                    "Deutsch"     => "de" );
533
534   echo "  <select id=\"$name\" name=\"$name\" size=\"1\">\n";
535
536   foreach($LOCALE as $place=>$locale)
537     {
538       if($language==$locale)
539         echo "   <option value=\"$locale\" selected=\"selected\">$place</option>\n";
540       else
541         echo "   <option value=\"$locale\">$place</option>\n";
542     }
543   echo "  </select>\n";
544
545   return;
546 }
547
548
549 function output_password_recovery($email,$password)
550 {
551 ?>
552    <form action="index.php" method="post">
553 <?php
554   echo "  <input type=\"hidden\" name=\"email\" value=\"".$email."\" />\n";
555   echo "  <input type=\"hidden\" name=\"password\" value=\"".$password."\" />\n";
556   echo "  <input type=\"hidden\" name=\"passwd\"  value=\"set\" />\n";
557 ?>
558      <fieldset>
559        <legend>Password recovery</legend>
560         <table>
561          <tr>
562             <td><label for="email">Old password:</label></td>
563             <td><input type="password" id="password0" name="password0" size="20" maxlength="30" /> </td>
564          </tr><tr>
565             <td><label for="password">New password:</label></td>
566             <td><input type="password" id="password1" name="password1" size="20" maxlength="30" /></td>
567          </tr><tr>
568             <td><label for="password">Retype:</label></td>
569             <td><input type="password" id="password2" name="password2" size="20" maxlength="30" /></td>
570          </tr><tr>
571            <td></td>
572            <td> <input type="submit" class="submitbutton" name="passwd" value="set" /></td>
573          </tr>
574         </table>
575      </fieldset>
576    </form>
577
578 <?php
579 }
580
581 function output_user_notes($userid,$gameid,$userstatus)
582 {
583   echo "<div class=\"notes\"> "._('Personal notes').": <br />\n";
584   $notes = DB_get_notes_by_userid_and_gameid($userid,$gameid);
585   foreach($notes as $note)
586     echo "$note <hr />\n";
587   if($userstatus!='gameover')
588     echo "<input name=\"note\" type=\"text\" size=\"15\" maxlength=\"100\" />\n";
589   echo "</div> \n";
590
591   return;
592 }
593
594 function output_robotproof($i)
595 {
596   switch($i)
597     {
598     case 0:
599       return "6*7=";
600     case 1:
601       return "5*7=";
602     case 2:
603       return "4*7=";
604     case 3:
605       return "3*7=";
606     case 4:
607       return "2*7=";
608     }
609 }
610
611 function output_exchanged_cards()
612 {
613   /* in a poverty game this function will output the exchanged cards
614    * players in the team will see the cards, the other team will see
615    * the backside of cards
616    */
617
618   /* need some information about the game */
619   global $gameid,$mygametype, $PREF,$me,$mystatus, $RULES;
620
621   /* some variables to track where the people with poverty are sitting */
622   $partnerpos1 = 0;
623   $povertypos1 = 0;
624   $partnerpos2 = 0;
625   $povertypos2 = 0;
626
627   /* only need to do it in a poverty game, this might not be needed, but
628    * just to make sure everything is ok
629    */
630   if($mygametype == 'poverty' || $mygametype=='dpoverty')
631     {
632       /* find out who has poverty */
633       for($mypos=1;$mypos<5;$mypos++)
634         {
635           $usersick = DB_get_sickness_by_pos_and_gameid($mypos,$gameid);
636           if($usersick == 'poverty' || ($RULES['lowtrump']=='poverty' && $usersick=='lowtrump'))
637             if($povertypos1)
638               $povertypos2 = $mypos;
639             else
640               $povertypos1 = $mypos;
641         }
642       /* get hash and exchanged cards for all involved */
643       $povertyhash1 = DB_get_hash_from_game_and_pos($gameid,$povertypos1);
644       $partnerhash1 = DB_get_partner_hash_by_hash($povertyhash1);
645
646       $povertycards1 = DB_get_exchanged_cards($povertyhash1);
647       $partnercards1 = DB_get_exchanged_cards($partnerhash1);
648
649       $partnerpos1 = DB_get_pos_by_hash($partnerhash1);
650       if($povertypos2)
651         {
652           $povertyhash2 = DB_get_hash_from_game_and_pos($gameid,$povertypos2);
653           $partnerhash2 = DB_get_partner_hash_by_hash($povertyhash2);
654
655           $povertycards2 = DB_get_exchanged_cards($povertyhash2);
656           $partnercards2 = DB_get_exchanged_cards($partnerhash2);
657
658           $partnerpos2 = DB_get_pos_by_hash($partnerhash2);
659         }
660     }
661
662   /* output the cards
663    * go through all positions, check that position has cards that need to be shown and
664    * show those cards
665    */
666   $show=1;
667   for($mypos=1;$mypos<5;$mypos++)
668     {
669       $usersick = DB_get_sickness_by_pos_and_gameid($mypos,$gameid);
670       if($usersick!=NULL ||
671          $mypos==$povertypos1 || $mypos==$partnerpos1 ||
672          $mypos==$povertypos2 || $mypos==$partnerpos2 )
673         {
674           /* figure out if we gave trump back */
675           $trump_back1=0;
676           if($povertypos2)
677             foreach($povertycards1 as $card)
678               {
679                 if(is_trump($card))
680                   {
681                     $trump_back1=1;
682                     break;
683                   }
684               }
685           $trump_back2=0;
686           if($povertypos2)
687             foreach($povertycards2 as $card)
688               {
689                 if(is_trump($card))
690                   {
691                     $trump_back2=1;
692                     break;
693                   }
694               }
695
696           /* output vorbehalt  */
697           echo "      <div class=\"vorbehalt".($mypos-1)."\"> Vorbehalt <br />\n";
698           if($show)
699             echo "       $usersick <br />\n";
700
701           /* output cards */
702           if($mypos==$partnerpos1)
703             {
704               foreach($partnercards1 as $card)
705                 {
706                   echo '        ';
707                   if($povertyhash1 == $me || $partnerhash1 == $me || $mystatus=='gameover')
708                     display_card($card,$PREF['cardset']);
709                   else
710                     display_card(0,$PREF['cardset']);
711                 }
712               if($trump_back1) echo '        '._('Trump back');
713             }
714           else if($mypos==$povertypos1)
715             {
716               foreach($povertycards1 as $card)
717                 {
718                   echo '        ';
719                   if($povertyhash1 == $me || $partnerhash1 == $me || $mystatus=='gameover')
720                     display_card($card,$PREF['cardset']);
721                   else
722                     display_card(0,$PREF['cardset']);
723               }
724               if($trump_back1) echo '        '._('Trump back');
725             }
726           else if($mypos==$povertypos2)
727             {
728               foreach($povertycards2 as $card)
729                 {
730                   echo '        ';
731                   if($povertyhash2 == $me || $partnerhash2 == $me || $mystatus=='gameover')
732                     display_card($card,$PREF['cardset']);
733                   else
734                     display_card(0,$PREF['cardset']);
735                 }
736               if($trump_back2) echo '        '._('Trump back');
737             }
738           else if($mypos==$partnerpos2)
739             {
740               foreach($partnercards2 as $card)
741                 {
742                   if(is_trump($card)) $trump_back=1;
743                   echo '        ';
744                   if($povertyhash2 == $me || $partnerhash2 == $me || $mystatus=='gameover')
745                     display_card($card,$PREF['cardset']);
746                   else
747                     display_card(0,$PREF['cardset']);
748                 }
749               if($trump_back2) echo '        '._('Trump back');
750             }
751           echo  "      </div>\n";
752         }
753       if($mygametype == $usersick)
754         $show = 0;
755     }
756 }
757
758
759 ?>