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