. */ /** * @package Base * @subpackage Game */ require('header.php'); libHTML::starthtml(); $joinablegames = libFindGames::joinablegames(); $joinedactivegames = libFindGames::joinedactivegames(); $joinedfinishedgames = libFindGames::joinedfinishedgames(); $activegames = libFindGames::activegames(); $finishedgames = libFindGames::finishedgames(); $gametypes = array('Joined','Joinable','Active','Finished'); if( isset($_REQUEST['gametype']) ) { $gametype = $_REQUEST['gametype']; } elseif( isset($_SESSION['gametype']) ) { $gametype = $_SESSION['gametype']; } else { if( $User->type['User'] ) { if ( ( count($joinedactivegames) + count($joinedfinishedgames) ) == 0 ) { // The user hasn't joined any games; give them a list to join $gametype = 'Joinable'; } else { // Show the user his games $gametype = 'Joined'; } } else { // Show the guest some games that others are playing in $gametype = 'Active'; } } if ( ! in_array($gametype, $gametypes) ) { if ( $User->type['User'] ) $gametype = 'Joined'; else $gametype = 'Active'; } $_SESSION['gametype'] = $gametype; print '
'; if ( $User->type['User'] ) { print 'Your games ('.count($joinedactivegames).')'; } print ' Joinable ('.count($joinablegames).') Active ('.count($activegames).') Finished ('.(count($finishedgames)+count($joinedfinishedgames)).')'; print '
'; libHTML::pagebreak(); $first = true; switch ( $gametype ) { case 'Joined': if ( count($joinedactivegames) == 0) { print '

You are not in any active games, select the "Joinable games" tab '. 'to view games that you can join, or select "New game" in the header to create your own game (you should generally join other peoples games before creating your own).

'; } foreach ($joinedactivegames as $gameID) { if ( $first ) $first = false; else print '
'; $CURGame = new Game($gameID); print $CURGame->summary(); } break; case 'Joinable': if ( count($joinablegames) == 0 ) { print '

There are no joinable games, select '. '"New game" in the header to create your own game.

'; } foreach ($joinablegames as $gameID) { if ( $first ) $first = false; else print '
'; $CURGame = new Game($gameID); print $CURGame->summary(); } break; case 'Active': if ( count($activegames) == 0 ) { print '

There are no active games on this server, select '. '"New game" in the header to create your own game.

'; } foreach ($activegames as $gameID) { if ( $first ) $first = false; else print '
'; $CURGame = new Game($gameID); print $CURGame->summary(); } break; case 'Finished': if ( (count($finishedgames)+count($joinedfinishedgames)) == 0 ) { print '

There are no finished games on this server, select '. '"New game" in the header to create your own game.

'; } if ( count($joinedfinishedgames) != 0) { print '

Your finished games:

'; } $first = true; $i = 0; foreach ($joinedfinishedgames as $gameID) { $i++; if ( $i > 100 ) break; //FIXME: Add pagination if ( $first ) $first = false; else print '
'; $CURGame = new Game($gameID); print $CURGame->summary(); } if ( count($joinedfinishedgames) != 0) { print '

Finished games:

'; } $i = 0; foreach ($finishedgames as $gameID) { $i++; if ( $i > 100 ) break; //*** if ( $first ) $first = false; else print '
'; $CURGame = new Game($gameID); print $CURGame->summary(); } break; } libHTML::footer(); ?>