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