X-Git-Url: https://git.nubati.net/cgi-bin/gitweb.cgi?p=e-DoKo.git;a=blobdiff_plain;f=include%2Fuser.php;h=eb4f6c4c33dd8160c066491811546b3328bb75ae;hp=1f2ae74fd7f70eb42e117042a227704e6cd652aa;hb=8ce1e61f4b254ee07466503dc5a193d227123005;hpb=6e7ed2d202da016b9a74256371369cc41201df2e diff --git a/include/user.php b/include/user.php index 1f2ae74..eb4f6c4 100644 --- a/include/user.php +++ b/include/user.php @@ -138,81 +138,167 @@ else echo "
Session:
\n";
- echo " p = pre-game phase ";
- echo "P = game in progess ";
- echo "E = game ended ";
- echo "N = N games with same hand
";
+ echo "
Games: \n";
+ echo " = pre-game phase ";
+ echo " = game in progess ";
+ echo "N = game over (N people played the same hand)
";
+ echo " Reminder: canceling a game can't be reversed!";
echo "
\n"; - while( $r = DB_fetch_array($result)) + /* sort into active and passive sessions */ + $count = 0; /* count number of games to check for beginner status */ + $session = -1; + $maxgame = 0; + $output_active = ""; + $output_inactive = ""; + $sessionoutput = ""; + $gameoutput = ""; + $keep_going = 2; + while( $keep_going ) { - $count++; - $game = DB_format_gameid($r[1]); - $gamenr = (int) $game; - if($gamenrold < $gamenr) + /* get next element */ + $r = DB_fetch_array($result); + + if($r) + $count++; + else { - if($gamenrold!=-1) - echo " | ||
$gamenr: | \n"; - else - echo "$gamenr:\n"; - $gamenrold = $gamenr; - echo "\n"; + /* need to run the while loop one more time when we run out of elements in the database */ + $keep_going--; + $r[0] = NULL; + $r[1] = NULL; + $r[2] = NULL; + $r[3] = NULL; + $r[4] = NULL; + $r[5] = NULL; + $r[6] = -2; } - $Multi = ($r[5]>1) ? "multi" : ""; - if($r[4]=='pre') - echo " p \n"; - else if (in_array($r[4],array('gameover','cancel-timedout','cancel-nines','cancel-noplay','cancel-trump'))) - { - echo " "; - if($r[5]<2) - echo "E "; - else - echo $r[5]; - echo "\n"; - } - else - echo " P \n"; - if($r[4] == 'pre' || $r[4] == 'play') + if( $r[6]==$session ) { - echo " | \n\n ";
- if($r[3]==$myid || !$r[3])
- echo "(it's your turn)\n";
- else
+ /* same session, update information */
+ $maxgame++;
+ $myhash = $r[0];
+ $gameid = $r[1];
+ $gamemoddate = $r[2];
+ $userid = $r[3];
+ $gamestatus = $r[4];
+ $gamefrequence = $r[5];
+
+ /* create output */
+ $sessionoutput .= $gameoutput;
+ $gameoutput = " "
+ .$gamefrequence."\n";
+ }
+ else
+ { /* new session */
+
+ /* output old session if available */
+ if($maxgame)
{
- $name = DB_get_name('userid',$r[3]);
- $gameid = $r[1];
- /* check if we need to send out a reminder */
- if(DB_get_reminder($r[3],$gameid)==0)
- if(time()-strtotime($r[2]) > 60*60*24*7)
- echo "Send a reminder.";
-
- /* check vacaction status of this user */
- if($vacation=check_vacation($r[3]))
+ /* is session active? */
+ if($gamestatus == 'pre' || $gamestatus== 'play' || time()-strtotime($gamemoddate) < 60*60*24*5 )
{
- $stop = substr($vacation[1],0,10);
- $title = 'begin:'.substr($vacation[0],0,10).' end:'.$vacation[1].' '.$vacation[2];
- echo "(it's $name's (on vacation until $stop) turn)\n";
+ $output_active .= " '."\n"; + $output_active .= ' '.$sessionoutput.''; + } + + $output_active .= " |