diff --git a/src/Tiebreaks.php b/src/Tiebreaks.php index 5c308fd..652b789 100644 --- a/src/Tiebreaks.php +++ b/src/Tiebreaks.php @@ -232,4 +232,23 @@ abstract class Tiebreaks extends Tournament } return $tiebreak; } + + /** + * @param Player $player + * @return float|int + */ + protected function calculateCumulative(Player $player) + { + $tiebreak = 0; + foreach ($player->getPairings() as $pairing) { + $toadd = 0; + if (array_search($pairing->getResult(), Constants::Won) !== false) { + $toadd = 1; + } elseif (array_search($pairing->getResult(), Constants::Draw) !== false) { + $toadd = 0.5; + } + $tiebreak += $tiebreak + $toadd; + } + return $tiebreak; + } } diff --git a/src/Tournament.php b/src/Tournament.php index 2f09001..9841ec8 100644 --- a/src/Tournament.php +++ b/src/Tournament.php @@ -314,6 +314,9 @@ class Tournament extends Tiebreaks case Tiebreak::Kashdan: return $this->calculateKashdan($player); break; + case Tiebreak::Cumulative: + return $this->calculateCumulative($player); + break; default: return null; }