public function getClosedByRoundForCricket()
{
$hits = Hit::join('game_user->user')->where(['game_user_id' => $this->id])->order('hits.id asc')->fetchAll();
$byRound = Arrays::groupBy($hits, Functions::extract()->round);
$closedInRound = [];
$closed = [15 => 0, 16 => 0, 17 => 0, 18 => 0, 19 => 0, 20 => 0, 25 => 0];
foreach ($byRound as $round => $hits) {
$closedInCurrentRound = 0;
foreach ($hits as $hit) {
if (isset($closed[$hit->field])) {
$closedField = min($hit->multiplier, 3 - $closed[$hit->field]);
$closedInCurrentRound += $closedField;
$closed[$hit->field] += $closedField;
}
}
$closedInRound[$round] = $closedInCurrentRound;
}
return $closedInRound;
}