mirror of
https://github.com/JeroenED/libpairtwo.git
synced 2024-10-31 20:56:08 +01:00
Added cumulative tiebreak
This commit is contained in:
parent
075f0c6c2f
commit
51c6b8249d
@ -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;
|
||||
}
|
||||
}
|
||||
|
@ -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;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user