public function update($match, ParticipantRepository $teamRepository, ParticipantRepository $supportRepository = null) { $redTeamId = $match['red_team_id']; $blueTeamId = $match['blue_team_id']; $teamRatings = $teamRepository->getRating([$redTeamId, $blueTeamId]); $teams = [['id' => $redTeamId, 'old' => $teamRatings[$redTeamId], 'opponent' => $teamRatings[$blueTeamId], 'score' => $match['red_score'] > $match['blue_score'] ? 1 : 0], ['id' => $blueTeamId, 'old' => $teamRatings[$blueTeamId], 'opponent' => $teamRatings[$redTeamId], 'score' => $match['blue_score'] > $match['red_score'] ? 1 : 0]]; $this->saveRating($teams, $match['id'], $teamRepository); }
protected function saveRating($rows, $matchId, ParticipantRepository $participantRepository) { foreach ($rows as $row) { $commandRating = isset($row['command']) ? $row['command'] : null; $rating = $this->calculateRating($row['old'], $row['score'], $row['opponent'], $commandRating); $participantRepository->saveRating($row['id'], $rating); $this->saveLog($row['id'], $matchId, $rating); } }
public function update($match, ParticipantRepository $squadRepository, ParticipantRepository $supportRepository = null) { /** @var SquadRepository $squadRepository */ $redSquadId = $squadRepository->composeId($match['red_goalkeeper_id'], $match['red_forward_id']); $blueSquadId = $squadRepository->composeId($match['blue_goalkeeper_id'], $match['blue_forward_id']); $squadRatings = $squadRepository->getRating([$redSquadId, $blueSquadId]); $squads = [['id' => $redSquadId, 'old' => $squadRatings[$redSquadId], 'opponent' => $squadRatings[$blueSquadId], 'score' => $match['red_score'] > $match['blue_score'] ? 1 : 0], ['id' => $blueSquadId, 'old' => $squadRatings[$blueSquadId], 'opponent' => $squadRatings[$redSquadId], 'score' => $match['blue_score'] > $match['red_score'] ? 1 : 0]]; $this->saveRating($squads, $match['id'], $squadRepository); }
public function update($match, ParticipantRepository $playerRepository, ParticipantRepository $teamRepository = null) { $redGId = $match['red_goalkeeper_id']; $redFId = $match['red_forward_id']; $blueGId = $match['blue_goalkeeper_id']; $blueFId = $match['blue_forward_id']; $redTeamId = $match['red_team_id']; $blueTeamId = $match['blue_team_id']; $playerRatings = $playerRepository->getRating([$redGId, $redFId, $blueGId, $blueFId]); $teamRatings = $teamRepository->getRating([$redTeamId, $blueTeamId]); $players = [['id' => $redGId, 'old' => $playerRatings[$redGId], 'opponent' => $teamRatings[$blueTeamId], 'command' => $teamRatings[$redTeamId], 'score' => $match['red_score'] > $match['blue_score'] ? 1 : 0], ['id' => $redFId, 'old' => $playerRatings[$redFId], 'opponent' => $teamRatings[$blueTeamId], 'command' => $teamRatings[$redTeamId], 'score' => $match['red_score'] > $match['blue_score'] ? 1 : 0], ['id' => $blueGId, 'old' => $playerRatings[$blueGId], 'opponent' => $teamRatings[$redTeamId], 'command' => $teamRatings[$blueTeamId], 'score' => $match['blue_score'] > $match['red_score'] ? 1 : 0], ['id' => $blueFId, 'old' => $playerRatings[$blueFId], 'opponent' => $teamRatings[$redTeamId], 'command' => $teamRatings[$blueTeamId], 'score' => $match['blue_score'] > $match['red_score'] ? 1 : 0]]; $this->saveRating($players, $match['id'], $playerRepository); }