require_once "./team.php"; require_once "./scheduler.php"; // teams for the tournament $colours = ["red", "green", "yellow", "blue", "orange", "pink", "black", "white"]; $S = new scheduler(51, $colours); //$S = new scheduler(5, ["red", "blue"]); // schedule 6 rounds of the game $S->schedule_fixtures(1); // play all 6 rounds of the game $S->play_rounds(6); foreach ($S->teams as $t) { echo "team " . $t->colour . " has " . $t->number_of_players . " players\n"; } echo "--------------------\n"; $fixtures = $S->get_fixtures(); $cnt = 1; foreach ($fixtures as $f) { echo "Fixture {$cnt}:\n"; echo "\t-----\n"; echo "\tPairs (" . sizeof($f['pairs']) . "):\n"; $i = 1; foreach ($f['pairs'] as $p) { $status1 = $p[0]->results[$cnt - 1] ? "Winner" : "Loser"; $status2 = $p[1]->results[$cnt - 1] ? "Winner" : "Loser"; echo "\t" . $p[0]->name . " (" . $p[0]->team . ", {$status1}) \t\t vs\t\t"; echo $p[1]->name . " (" . $p[1]->team . ", {$status2}) \n"; } echo "\t-----\n"; echo "\tUnpaired players:\n"; //foreach($f['unpaired_players'] as $p) echo "\t" . $p -> name . " (" . $p -> team . ") \n";
$id = 0; $teams = []; $team_colours = []; while (isset($_POST["team{$id}"])) { $name = $_POST["team{$id}"]; $colour = $_POST["colour{$id}"]; $teams[] = $name; $team_colours["{$name}"] = $colour; $id++; } require_once "scheduler.php"; if (sizeof($teams) == sizeof($team_colours) && sizeof($teams) > 0 && $N > 0) { $S = new scheduler($N, $teams); $S->schedule_fixtures($M); $S->play_rounds($M); $data = $S->get_fixtures(); echo "<table id='teams_assigned'>"; echo "<th>Teams assigned</th>"; foreach ($S->teams as $t) { echo "<tr style='background-color: " . $team_colours[$t->colour] . "'>"; echo "<td>" . $t->colour . "</td>"; echo "<td>" . $t->number_of_players . " players</td>"; echo "<td>List of players: "; foreach ($t->players as $pl) { echo $pl->name . ' '; } echo "</td>"; echo "</tr>"; } echo "</table>"; $cnt = 1;