Skip to content

Commit

Permalink
ah fix
Browse files Browse the repository at this point in the history
  • Loading branch information
lsv committed May 9, 2018
1 parent f43fe86 commit 3f2e9a0
Showing 1 changed file with 17 additions and 4 deletions.
21 changes: 17 additions & 4 deletions src/Model/Event.php
Original file line number Diff line number Diff line change
Expand Up @@ -354,6 +354,12 @@ public function get1HUnderGoals(): array
*/
public function getOrdAH(): array
{
$isFractionAllowed = function (float $number) {
$whole = floor($number);
$fraction = $number - $whole;
return $fraction === 0 || $fraction === .5;
};

$filtered = array_filter($this->odds, function (Odds $odds) {
return
$odds->getSubtype() === 'win'
Expand All @@ -364,13 +370,20 @@ public function getOrdAH(): array

$handicaps = [];
foreach ($filtered as $odds) {
foreach ($this->getParticipants() as $participant) {
if ($participant->getId() === $odds->getIparam1()) {
$handicaps[] = new Handicap($this, $participant, $odds->getDparam1(), $odds->getOffers());
continue;
if ($isFractionAllowed($odds->getDparam1())) {
foreach ($this->getParticipants() as $participant) {
if ($participant->getId() === $odds->getIparam1()) {
$handicaps[] = new Handicap($this, $participant, $odds->getDparam1(), $odds->getOffers());
continue;
}
}
}
}

usort($handicaps, function (Handicap $a, Handicap $b) {
return $a->getHandicap() <=> $b->getHandicap();
});

return $handicaps;
}

Expand Down

0 comments on commit 3f2e9a0

Please sign in to comment.