Added cumulative tiebreak

This commit is contained in:
Jeroen De Meerleer 2019-05-30 21:25:37 +02:00
parent 075f0c6c2f
commit 51c6b8249d
2 changed files with 22 additions and 0 deletions

View File

@ -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;
}
}

View File

@ -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;
}