Merge branch 'remove-getters' into develop

This commit is contained in:
Jeroen De Meerleer 2019-12-21 19:33:00 +01:00
commit b5b45d649d
Signed by: JeroenED
GPG Key ID: 28CCCB8F62BFADD6
2 changed files with 20 additions and 20 deletions

34
dist/template.php vendored
View File

@ -2,7 +2,7 @@
// EDIT ME!
$pairingfile = 'your pairing-file.swar';
$fileformat = 'Swar-4'; // Possible values: Pairtwo-5, Pairtwo-6, Swar-4
$fileformat = 'Swar-4'; // Possible getValue()s: Pairtwo-5, Pairtwo-6, Swar-4
?>
<!doctype html>
@ -37,37 +37,37 @@ $reader->read($pairingfile);
// You can also use the doc/api folder to get all possible methods and fields
// Below is an example of what can be used. Feel free to modify this.
echo '<h1>' . $reader->getTournament()->getName() . '</h1>' . PHP_EOL;
foreach ($reader->getTournament()->getRounds() as $round) {
echo '<h2>Round ' . ($round->getRoundNo() + 1) . ': ' . $round->getDate()->format('m/d/Y') . '</h2>' . PHP_EOL;
echo '<h1>' . $reader->Tournament->Name . '</h1>' . PHP_EOL;
foreach ($reader->Tournament->Rounds as $round) {
echo '<h2>Round ' . ($round->RoundNo + 1) . ': ' . $round->Date->format('m/d/Y') . '</h2>' . PHP_EOL;
echo '<table>' . PHP_EOL;
echo '<thead>' . PHP_EOL;
echo '<tr><th></th><th>White</th><th>Black</th><th>Result</th></tr>' . PHP_EOL;
echo '</thead>' . PHP_EOL;
echo '<tbody>' . PHP_EOL;
foreach ($round->getGamesByBoard() as $game) {
foreach ($round->GamesByBoard as $game) {
echo '<tr>' . PHP_EOL;
echo '<td>' . ($game->getBoard() + 1) . '</td>' . PHP_EOL;
echo '<td>' . $game->getWhite()->getPlayer()->getName() . '</td>' . PHP_EOL;
echo '<td>' . $game->getBlack()->getPlayer()->getName() . '</td>' . PHP_EOL;
echo '<td>' . $game->getResult()->getValue() . '</td>' . PHP_EOL;
echo '<td>' . ($game->Board + 1) . '</td>' . PHP_EOL;
echo '<td>' . $game->White->Player->Name . '</td>' . PHP_EOL;
echo '<td>' . $game->Black->Player->Name . '</td>' . PHP_EOL;
echo '<td>' . $game->Result->getValue() . '</td>' . PHP_EOL;
echo '</tr>' . PHP_EOL;
}
echo '</tbody>' . PHP_EOL;
echo '</table>' . PHP_EOL;
echo '<p><strong>Bye:</strong> ';
$bye = [];
foreach ($round->getBye() as $pairing) {
$bye[] = $pairing->getPlayer()->getName();
foreach ($round->Bye as $pairing) {
$bye[] = $pairing->Player->Name;
}
echo implode('; ', $bye);
echo '</p>' . PHP_EOL;
echo '<p><strong>Absent:</strong> ';
$bye = [];
foreach ($round->getAbsent() as $pairing) {
$bye[] = $pairing->getPlayer()->getName();
foreach ($round->Absent as $pairing) {
$bye[] = $pairing->Player->Name;
}
echo implode('; ', $bye);
echo '</p>' . PHP_EOL;
@ -77,7 +77,7 @@ echo '<h2>Rankings</h2>' . PHP_EOL;
echo '<table>' . PHP_EOL;
echo '<thead>' . PHP_EOL;
echo '<tr><th> </th><th>Name (elo)</th>' . PHP_EOL;
foreach ($reader->getTournament()->getTieBreaks() as $tiebreak) {
foreach ($reader->Tournament->TieBreaks as $tiebreak) {
echo '<th>' . $tiebreak->getValue() . '</th>' . PHP_EOL;
}
echo '</tr>' . PHP_EOL;
@ -85,11 +85,11 @@ echo '</thead>' . PHP_EOL;
echo '<tbody>' . PHP_EOL;
$rank = 1;
foreach ($reader->getTournament()->getRanking() as $player) {
foreach ($reader->Tournament->Ranking as $player) {
echo '<tr>' . PHP_EOL;
echo '<td>' . $rank . '</td>' . PHP_EOL;
echo '<td>' . $player->getName() . '(' . $player->getElo($reader->getTournament()->getPriorityElo()) . ')</td>' . PHP_EOL;
echo '<td>' . implode('</td><td>', $player->getTiebreaks()) . '</td>' . PHP_EOL;
echo '<td>' . $player->Name . '(' . $player->getElo($reader->Tournament->PriorityElo) . ')</td>' . PHP_EOL;
echo '<td>' . implode('</td><td>', $player->Tiebreaks) . '</td>' . PHP_EOL;
echo '</tr>' . PHP_EOL;
$rank++;
}

View File

@ -786,7 +786,7 @@ class Tournament
{
$tiebreak = 0;
foreach ($player->Pairings as $plkey => $plpairing) {
if (($plpairing->Opponent->Points / count($plpairing->Opponent->Pairings) * 100) >= $cut) {
if (($plpairing->Opponent->calculatePoints() / count($plpairing->Opponent->Pairings) * 100) >= $cut) {
if (array_search($plpairing->Result, Constants::Won) !== false) {
$tiebreak += 1;
} elseif (array_search($plpairing->Result, Constants::Draw) !== false) {
@ -856,9 +856,9 @@ class Tournament
foreach ($player->Pairings as $key => $pairing) {
if ($pairing->Opponent) {
if (array_search($pairing->Result, Constants::Won) !== false) {
$tiebreak += $pairing->Opponent->Points;
$tiebreak += $pairing->Opponent->calculatePoints();
} elseif (array_search($pairing->Result, Constants::Draw) !== false) {
$tiebreak += $pairing->Opponent->Points / 2;
$tiebreak += $pairing->Opponent->calculatePoints() / 2;
}
}
}