<?php
+/* Copyright 2006, 2007, 2008, 2009, 2010 Arun Persaud <arun@nubati.net>
+ *
+ * This file is part of e-DoKo.
+ *
+ * e-DoKo is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * e-DoKo is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with e-DoKo. If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
+
error_reporting(E_ALL);
-include_once("config.php");
-include_once("output.php"); /* html output only */
-include_once("db.php"); /* database only */
-include_once("functions.php"); /* the rest */
+/* start a session, if it is not already running.
+ * This way people don't have to log in all the times.
+ * The session variables can also be read out from different
+ * php scripts, so that the code can be easily split up across several files
+ */
+session_start();
-/* check if some variables are set in the config file, else set defaults */
-if(!isset($EmailName))
- $EmailName="[DoKo] ";
-if(isset($EMAIL_REPLY))
- {
- ini_set("sendmail_from",$EMAIL_REPLY);
- }
-if(!isset($ADMIN_NAME))
- {
- output_header();
- echo "<h1>Setup not completed</h1>";
- echo "You need to set \$ADMIN_NAME in config.php.";
- output_footer();
- exit();
- }
-if(!isset($ADMIN_EMAIL))
- {
- output_header();
- echo "<h1>Setup not completed</h1>";
- echo "You need to set \$ADMIN_EMAIL in config.php. ".
- "If something goes wrong an email will send to this address.";
- output_footer();
- exit();
- }
+include_once("config.php"); /* needs to be first in list, since other includes use this */
+include_once("./include/output.php"); /* html output only */
+include_once("./include/db.php"); /* database only */
+include_once("./include/functions.php"); /* the rest */
-/* in case work has to be done on the database or other section we can
- * shut down the server and tell people to come back later
- */
-if(0)
- {
- output_header();
- echo "Working on the database...please check back in a few mintues";
- output_footer();
- exit();
- }
+/* make sure that user has set all variables in config.php */
+config_check();
-if(DB_open()<0)
+/* open the database */
+$DBopen = DB_open();
+if($DBopen<0)
{
output_header();
- echo "Database error, can't connect... Please wait a while and try again. ".
- "If the problem doesn't go away feel free to contact $ADMIN_NAME at $ADMIN_EMAIL.";
- output_footer();
- exit();
- }
-/* done major error checking, output header of HTML page */
-output_header();
+ if($DBopen == -1)
+ echo "Database error, can't connect... Please wait a while and try again. ".
+ "If the problem doesn't go away feel free to contact $ADMIN_NAME at $ADMIN_EMAIL.";
+ else if ($DBopen == -2)
+ echo "Wrong database version, please update your database using the update.php script.";
-/* check if we want to start a new game */
-if(myisset("new"))
- {
- $names = DB_get_all_names();
- output_form_for_new_game($names);
+ output_footer();
+ exit();
}
-/*check if everything is ready to set up a new game */
- else if( myisset("PlayerA", "PlayerB","PlayerC","PlayerD","dullen","schweinchen","call" ))
- {
- $PlayerA = $_REQUEST["PlayerA"];
- $PlayerB = $_REQUEST["PlayerB"];
- $PlayerC = $_REQUEST["PlayerC"];
- $PlayerD = $_REQUEST["PlayerD"];
-
- $dullen = $_REQUEST["dullen"];
- $schweinchen = $_REQUEST["schweinchen"];
- $call = $_REQUEST["call"];
- $EmailA = DB_get_email_by_name($PlayerA);
- $EmailB = DB_get_email_by_name($PlayerB);
- $EmailC = DB_get_email_by_name($PlayerC);
- $EmailD = DB_get_email_by_name($PlayerD);
-
- if($EmailA=="" || $EmailB=="" || $EmailC=="" || $EmailD=="")
- {
- echo "couldn't find one of the names, please start a new game";
- output_footer();
- DB_close();
- exit();
- }
-
- $useridA = DB_get_userid_by_name($PlayerA);
- $useridB = DB_get_userid_by_name($PlayerB);
- $useridC = DB_get_userid_by_name($PlayerC);
- $useridD = DB_get_userid_by_name($PlayerD);
-
- /* create random numbers */
- $randomNR = create_array_of_random_numbers($useridA,$useridB,$useridC,$useridD);
- $randomNRstring = join(":",$randomNR);
-
- /* create game */
- $followup = NULL;
- if(myisset("followup") )
- {
- $followup= $_REQUEST["followup"];
- $session = DB_get_session_by_gameid($followup);
- $ruleset = DB_get_ruleset_by_gameid($followup); /* just copy ruleset from old game,
- this way no manipulation is possible */
- if($session)
- mysql_query("INSERT INTO Game VALUES (NULL, NULL, '$randomNRstring', 'normal', NULL,NULL,'1',NULL,'pre',".
- "'$ruleset','$session' ,NULL)");
- else
- {
- /* get max session */
- $max = DB_get_max_session();
- $max++;
- mysql_query("UPDATE Game SET session='".$max."' WHERE id=".DB_quote_smart($followup));
- mysql_query("INSERT INTO Game VALUES (NULL, NULL, '$randomNRstring', 'normal', NULL,NULL,'1',NULL,'pre',".
- "'$ruleset','$max' ,NULL)");
- }
- }
- else
- {
- /* get ruleset information or create new one */
- $ruleset = DB_get_ruleset($dullen,$schweinchen,$call);
- if($ruleset <0)
- {
- myerror("Error defining ruleset: $ruleset");
- output_footer();
- DB_close();
- exit();
- };
-
- mysql_query("INSERT INTO Game VALUES (NULL, NULL, '$randomNRstring', 'normal', NULL,NULL,'1',NULL,'pre', ".
- "'$ruleset',NULL ,NULL)");
- }
- $game_id = mysql_insert_id();
-
- /* create hash */
- $TIME = (string) time(); /* to avoid collisions */
- $hashA = md5("AGameOfDoko".$game_id.$PlayerA.$EmailA.$TIME);
- $hashB = md5("AGameOfDoko".$game_id.$PlayerB.$EmailB.$TIME);
- $hashC = md5("AGameOfDoko".$game_id.$PlayerC.$EmailC.$TIME);
- $hashD = md5("AGameOfDoko".$game_id.$PlayerD.$EmailD.$TIME);
-
- /* create hands */
- mysql_query("INSERT INTO Hand VALUES (NULL,".DB_quote_smart($game_id).",".DB_quote_smart($useridA).
- ", ".DB_quote_smart($hashA).", 'start','1',NULL,NULL,NULL,NULL)");
- $hand_idA = mysql_insert_id();
- mysql_query("INSERT INTO Hand VALUES (NULL,".DB_quote_smart($game_id).",".DB_quote_smart($useridB).
- ", ".DB_quote_smart($hashB).", 'start','2',NULL,NULL,NULL,NULL)");
- $hand_idB = mysql_insert_id();
- mysql_query("INSERT INTO Hand VALUES (NULL,".DB_quote_smart($game_id).",".DB_quote_smart($useridC).
- ", ".DB_quote_smart($hashC).", 'start','3',NULL,NULL,NULL,NULL)");
- $hand_idC = mysql_insert_id();
- mysql_query("INSERT INTO Hand VALUES (NULL,".DB_quote_smart($game_id).",".DB_quote_smart($useridD).
- ", ".DB_quote_smart($hashD).", 'start','4',NULL,NULL,NULL,NULL)");
- $hand_idD = mysql_insert_id();
-
- /* save cards */
- for($i=0;$i<12;$i++)
- mysql_query("INSERT INTO Hand_Card VALUES (NULL, '$hand_idA', '".$randomNR[$i]."', 'false')");
- for($i=12;$i<24;$i++)
- mysql_query("INSERT INTO Hand_Card VALUES (NULL, '$hand_idB', '".$randomNR[$i]."', 'false')");
- for($i=24;$i<36;$i++)
- mysql_query("INSERT INTO Hand_Card VALUES (NULL, '$hand_idC', '".$randomNR[$i]."', 'false')");
- for($i=36;$i<48;$i++)
- mysql_query("INSERT INTO Hand_Card VALUES (NULL, '$hand_idD', '".$randomNR[$i]."', 'false')");
-
- /* send out email, TODO: check for error with email */
- $message = "\n".
- "you are invited to play a game of DoKo (that is to debug the program ;).\n".
- "Place comments and bug reports here:\n".
- "http://wiki.nubati.net/index.php?title=EmailDoko\n\n".
- "The whole round would consist of the following players:\n".
- "$PlayerA\n".
- "$PlayerB\n".
- "$PlayerC\n".
- "$PlayerD\n\n".
- "If you want to join this game, please follow this link:\n\n".
- "".$host."?me=";
-
- mymail($EmailA,"You are invited to a game of DoKo","Hello $PlayerA,\n".$message.$hashA);
- mymail($EmailB,"You are invited to a game of DoKo","Hello $PlayerB,\n".$message.$hashB);
- mymail($EmailC,"You are invited to a game of DoKo","Hello $PlayerC,\n".$message.$hashC);
- mymail($EmailD,"You are invited to a game of DoKo","Hello $PlayerD,\n".$message.$hashD);
-
- echo "You started a new game. The emails have been sent out!";
- } /* end set up a new game */
-/* cancle a game, if nothing has happend in the last N minutes */
-else if(myisset("cancle","me"))
+/* localization */
+/* needs to be in front of output_header, but we don't know the users preferences at this time,
+ * so we go by the session variable or if language is set
+ */
+if(myisset('language') || isset($_SESSION['language']))
{
- $me = $_REQUEST["me"];
-
- /* test for valid ID */
- $myid = DB_get_userid_by_hash($me);
- if(!$myid)
+ $language = 'en';
+ if(isset($_SESSION['language']))
+ $language = $_SESSION['language'];
+ if(myisset('language'))
{
- echo "Can't find you in the database, please check the url.<br />\n";
- echo "perhaps the game has been cancled, check by login in <a href=\"$host\">here</a>.";
- output_footer();
- DB_close();
- exit();
+ $language = $_REQUEST['language'];
+ $_SESSION['language'] = $language; /* overrule preferences */
}
-
- DB_update_user_timestamp($myid);
-
- /* get some information from the DB */
- $gameid = DB_get_gameid_by_hash($me);
- $myname = DB_get_name_by_hash($me);
-
- /* check if game really is old enough */
- $result = mysql_query("SELECT mod_date from Game WHERE id='$gameid' " );
- $r = mysql_fetch_array($result,MYSQL_NUM);
- if(time()-strtotime($r[0]) > 60*60*24*30) /* = 1 month */
+ switch($language)
{
- $message = "Hello, \n\n".
- "Game $gameid has been cancled since nothing happend for a while and $myname requested it.\n";
-
- $userids = DB_get_all_userid_by_gameid($gameid);
- foreach($userids as $user)
- {
- $To = DB_get_email_by_userid($user);
- mymail($To,$EmailName."game $gameid cancled (timed out)",$message);
- }
-
- /* delete everything from the dB */
- DB_cancel_game($me);
-
- echo "<p style=\"background-color:red\";>Game $gameid has been cancled.<br /><br /></p>";
+ case 'de':
+ putenv("LC_ALL=de_DE");
+ setlocale(LC_ALL, "de_DE");
+ // Specify location of translation tables
+ bindtextdomain("edoko", "./locale");
+ // Choose domain
+ textdomain("edoko");
+ break;
+ default:
+ /* do nothing */
}
- else
- echo "<p>You need to wait longer before you can cancle a game...</p>\n";
}
-/* handle request from one specific player for one game,
- * (the hash is set on a per game base) */
-else if(myisset("me"))
- {
- $me = $_REQUEST["me"];
-
- /* test for valid ID */
- $myid = DB_get_userid_by_hash($me);
- if(!$myid)
- {
- echo "Can't find you in the database, please check the url.<br />\n";
- echo "perhaps the game has been cancled, check by login in <a href=\"$host\">here</a>.";
- output_footer();
- DB_close();
- exit();
- }
-
- /* the user had done something, update the timestamp */
- DB_update_user_timestamp($myid);
-
- /* get some information from the DB */
- $gameid = DB_get_gameid_by_hash($me);
- $myname = DB_get_name_by_hash($me);
- $mystatus = DB_get_status_by_hash($me);
- $mypos = DB_get_pos_by_hash($me);
- $myhand = DB_get_handid_by_hash($me);
- $session = DB_get_session_by_gameid($gameid);
-
- /* get prefs and save them */
- DB_get_PREF($myid);
- /* end set pref */
-
-
- /* get rule set for this game */
- $result = mysql_query("SELECT * FROM Rulesets".
- " LEFT JOIN Game ON Game.ruleset=Rulesets.id ".
- " WHERE Game.id='$gameid'" );
- $r = mysql_fetch_array($result,MYSQL_NUM);
-
- $RULES["dullen"] = $r[2];
- $RULES["schweinchen"] = $r[3];
- $RULES["call"] = $r[4];
-
-
- /* get some infos about the game */
- $gametype = DB_get_gametype_by_gameid($gameid);
- $gamestatus = DB_get_game_status_by_gameid($gameid);
- $GT = $gametype;
- if($gametype=="solo")
- {
- $gametype = DB_get_solo_by_gameid($gameid);
- $GT = $gametype." ".$GT;
- }
-
- /* display rule set for this game */
- echo "<div class=\"ruleset\">\n";
-
- if($gamestatus != 'pre')
- echo " Gametype: $GT <br />\n";
-
- echo "Rules: <br />\n";
- echo "10ofhearts : ".$RULES["dullen"] ."<br />\n";
- echo "schweinchen: ".$RULES["schweinchen"] ."<br />\n";
- echo "call: ".$RULES["call"] ."<br />\n";
- echo "</div>\n";
-
- /* output extra division in case this game is part of a session */
- if($session)
- {
- echo "<div class=\"session\">\n".
- "This game is part of session $session: \n";
- $hashes = DB_get_hashes_by_session($session,$myid);
- $i = 1;
- foreach($hashes as $hash)
- {
- if($hash == $me)
- echo "$i ";
- else
- echo "<a href=\"".$host."?me=".$hash."\">$i</a> ";
- $i++;
- }
- echo "</div>\n";
- }
-
-
- /* does anyone have both foxes */
- $GAME["schweinchen"]=0;
- for($i=1;$i<5;$i++)
- {
- $hash = DB_get_hash_from_game_and_pos($gameid,$i);
- $cards = DB_get_all_hand($hash);
- if( in_array("19",$cards) && in_array("20",$cards) )
- {
- $GAME["schweinchen"]=1;
- $GAME["schweinchen-who"]=$hash;
- }
- };
-
- /* mystatus gets the player through the different stages of a game.
- * start: yes/no
- * init: check values from start,
- * check for sickness
- * check: check for return values from init
- * poverty: handle poverty, wait here until all player have reached this state
- * display sickness and move on to game
- * play: game in progress
- * gameover: are we revisiting a game
- */
- switch($mystatus)
- {
- case 'start':
- if( !myisset("in") )
- {
- output_check_want_to_play($me);
- break;
- }
- else
- {
- /* move on to the next stage*/
- DB_set_hand_status_by_hash($me,'init');
- }
- case 'init':
- /* first check if everything went ok in the last step
- * if not, send user back, if yes, check what he did
- */
- if( !myisset("in") )
- {
- echo "<p> You need to answer the <a href=\"$host?me=$me\">question</a>.</p>";
- DB_set_hand_status_by_hash($me,'start');
- }
- else
- {
- if($_REQUEST["in"] == "no")
- {
- /* cancel the game */
- $message = "Hello, \n\n".
- "the game has been canceled due to the request of one of the players.\n";
-
- $userids = DB_get_all_userid_by_gameid($gameid);
- foreach($userids as $user)
- {
- $To = DB_get_email_by_userid($user);
- mymail($To,$EmailName."game $gameid canceled",$message);
- }
-
- /* delete everything from the dB */
- DB_cancel_game($me);
- }
- else
- {
- echo "Thanks for joining the game...";
-
- $mycards = DB_get_hand($me);
- sort($mycards);
- echo "<p class=\"mycards\" style=\"margin-top:8em;\">your cards are: <br />\n";
- foreach($mycards as $card)
- display_card($card,$PREF["cardset"]);
- echo "</p>\n";
-
- output_check_for_sickness($me,$mycards);
-
- /* move on to the next stage*/
- DB_set_hand_status_by_hash($me,'check');
- }
- }
- break;
-
- case 'check':
- /* ok, user is in the game, saw his cards and selected his vorbehalt
- * so first we check what he selected
- */
- if(!myisset("solo","wedding","poverty","nines") )
- {
- /* all these variables have a pre-selected default,
- * so we should never get here,
- * unless a user tries to cheat ;)
- * can also happen if user reloads the page!
- */
- echo "<p> You need to answer the <a href=\"$host?me=$me&in=yes\">questions</a>.</p>";
- DB_set_hand_status_by_hash($me,'init');
- }
- else
- {
- echo "Processing what you selected in the last step...<br />";
-
- /* check if this sickness needs to be handled first */
- $gametype = DB_get_gametype_by_gameid($gameid);
- $startplayer = DB_get_startplayer_by_gameid($gameid);
-
- if( $_REQUEST["solo"]!="No")
- {
- /* user wants to play a solo */
-
- /* store the info in the user's hand info */
- DB_set_solo_by_hash($me,$_REQUEST["solo"]);
- DB_set_sickness_by_hash($me,"solo");
-
- echo "<br />Seems like you want to play a ".$_REQUEST["solo"]." solo. Got it.<br />\n";
-
- if($gametype == "solo" && $startplayer<$mypos)
- {}/* do nothing, since someone else already is playing solo */
- else
- {
- /* this solo comes first
- * store info in game table
- */
- DB_set_gametype_by_gameid($gameid,"solo");
- DB_set_startplayer_by_gameid($gameid,$mypos);
- DB_set_solo_by_gameid($gameid,$_REQUEST["solo"]);
- };
- }
- else if($_REQUEST["wedding"] == "yes")
- {
- /* TODO: add silent solo somewhere*/
- echo "Ok, you don't want to play a silent solo...wedding was chosen.<br />\n";
- DB_set_sickness_by_hash($me,"wedding");
- }
- else if($_REQUEST["poverty"] == "yes")
- {
- echo "Don't think you can win with just a few trump...? ok, poverty chosen <br />\n";
- DB_set_sickness_by_hash($me,"poverty");
- }
- else if($_REQUEST["nines"] == "yes")
- {
- echo "What? You just don't want to play a game because you have a few nines? Well, if no one".
- " is playing solo, this game will be canceled.<br />\n";
- DB_set_sickness_by_hash($me,"nines");
- }
-
- echo " Ok, done with checking, please go to the <a href=\"$host?me=$me\">next step of the setup</a>.<br />";
-
- /* move on to the next stage*/
- DB_set_hand_status_by_hash($me,'poverty');
-
- /* check if everyone has reached this stage, send out email */
- $userids = DB_get_all_userid_by_gameid($gameid);
- $ok = 1;
- foreach($userids as $user)
- {
- $userstat = DB_get_hand_status_by_userid_and_gameid($user,$gameid);
- if($userstat!='poverty' && $userstat!='play')
- {
- $ok = 0;
- DB_set_player_by_gameid($gameid,$user);
- }
- };
- if($ok)
- {
- /* reset player = everyone has to do something now */
- DB_set_player_by_gameid($gameid,NULL);
-
- foreach($userids as $user)
- {
- $To = DB_get_email_by_userid($user);
- $userhash = DB_get_hash_from_gameid_and_userid($gameid,$user);
- if($userhash != $me)
- {
- $message = "Everyone finish the questionary in game $gameid, ".
- "please visit this link now to continue: \n".
- " ".$host."?me=".$userhash."\n\n" ;
- mymail($To,$EmailName." finished setup in game $gameid",$message);
- }
- };
- };
- };
-
- break;
-
- case 'poverty':
- /* here we need to check if there is a solo or some other form of sickness.
- * If so, which one is the most important one
- * set that one in the Game table
- * tell people about it.
- */
- echo "<br /> Checking if someone else selected solo, nines, wedding or poverty.<br />";
-
- /* check if everyone has reached this stage */
- $userids = DB_get_all_userid_by_gameid($gameid);
- $ok = 1;
- foreach($userids as $user)
- {
- $userstat = DB_get_hand_status_by_userid_and_gameid($user,$gameid);
- if($userstat!='poverty' && $userstat!='play')
- $ok = 0;
- };
-
- if(!$ok)
- {
- echo "This step can only be handled after everyone finished the last step. ".
- "Seems like this is not the case, so you need to wait a bit... ".
- "you will get an email once that is the case, please use the link in ".
- "that email to continue the game.<br />";
- }
- else
- {
- echo "Everyone has finished checking their cards, let's see what they said...<br />";
-
- /* check what kind of game we are playing, in case there are any solos this already
- *will have the correct information in it */
- $gametype = DB_get_gametype_by_gameid($gameid);
- $startplayer = DB_get_startplayer_by_gameid($gameid);
-
- /* check for different sickness and just output a general info */
- $nines = 0;
- $poverty = 0;
- $wedding = 0;
- $solo = 0;
- foreach($userids as $user)
- {
- $name = DB_get_name_by_userid($user);
- $usersick = DB_get_sickness_by_userid_and_gameid($user,$gameid);
- if($usersick == 'nines')
- {
- $nines = $user;
- echo "$name has a Vorbehalt. <br />";
- break;
- }
- else if($usersick == 'poverty')
- {
- $poverty++;
- echo "$name has a Vorbehalt. <br />";
- }
- else if($usersick == 'wedding')
- {
- $wedding=$user;
- echo "$name has a Vorbehalt. <br />" ;
- }
- else if($usersick == 'solo')
- {
- $solo++;
- echo "$name has a Vorbehalt. <br />" ;
- }
- }
-
- /* now check which sickness comes first and set the gametype to it */
-
- if($gametype == "solo")
- {
- /* do nothing */
- }
- else if($nines)
- {
- /* cancel game */
- /* TODO: should we keep statistics of this? */
- $message = "Hello, \n\n".
- " the game has been canceled because ".DB_get_name_by_userid($nines).
- " has five or more nines and nobody is playing solo.\n\n".
- " To redeal either start a new game or, in case the game was part of a tournament, \n".
- " go to the last game and use the link at the bottom of the page to redeal.";
-
- $userids = DB_get_all_userid_by_gameid($gameid);
- foreach($userids as $user)
- {
- $To = DB_get_email_by_userid($user);
- mymail($To,$EmailName."game $gameid canceled",$message);
- }
-
- /* delete everything from the dB */
- DB_cancel_game($me);
-
- echo "The game has been canceled because ".DB_get_name_by_userid($nines).
- " has five or more nines and nobody is playing solo.\n";
- output_footer();
- DB_close();
- exit();
- }
- else if($poverty==1) /* one person has poverty */
- {
- DB_set_gametype_by_gameid($gameid,"poverty");
- $gametype = "poverty";
- $who = DB_get_sickness_by_gameid($gameid);
- if(!$who)
- {
- $firstsick = DB_get_sickness_by_pos_and_gameid(1,$gameid);
- if($firstsick == "poverty")
- DB_set_sickness_by_gameid($gameid,2); /* who needs to be asked first */
- else
- DB_set_sickness_by_gameid($gameid,1); /* who needs to be asked first */
- }
- }
- else if($poverty==2) /* two people have poverty */
- {
- DB_set_gametype_by_gameid($gameid,"dpoverty");
- $gametype = "dpoverty";
- $who = DB_get_sickness_by_gameid($gameid);
- if(!$who)
- {
- $firstsick = DB_get_sickness_by_pos_and_gameid(1,$gameid);
- if($firstsick == "poverty")
- {
- $seconsick = DB_get_sickness_by_pos_and_gameid(1,$gameid);
- if($secondsick == "poverty")
- DB_set_sickness_by_gameid($gameid,30); /* who needs to be asked first */
- else
- DB_set_sickness_by_gameid($gameid,20); /* who needs to be asked first */
- }
- else
- DB_set_sickness_by_gameid($gameid,10); /* who needs to be asked first */
- }
- }
- else if($wedding> 0)
- {
- DB_set_gametype_by_gameid($gameid,"wedding");
- DB_set_sickness_by_gameid($gameid,'-1'); /* wedding not resolved yet */
- $gametype = "wedding";
- };
-
- echo "<br />\n";
-
- /* now the gametype is set correctly (shouldn't matter that this is calculated for every user)
- * output what kind of game we have */
-
- $poverty = 0;
- foreach($userids as $user)
- {
- /* userids are sorted by position...
- * so output whatever the first one has, then whatever the next one has
- * stop when the sickness is the same as the gametype
- */
-
- $name = DB_get_name_by_userid($user);
- $usersick = DB_get_sickness_by_userid_and_gameid($user,$gameid);
-
- if($usersick)
- echo "$name has $usersick. <br />"; /*TODO: perhaps save this in a string and store in Game? */
-
- if($usersick=="poverty")
- $poverty++;
- 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;
- };
-
- /* output Schweinchen in case the rules need it */
- if( $gametype != "solo")
- if($GAME["schweinchen"] && $RULES["schweinchen"]=="both" )
- echo DB_get_name_by_hash($GAME["schweinchen-who"])." has Schweinchen. <br />";
-
- echo "<br />\n";
-