/** * @param AbstractTournament $tournament * @param PlannedMatch $plannedMatch * * @return MatchForm */ public function getMatchForm(AbstractTournament $tournament, PlannedMatch $plannedMatch = null) { $gamesPerMatch = $tournament->getMinimumNumberOfGames(); if ($tournament->getTeamType() == $tournament::TYPE_SINGLE) { $form = new MatchFormSingle($this->playerRepository, $gamesPerMatch, $tournament->getMaxScore()); } else { if ($plannedMatch == null) { $form = new MatchFormDouble($this->playerRepository, $gamesPerMatch, $tournament->getMaxScore(), $tournament->getPlayers()); } else { $form = new MatchFormDouble($this->playerRepository, $gamesPerMatch, $tournament->getMaxScore(), array()); $form->setTeamOne($plannedMatch->getTeam1()); $form->setTeamTwo($plannedMatch->getTeam2()); } } return $form; }
/** * @param PlannedMatch $plannedMatch * @param Match $match */ public function matchPlayed(Match $match, PlannedMatch $plannedMatch = null) { $plannedMatch->matchPlayed($match); $winner = $plannedMatch->getTeam($match->getWinner() - 1); if ($plannedMatch->isFinal()) { $this->winner = $winner; $second = $plannedMatch->getTeam($match->getLooser() - 1); $this->second = $second; $this->end = new \DateTime(); } else { $plannedMatch->getMatchForWinner()->setTeam($winner, $plannedMatch->getMatchIndexForWinner()); } }
public function testIsNotFinal() { $match = $this->getMock('Application\\Model\\Entity\\PlannedMatch'); $this->plannedMatch->winnerPlaysInMatchAt($match, 1); $this->assertFalse($this->plannedMatch->isFinal()); }