+ /* now check which sickness comes first and set the gametype to it */
+
+ /* if gamestatus == normal, set poverty or dpovert (in case two people have poverty) */
+ if($poverty>0 && $gametype == "normal")
+ {
+ if($poverty==1)
+ {
+ DB_set_gametype_by_gameid($gameid,"poverty");
+ $gametype = "poverty";
+ }
+ else if($poverty==2)
+ {
+ DB_set_gametype_by_gameid($gameid,"dpoverty");
+ $gametype = "dpoverty";
+ };
+ };
+ /* if gamestatus == normal, set wedding */
+ if($wedding> 0 && $gametype == "normal")
+ {
+ DB_set_gametype_by_gameid($gameid,"wedding");
+ $gametype = "wedding";
+ };
+
+ /* now the gametype is set correctly (shouldn't matter that this is calculated for every user)
+ * output what kind of game we have */
+
+ echo "<br />\n";
+
+ $poverty=0;
+ foreach($userids as $user)
+ {
+ $name = DB_get_name_by_userid($user);
+ $usersick = DB_get_sickness_by_userid_and_gameid($user,$gameid);
+ if($usersick=="poverty")
+ $poverty++;
+ if($usersick)
+ echo "$name has $usersick <br />";
+ if($usersick == "wedding" && $gametype =="wedding")
+ break;
+ if($usersick == "poverty" && $gametype =="poverty")
+ break;
+ if($usersick == "poverty" && $gametype =="dpoverty" && $poverty==2)
+ break;
+ if($usersick == "solo" && $gametype =="solo")
+ break;
+ };
+ echo "<br />\n";
+
+ /* check for Schweinchen (cards 21,22) */
+ if($RULES["schweinchen"]=="both")
+ {
+ set_gametype($gametype);
+ echo "TODO: check if one user has both foxes and output here ";
+ }
+
+ /* finished the setup, go to next stage unless there is a case of poverty*/
+ switch($gametype)
+ {
+ case "solo":
+ /* are we the solo player? set us to re, else set us to contra */
+ $pos = DB_get_pos_by_hash($me);
+ if($pos == $startplayer)
+ DB_set_party_by_hash($me,"re");
+ else
+ DB_set_party_by_hash($me,"contra");
+ DB_set_hand_status_by_hash($me,'play');
+ break;
+ case "wedding":
+ echo "Don't know who will be Re and Contra, you need to figure that out at the end of the game yourself <br />\n";
+ DB_set_hand_status_by_hash($me,'play');
+ break;
+ case "normal":
+ $hand = DB_get_all_hand($me);
+
+ if(in_array('3',$hand)||in_array('4',$hand))
+ DB_set_party_by_hash($me,"re");
+ else
+ DB_set_party_by_hash($me,"contra");
+ DB_set_hand_status_by_hash($me,'play');
+ break;
+ case "poverty":
+ case "dpoverty":
+ echo "TODO: handle poverty here";
+ DB_set_hand_status_by_hash($me,'play');
+ };