Exemplo n.º 1
0
 function testLog()
 {
     $table = new FoosTable(dirname(__FILE__) . '/testData/');
     $table->loadCurrentStatus();
     $table->setLogMaxSize(15);
     $table->calculateScore();
     $log = $table->getLog();
     $this->assertEqual(count($log), 15);
     $this->assertEqual(count($log[0]), 11);
 }
Exemplo n.º 2
0
    $tmpTable->deleteMatch($timestamp);
    $tmpTable->saveToFile();
    // Remove ?delete=xxx part from URL
    header('Location: foos.php');
    die;
}
// Current data
$table = new FoosTable($workingPath);
$maxGamesInGraph = 50;
$table->setLogMaxSize($maxGamesInGraph);
$table->loadCurrentStatus();
$table->calculateScore();
// Table with data 48h old (to display changes)
$tableOld = new FoosTable($workingPath);
$tableOld->loadStatusForTime(time() - 48 * 60 * 60);
$tableOld->calculateScore();
//** View **//
?>
<!doctype html>
<html lang="en" class="no-js">
<head>
    <meta charset="utf-8">
    <title>#last.foos</title>
    <meta name="description" content="Foos.fm">
    <link rel="stylesheet" href="style.css">
    <link rel="icon" href="favicon.ico" type="image/x-icon"> 
</head>
<body>

    <h1>Last.foos</h1>
Exemplo n.º 3
0
    $table->loadCurrentStatus();
    $player1 = $table->getPlayerByName($toks[0]);
    $player2 = $table->getPlayerByName($toks[1]);
    $team1 = new FoosTeam($player1, $player2);
    $player3 = $table->getPlayerByName($toks[3]);
    $player4 = $table->getPlayerByName($toks[4]);
    $team2 = new FoosTeam($player3, $player4);
    $player1Old = $tableOld->getPlayerByName($toks[0]);
    $player2Old = $tableOld->getPlayerByName($toks[1]);
    $player3Old = $tableOld->getPlayerByName($toks[3]);
    $player4Old = $tableOld->getPlayerByName($toks[4]);
    $tableOld->sortPlayers();
    $match = new FoosMatch($team1, $toks[2], $team2, $toks[5]);
    $table->addMatch($match);
    echo "Game " . $table->getNumberOfMatches() . ": " . $match->getPlayer1()->getName() . " beat " . $match->getPlayer2()->getName() . "\n";
    $table->calculateScore();
    echo $player1->getName() . ' => ' . 'from #' . $tableOld->getPositionOfPlayer($toks[0]) . " (" . $player1Old->getRoundedStrength() . ") " . "to #" . $table->getPositionOfPlayer($toks[0]) . " (" . $player1->getRoundedStrength() . ")\n";
    echo $player2->getName() . ' => ' . 'from #' . $tableOld->getPositionOfPlayer($toks[1]) . " (" . $player2Old->getRoundedStrength() . ") " . "to #" . $table->getPositionOfPlayer($toks[1]) . " (" . $player2->getRoundedStrength() . ")\n";
    echo $player3->getName() . ' => ' . 'from #' . $tableOld->getPositionOfPlayer($toks[3]) . " (" . $player3Old->getRoundedStrength() . ") " . "to #" . $table->getPositionOfPlayer($toks[3]) . " (" . $player3->getRoundedStrength() . ")\n";
    echo $player4->getName() . ' => ' . 'from #' . $tableOld->getPositionOfPlayer($toks[4]) . " (" . $player4Old->getRoundedStrength() . ") " . "to #" . $table->getPositionOfPlayer($toks[4]) . " (" . $player4->getRoundedStrength() . ")\n";
    $table->saveToFile();
    $showHelp = false;
}
// Display help message
if ($showHelp) {
    echo "How it works:\n" . "Current table: foos\n" . "Chances of winning: foos Samuel Coffey\n" . "Log a game: foos Samuel 2 Coffey 0\n";
}
function printFoosTable($players)
{
    $maxNameLength = 8;
    $numPlayers = count($players);