Beispiel #1
0
 /**
  * Calculates rating points exchange between teams and returns it.
  *
  * @return float the points exchange
  * @throws InvalidMatchResultException if cannot determine match result
  */
 public function calculate()
 {
     $base = $this->ratingsGap / Calculate::MAX_RATINGS_GAP;
     if ($this->matchResult->isUnderdogWin() || $this->matchResult->equalsWin()) {
         $this->exchangeAmount = 1 + $base;
         $this->applyWeightings();
         return $this->exchangeAmount;
     }
     if ($this->matchResult->isHigherTeamWin()) {
         $this->exchangeAmount = 1 - $base;
         $this->applyWeightings();
         return $this->exchangeAmount;
     }
     if ($this->matchResult->getResult() == MatchResult::DRAW) {
         $this->exchangeAmount = $base;
         $this->applyWeightings();
         return $this->exchangeAmount;
     }
     throw new InvalidMatchResultException('Cannot calculate exchange: Invalid MatchResult Type');
 }