mirror of
https://github.com/JeroenED/libpairtwo.git
synced 2024-11-22 06:26:57 +01:00
Implemented Sonneborn-Berger
This commit is contained in:
parent
eba962a11c
commit
5128d2762e
@ -188,4 +188,22 @@ abstract class Tiebreaks extends Tournament
|
|||||||
}
|
}
|
||||||
return $tiebreak;
|
return $tiebreak;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param Player $player
|
||||||
|
* @return float|int|null
|
||||||
|
*/
|
||||||
|
protected function calculateSonneborn(Player $player)
|
||||||
|
{
|
||||||
|
$tiebreak = 0;
|
||||||
|
foreach ($player->getPairings() as $key => $pairing) {
|
||||||
|
if (array_search($pairing->getResult(), Constants::Won) !== false) {
|
||||||
|
$tiebreak += $pairing->getOpponent()->getPoints();
|
||||||
|
} elseif (array_search($pairing->getResult(), Constants::draw) !== false) {
|
||||||
|
$tiebreak += $pairing->getOpponent()->getPoints() / 2;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return $tiebreak;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -308,6 +308,9 @@ class Tournament extends Tiebreaks
|
|||||||
case Tiebreak::BuchholzMed:
|
case Tiebreak::BuchholzMed:
|
||||||
return $this->calculateBuchholz($player, 1, 1);
|
return $this->calculateBuchholz($player, 1, 1);
|
||||||
break;
|
break;
|
||||||
|
case Tiebreak::Sonneborn:
|
||||||
|
return $this->calculateSonneborn($player);
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user