mirror of
https://github.com/JeroenED/libpairtwo.git
synced 2024-11-16 11:57:51 +01:00
Created Showing the pairings of a specific player (markdown)
parent
77256cd1b7
commit
6115d00821
31
Showing-the-pairings-of-a-specific-player.md
Normal file
31
Showing-the-pairings-of-a-specific-player.md
Normal file
@ -0,0 +1,31 @@
|
|||||||
|
You can show the pairings of a specific player by using the `Player::getPairings()` method. To get the specific player you can use the static function `Player::getPlayersByName()`.
|
||||||
|
|
||||||
|
## Example
|
||||||
|
|
||||||
|
```php
|
||||||
|
<?php
|
||||||
|
|
||||||
|
require_once('vendor/autoload.php');
|
||||||
|
|
||||||
|
use JeroenED\Libpairtwo\Sws;
|
||||||
|
use JeroenED\Libpairtwo\Player;
|
||||||
|
|
||||||
|
$sws = Sws::readSws('Tata-Steel-2018.sws');
|
||||||
|
|
||||||
|
$magnusses = Player::getPlayersByName("Magnus Carlsen", $sws->getTournament());
|
||||||
|
|
||||||
|
$magnus = $magnusses[0];
|
||||||
|
|
||||||
|
foreach ($magnus->getPairings() as $game) {
|
||||||
|
$player = $pairing->getPlayer()->getName();
|
||||||
|
if (!is_null($pairing->getOpponent())) {
|
||||||
|
$opponent = $pairing->getOpponent()->getName();
|
||||||
|
$color = $pairing->getColor()->getKey();
|
||||||
|
echo $player . ' against ' . $opponent . ' using ' . $color . PHP_EOL;
|
||||||
|
} elseif ($pairing->getResult() == Result::bye ) {
|
||||||
|
echo $player . ' is bye' . PHP_EOL;
|
||||||
|
} elseif ($pairing->getResult() == Result::absent ) {
|
||||||
|
echo $player . ' is absent' . PHP_EOL;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
```
|
Loading…
Reference in New Issue
Block a user