exit();
}
+/* done major error checking, output header of HTML page */
output_header();
/* check if we want to start a new game */
{
echo "couldn't find one of the names, please start a new game";
output_footer();
+ DB_close();
exit();
}
{
echo "Error defining ruleset: $ruleset";
output_footer();
+ DB_close();
exit();
};
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();
}
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();
}
$RULES["dullen"] = $r[2];
$RULES["schweinchen"] = $r[3];
-
+ $RULES["call"] = "1st-own-card";
+
+
/* get some infos about the game */
$gametype = DB_get_gametype_by_gameid($gameid);
$gamestatus = DB_get_game_status_by_gameid($gameid);
display_card($card,$PREF["cardset"]);
echo "</p>\n";
- check_for_sickness($me,$mycards);
+ output_check_for_sickness($me,$mycards);
/* move on to the next stage*/
DB_set_hand_status_by_hash($me,'check');
$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",$message);
+ $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);
}
};
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 />";
+ "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 "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)
$message = "Someone has poverty, it's your turn to decide, if you want to take the trump. Please visit:".
" ".$host."?me=".$userhash."\n\n" ;
- mymail($To,$EmailName." poverty",$message);
+ mymail($To,$EmailName." poverty (game $gameid)",$message);
}
/* this user is done */
$To = DB_get_email_by_pos_and_gameid($who,$gameid);
$userhash = DB_get_hash_from_game_and_pos($gameid,$who);
- $message = "Someone has poverty, it's your turn to decide, if you want to take the trump. Please visit:".
- " ".$host."?me=".$userhash."\n\n" ;
- mymail($To,$EmailName." poverty",$message);
+ $message = "Someone has poverty, it's your turn to decide, ".
+ "if you want to take the trump. Please visit:".
+ " ".$host."?me=".$userhash."\n\n" ;
+ mymail($To,$EmailName." poverty (game $gameid)",$message);
}
}
echo "<p style=\"background-color:red\";>Game $gameid has been cancled.<br /><br /></p>";
output_footer();
+ DB_close();
exit();
}
/* email startplayer) */
$message = "It's your turn now in game $gameid.\n".
"Use this link to play a card: ".$host."?me=".$hash."\n\n" ;
- mymail($email,$EmailName."ready, set, go... ",$message);
+ mymail($email,$EmailName."ready, set, go... (game $gameid) ",$message);
}
else
echo " Please, <a href=\"$host?me=$me\">start</a> the game.<br />";
/* has the game started? No, then just wait here...*/
if($gamestatus == 'pre')
{
- echo "You finished the setup, but not everyone else finished it...so you need to wait for the others. Just wait for the an email... <br />";
+ echo "You finished the setup, but not everyone else finished it... ".
+ "so you need to wait for the others. Just wait for the an email... <br />";
break; /* not sure this works... the idea is that you can
* only play a card after everyone is ready to play */
}
" User.id, ".
" Hand.party as party, ".
" Hand.sickness as sickness, ".
- " Hand.point_call ".
+ " Hand.point_call, ".
+ " User.last_login ".
"FROM Hand ".
"LEFT JOIN User ON User.id=Hand.user_id ".
"WHERE Hand.game_id='".$gameid."' ".
$pos = $r[1];
$user = $r[2];
$party = $r[3];
- $sickness= $r[4];
- $call = $r[5];
+ $sickness = $r[4];
+ $call = $r[5];
+ $lastlogin = strtotime($r[6]);
$offset = DB_get_user_timezone($user);
$zone = return_timezone($offset);
/* add hints for poverty, wedding, solo, etc */
if($GT=="poverty" && $party=="re")
if($sickness=="poverty")
- echo "(poverty <)";
+ {
+ $userhash = DB_get_hash_from_gameid_and_userid($gameid,$user);
+ $cards = DB_get_all_hand($userhash);
+ $trumpNR = count_trump($cards);
+ if($trumpNR)
+ echo "(poverty < trump back)";
+ else
+ echo "(poverty <)";
+ }
else
echo "(poverty >)";
if($GT=="dpoverty")
if($party=="re")
if($sickness=="poverty")
- echo "(poverty A <)";
+ {
+ $userhash = DB_get_hash_from_gameid_and_userid($gameid,$user);
+ $cards = DB_get_all_hand($userhash);
+ $trumpNR = count_trump($cards);
+ if($trumpNR)
+ echo "(poverty A < trump back)";
+ else
+ echo "(poverty A <)";
+ }
else
echo "(poverty A >)";
else
if($sickness=="poverty")
- echo "(poverty B <)";
+ {
+ $userhash = DB_get_hash_from_gameid_and_userid($gameid,$user);
+ $cards = DB_get_all_hand($userhash);
+ $trumpNR = count_trump($cards);
+ if($trumpNR)
+ echo "(poverty B < trump back)";
+ else
+ echo "(poverty B <)";
+ }
else
echo "(poverty B >)";
echo "(wedding +)";
else
echo "(wedding)";
+
+ if(ereg("solo",$GT) && $party=="re")
+ echo "($GT)";
+
/* add point calls */
if($call!=NULL)
echo " $party $call ";
echo "<br />\n";
- echo " local time: ".date("Y-m-d H:i:s")."\n";
+ echo " local time: ".date("Y-m-d H:i:s")."<br />\n";
+ echo " last login: ".date("Y-m-d H:i:s",$lastlogin)."<br />\n";
echo " </span>\n";
}
" Hand.position as position,".
" Play.sequence as sequence, ".
" Trick.id, ".
- " Comment.comment ".
+ " Comment.comment, ".
+ " Play.create_date, ".
+ " Hand.user_id ".
"FROM Trick ".
"LEFT JOIN Play ON Trick.id=Play.trick_id ".
"LEFT JOIN Hand_Card ON Play.hand_card_id=Hand_Card.id ".
$seq = $r[2];
$trick = $r[3];
$comment = $r[4];
-
+ $timeplayed = strtotime($r[5]);
+ $user = $r[6];
+
+ $offset = DB_get_user_timezone($user);
+ $zone = return_timezone($offset);
+ date_default_timezone_set($zone);
+
/* check if first schweinchen has been played */
if($r[0] == 19 || $r[0] == 20 )
$GAME["schweinchen"]++;
}
if(sizeof($h))
$header = "CC: ".join(",",$h)."\r\n";
-
+
foreach($userids as $user)
{
$To = DB_get_email_by_userid($user);
- $hash = DB_get_hash_from_gameid_and_userid($gameid,$user)
+ $hash = DB_get_hash_from_gameid_and_userid($gameid,$user);
$mymessage = $message."Use this link to have a look at the game: ".$host."?me=".$hash."\n\n" ;
mymail($To,$EmailName."game over (game $gameid)",$mymessage,$header);
}
$message = "A card has been played in game $gameid.\n\n".
"It's your turn now.\n".
"Use this link to play a card: ".$host."?me=".$next_hash."\n\n" ;
- mymail($email,$EmailName."a card has been played",$message);
+ mymail($email,$EmailName."a card has been played in game $gameid",$message);
}
}
else
" <input type=\"radio\" name=\"call30\" value=\"yes\" /> ";
if( can_call(0,$me) )
echo " 0:".
- " <input type=\"radio\" name=\"call0\" value=\"yes\" /> ";
+ " <input type=\"radio\" name=\"call0\" value=\"yes\" /> ".
+ " no call:".
+ " <input type=\"radio\" name=\"call0\" value=\"no\" /> ";
echo "<br />\nA short comments:<input name=\"comment\" type=\"text\" size=\"30\" maxlength=\"50\" />\n";
echo "<input type=\"hidden\" name=\"me\" value=\"$me\" />\n";
echo "error in testing the status";
}
output_footer();
+ DB_close();
exit();
}
/* user status page */
echo "<p>and these are your games that are already done:<br />Game: \n";
+ $output=array();
$result = mysql_query("SELECT hash,game_id from Hand WHERE user_id='$uid' AND status='gameover'" );
while( $r = mysql_fetch_array($result,MYSQL_NUM))
- echo "<a href=\"".$host."?me=".$r[0]."\">#".$r[1]." </a>, ";
- echo "</p>\n";
+ $output[]= "<a href=\"".$host."?me=".$r[0]."\">#".$r[1]." </a>";
+ echo implode(", ",$output)."</p>\n";
$names = DB_get_all_names();
echo "<p>registered players:<br />\n";
- foreach ($names as $name)
- echo "$name, \n";
+ echo implode(", ",$names)."\n";
echo "</p>\n";
echo "<p>Want to start a new game? Visit <a href=\"".$host."?new\">this page.</a></p>";
}
};
output_footer();
+ DB_close();
exit();
}
/* page for registration */
/* default login page */
else
{
- $pre=0;$game=0;$done=0;
+ $pre[0]=0;$game[0]=0;$done[0]=0;
$r=mysql_query("SELECT COUNT(id) FROM Game GROUP BY status");
if($r) {
- $pre = mysql_fetch_array($r,MYSQL_NUM);
+ $pre = mysql_fetch_array($r,MYSQL_NUM);
$game = mysql_fetch_array($r,MYSQL_NUM);
$done = mysql_fetch_array($r,MYSQL_NUM);
}
- output_home_page($pre[0],$game[0],$done[0]);
+
+ $r=mysql_query("SELECT AVG(datediff(mod_date,create_date)) FROM Game where status='gameover' ");
+ if($r)
+ $avgage= mysql_fetch_array($r,MYSQL_NUM);
+ else
+ $avgage[0]=0;
+
+ output_home_page($pre[0],$game[0],$done[0],$avgage[0]);
}
output_footer();