- /* check if we are being asked now
- * no? display wait message, e.g. player X is asked at the moment
- */
- $usersick = DB_get_sickness_by_userid_and_gameid($myid,$gameid);
- if(myisset("trump") && $_REQUEST["trump"]=="no" && ($who==$mypos || $who==$mypos*10))
+ /* the following is part B) of whats needs to be done)
+ /* check if user wants to give cards back */
+ if(myisset("exchange"))
+ {
+ $exchange = $_REQUEST['exchange'];
+ $partnerhash = DB_get_partner_hash_by_hash($me);
+ $partnerid = DB_get_userid('hash',$partnerhash);
+ $partnerhand = DB_get_handid('gameid-userid',$gameid,$partnerid);
+
+ /* if exchange is set to a value>0, exchange that card back to the partner */
+ if($exchange >0)
+ {
+ $result = DB_query("UPDATE Hand_Card SET hand_id='$partnerhand'".
+ " WHERE hand_id='$myhand' AND card_id=".DB_quote_smart($exchange));
+ };
+ }
+ /* update hand */
+ $mycards = DB_get_hand($me);
+ $mycards = mysort($mycards,$gametype);
+
+ /* check if user need to give more cards back */
+ if( ($myparty=='re' || $myparty=='contra') && count($mycards)>12)
+ {
+ echo "<div class=\"poverty\"> you need to get rid of a few cards</div>\n";
+
+ $type="exchange";
+ echo "<div class=\"mycards\">Your cards are: <br />\n";
+ foreach($mycards as $card)
+ display_link_card($card,$PREF["cardset"],$type);
+ echo " <input type=\"submit\" class=\"submitbutton\" value=\"select card to give back\" />\n";
+ echo "</div>\n";
+ }
+ else if( ($myparty=='re' || $myparty=='contra') && count($mycards)==12)
+ {
+ /* user is done, ready to play */
+ DB_set_hand_status_by_hash($me,'play');
+ /* TODO if resolved; email start player, set startplayer */
+ }
+
+ /* the following is part A) of what needs to be done */
+ if(!myisset("trump"))
+ {
+ if(!$myparty)
+ {
+ echo "<div class=\"poverty\">\n";
+ $userids = DB_get_all_userid_by_gameid($gameid);
+ foreach($userids as $user)