if(myisset("followup") )
{
$followup= $_REQUEST["followup"];
- mysql_query("INSERT INTO Game VALUES (NULL, NULL, '$randomNRstring', 'normal', NULL,'1','pre','$followup' ,NULL)");
+ $session = DB_get_session_by_gameid($followup);
+ if($session)
+ mysql_query("INSERT INTO Game VALUES (NULL, NULL, '$randomNRstring', 'normal', NULL,'1','pre','$session' ,NULL)");
+ else
+ {
+ /* get max session */
+ $max = DB_get_max_session();
+ $max++;
+ mysql_query("INSERT INTO Game VALUES (NULL, NULL, '$randomNRstring', 'normal', NULL,'1','pre','$max' ,NULL)");
+ mysql_query("UPDATE Game SET session='".$max."' WHERE id=".DB_quote_smart($followup));
+ }
}
else
mysql_query("INSERT INTO Game VALUES (NULL, NULL, '$randomNRstring', 'normal', NULL,'1','pre', NULL ,NULL)");
while( $r = mysql_fetch_array($result,MYSQL_NUM))
echo " FINAL SCORE: ".$r[0]." ".$r[1]."<br />";
- /* suggest a new game with the same people in it, just rotated once */
- $names = DB_get_all_names_by_gameid($gameid);
- output_ask_for_new_game($names[1],$names[2],$names[3],$names[0],$gameid);
+
+ $session = DB_get_session_by_gameid($gameid);
+ $result = mysql_query("SELECT id,create_date FROM Game".
+ " WHERE session=$session".
+ " ORDER BY create_date DESC".
+ " LIMIT 1");
+ $r=-1;
+ if($result)
+ $r = mysql_fetch_array($result,MYSQL_NUM);
+
+ if(!$session || $gameid==$r)
+ {
+ /* suggest a new game with the same people in it, just rotated once */
+ $names = DB_get_all_names_by_gameid($gameid);
+ output_ask_for_new_game($names[1],$names[2],$names[3],$names[0],$gameid);
+ }
}
break;
default:
echo "</p>\n";
- echo "<p>and these are your games that are already done:<br />\n";
+ echo "<p>and these are your games that are already done:<br />Game: \n";
$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]."\">game #".$r[1]." </a><br />";
+ echo "<a href=\"".$host."?me=".$r[0]."\">#".$r[1]." </a>, ";
echo "</p>\n";
$names = DB_get_all_names();
echo "<p>registered players:<br />\n";
foreach ($names as $name)
- echo "$name <br />\n";
+ echo "$name, \n";
echo "</p>\n";
- echo "<p>Want to start a new game? remember 4 names from the list above and visit ".
- "<a href=\"".$host."?new\">this page.</a></p>";
+ echo "<p>Want to start a new game? Visit <a href=\"".$host."?new\">this page.</a></p>";
}
else
{