Implemented kashdan

This commit is contained in:
Jeroen De Meerleer 2019-05-30 21:20:14 +02:00
parent 59510c9122
commit 075f0c6c2f
2 changed files with 29 additions and 0 deletions

View File

@ -206,4 +206,30 @@ abstract class Tiebreaks extends Tournament
}
return $tiebreak;
}
/**
* @param Player $player
* @return int
*/
protected function calculateKashdan(Player $player)
{
$tiebreak = 0;
foreach ($player->getPairings() as $pairing) {
$toadd = 0;
if (array_search($pairing->getResult(), Constants::Won) !== false) {
$toadd = 3;
} elseif (array_search($pairing->getResult(), Constants::Draw) !== false) {
$toadd = 2;
} elseif (array_search($pairing->getResult(), Constants::Lost) !== false) {
$toadd = 1;
}
if (array_search(Constants::NotPlayed, $pairing->getResult()) !== false) {
$toadd = 0;
}
$tiebreak += $toadd;
}
return $tiebreak;
}
}

View File

@ -311,6 +311,9 @@ class Tournament extends Tiebreaks
case Tiebreak::Sonneborn:
return $this->calculateSonneborn($player);
break;
case Tiebreak::Kashdan:
return $this->calculateKashdan($player);
break;
default:
return null;
}