mirror of
https://github.com/JeroenED/libpairtwo.git
synced 2024-10-31 20:56:08 +01:00
Implemented kashdan
This commit is contained in:
parent
59510c9122
commit
075f0c6c2f
@ -206,4 +206,30 @@ abstract class Tiebreaks extends Tournament
|
|||||||
}
|
}
|
||||||
return $tiebreak;
|
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;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -311,6 +311,9 @@ class Tournament extends Tiebreaks
|
|||||||
case Tiebreak::Sonneborn:
|
case Tiebreak::Sonneborn:
|
||||||
return $this->calculateSonneborn($player);
|
return $this->calculateSonneborn($player);
|
||||||
break;
|
break;
|
||||||
|
case Tiebreak::Kashdan:
|
||||||
|
return $this->calculateKashdan($player);
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user