+ if($hash!=$me)
+ {
+ if(DB_get_email_pref_by_hash($hash)!='emailaddict')
+ {
+ /* email startplayer */
+ $message = "It's your turn now in game ".DB_format_gameid($gameid).".\n".
+ "Use this link to play a card: ".$HOST.$INDEX."?action=game&me=".$hash."\n\n" ;
+ $subject = 'Ready, set, go... (game '.DB_format_gameid($gameid).')';
+ mymail($who,$subject,$message);
+ }
+ }
+ else
+ echo "Please, <a href=\"$INDEX?action=game&me=$me\">start</a> the game.<br />\n";
+ }
+ else
+ {
+ /* set status of first player to be asked to poverty */
+ $who = DB_get_sickness_by_gameid($gameid);
+ if($who > 6) $who= $who/10; /* in case we have dpoverty */
+
+ $whoid = DB_get_userid('gameid-position',$gameid,$who);
+ if($whoid==$myid)
+ echo "Please, <a href=\"$INDEX?action=game&me=$me\">start</a> the game.<br /\n";
+ else
+ {
+ $whohash = DB_get_hash_from_game_and_pos($gameid,$who);
+ DB_set_player_by_gameid($gameid,$whoid);
+
+ if(DB_get_email_pref_by_hash($hash)!='emailaddict')
+ {
+ /* email player for poverty */
+ $message = "Poverty: It's your turn now in game ".DB_format_gameid($gameid).".\n".
+ "Use this link to play a card: ".$HOST.$INDEX."?action=game&me=".$whohash."\n\n" ;
+ $subject = 'Poverty (game '.DB_format_gameid($gameid).') ';
+ mymail($whoid,$subject,$message);
+ }
+ }
+ }
+ echo "</div>\n";
+ break;
+ }
+
+ case 'poverty':
+ /* user only gets here in a poverty game, several things have to be handled here:
+ * A) ask, if user wants to take trump
+ * yes-> take trump,
+ * poverty: set re/contra
+ * dpoverty: first time: set re, send email to second player
+ * second time: set contra
+ * poverty: set status of other players to 'play'
+ * set status to play in case 0 trump
+ * no -> set status to play,
+ * ask next player or cancle the game if no more players
+ * B) user took trump and has too many cards (e.g. count(cards)>12 and re/contra set)
+ * ask to give cards back, set status to play, once player has 12 cards
+ *
+ * it is easier to check B) first
+ */
+
+ set_gametype($gametype); /* this sets the $CARDS variable */
+ $myparty = DB_get_party_by_hash($me);
+
+ /* 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));
+ DB_add_exchanged_card(DB_quote_smart($exchange),$myhand,$partnerhand);