/** * Given a team ('A'/'B'), determines new team rating. * * @param string $team * @return float */ protected function getNewTeamRating($team) { $inputRatingFunction = 'getTeam' . $team . 'Rating'; if ($this->matchResult->getHigherTeam() == MatchResult::TEAMS_EQUAL) { // team's ranking points equal before game if ($this->matchResult->getResult() == MatchResult::DRAW) { // no change return $this->ratingsInput->{$inputRatingFunction}(); } if ($this->matchResult->getResult() == $team) { // this team wins and gets points increase return $this->ratingsInput->{$inputRatingFunction}() + $this->exchange->getExchangeAmount(); } // team lost return $this->ratingsInput->{$inputRatingFunction}() - $this->exchange->getExchangeAmount(); } if ($this->matchResult->getHigherTeam() == $team) { // team in question is higher ranked before game if ($this->matchResult->getResult() == $team) { // team won return $this->ratingsInput->{$inputRatingFunction}() + $this->exchange->getExchangeAmount(); } // team lost or drew, as they're higher ranked they lose points return $this->ratingsInput->{$inputRatingFunction}() - $this->exchange->getExchangeAmount(); } // if we get here we're dealing with lower-ranked team before game if ($this->matchResult->getResult() == $team || $this->matchResult->getResult() == MatchResult::DRAW) { // lower ranked team gains points from win or draw return $this->ratingsInput->{$inputRatingFunction}() + $this->exchange->getExchangeAmount(); } // lower ranked team lost return $this->ratingsInput->{$inputRatingFunction}() - $this->exchange->getExchangeAmount(); }