- Mastermind: 4-color sequence, 10 tries, black/white peg feedback - Hangman: 6 lives, progressive letter reveal, 10-word vocabulary - Both available in BBS (telnet) and web (WML/XHTML) sides - Shared sp_games persistence, scores table integration - Updated games index and menu navigation
31 lines
1.1 KiB
PHP
31 lines
1.1 KiB
PHP
<?php
|
|
require_once __DIR__ . '/../lib/bootstrap.php';
|
|
$games = ['guess' => 'Guess the Number', 'quiz' => 'Quick Quiz',
|
|
'ttt' => 'Noughts & Crosses', 'nim' => 'Nim', 'mastermind' => 'Mastermind'];
|
|
$g = (string)($_GET['g'] ?? '');
|
|
|
|
page_start('High scores', ['back' => '/games.php']);
|
|
|
|
if (!isset($games[$g])) {
|
|
p_para('Pick a game:');
|
|
$links = [];
|
|
foreach ($games as $k => $n) $links[] = ['/games/scores.php', $n, ['g' => $k]];
|
|
p_links($links);
|
|
} else {
|
|
p_para($games[$g] . ' - top 10:');
|
|
$s = db()->prepare("SELECT u.username, MAX(s.score) sc, COUNT(*) n
|
|
FROM scores s JOIN users u ON u.id=s.user_id
|
|
WHERE s.game=? GROUP BY s.user_id
|
|
ORDER BY sc DESC LIMIT 10");
|
|
$s->execute([$g]);
|
|
$rows = $s->fetchAll();
|
|
if (!$rows) p_para('No scores yet.');
|
|
$i = 1;
|
|
foreach ($rows as $r) {
|
|
p_para($i++ . '. ' . $r['username'] . ' - ' . $r['sc'] . ' (' . $r['n'] . ' plays)');
|
|
}
|
|
p_links([['/games/scores.php', 'Other games']]);
|
|
}
|
|
p_links([['/games.php', 'Games'], ['/index.php', 'Home']]);
|
|
page_end();
|