5 a.1 Showing a ranking
Jeroen De Meerleer edited this page 2019-09-28 10:22:12 +02:00

You can show a ranking by using the Tournament::getRanking() method.

First, start by importing your sws-file. Using the resulting Sws-object you can navigate to the tournament and call the Tournament::getRanking() method.

Tournament::getRanking() returns an array of Player objects. This allows you to iterate through the array using foreach and display the required fields. Tournament::getRanking(); takes account of the tiebreaks. The order of tiebreaks gets loaded from your pairing file. The tiebreaks are calculated when getRanking() is called. Only the required tiebreaks are calculated. If tiebreak 1 is enough to provide the full ranking, tiebreak 2 does not get calculated.

Example

require_once('vendor/autoload.php');

Use JeroenED/Libpairtwo/IOFactory;

$filereader = IOFactory::createReader('Swar-4');
$filereader->read('mycompetition.swar');

$ranking = $filereader->getTournament()->getRanking();
$count = 1;
foreach($ranking as $player) {
    echo $count . ' ' . $player->getName() . '(' . $player.->getTiebreaks()[0] . ')';
    $count++;
}