/** * @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; }
/** * Creates a new match * * @param AbstractTournament $tournament * @param Player $player1 * @param Player $player2 * * @return Match */ public function getNew(AbstractTournament $tournament, $player1 = null, $player2 = null) { if ($tournament->getTeamType() == $tournament::TYPE_SINGLE) { $match = new SingleMatch(); $match->setPlayer1($player1); $match->setPlayer2($player2); } else { $match = new DoubleMatch(); } $gamesPerMatch = $tournament->getMinimumNumberOfGames(); for ($i = 0; $i < $gamesPerMatch; $i++) { $match->addGame(new Game()); } $match->setDate(new \DateTime()); $match->setTournament($tournament); return $match; }