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); }
$tmpTable = new FoosTable($workingPath); $tmpTable->loadCurrentStatus(); $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>
$player2 = $table->getPlayerByName($toks[1]); $team1 = new FoosTeam($player1, $player2); $player3 = $table->getPlayerByName($toks[2]); $player4 = $table->getPlayerByName($toks[3]); $team2 = new FoosTeam($player3, $player4); echo $team1->getName() . ' => Chance: ' . number_format($team1->getChancesToWinAgainst($team2) * 100, 2) . '%,' . ' Win: ' . round($team1->getStrengthDeltaAfterGame($team2, 1)) . "\n"; echo $team2->getName() . ' => Chance: ' . number_format($team2->getChancesToWinAgainst($team1) * 100, 2) . '%,' . ' Win: ' . round($team2->getStrengthDeltaAfterGame($team1, 1)) . ""; } $showHelp = false; } // Usecase 5: ?foos player1 player2 score1 player3 player4 score2 if (count($toks) == 6 && is_numeric($toks[2]) && is_numeric($toks[5])) { $tableOld = new FoosTable($workingPath); $tableOld->loadCurrentStatus(); $tableOld->calculateScore(); $table = new FoosTable($workingPath); $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";