mirror of
https://github.com/JeroenED/libpairtwo.git
synced 2024-11-21 22:17:41 +01:00
Added cumulative tiebreak
This commit is contained in:
parent
07c3a8ad21
commit
0179e52eb2
@ -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