Beispiel #1
0
 public function testSetGetSeed()
 {
     $seed = RoundSetupSeed::create([[1, 2]]);
     $setup = new TournamentSetup();
     $setup->setSeed($seed);
     $this->assertEquals($seed, $setup->getSeed());
 }
Beispiel #2
0
 public function testSetGetLegMode()
 {
     $seed = RoundSetupSeed::create([[1, 2]]);
     $this->assertNull($seed->getLegMode());
     $mode = new LegMode(LegMode::DOUBLE_OUT_301);
     $seed->setLegMode($mode);
     $this->assertEquals($mode, $seed->getLegMode());
 }
Beispiel #3
0
 public static function create($playerIdByGroup)
 {
     $setup = new TournamentSetup();
     $seed = RoundSetupSeed::create($playerIdByGroup);
     // create seed with n groups
     $seed->setAdvance(-1);
     // seed defaults to advance -1
     $setup->setSeed($seed);
     $groupRound = RoundSetupAva::createStraight();
     // create an AvA round with straight input
     $groupRound->setAdvance(2);
     // each group, best 2 advance
     $groupRound->setGameMode(new GameMode(GameMode::FIRST_TO, 3));
     $groupRound->setLegMode(new LegMode(LegMode::SINGLE_OUT_301));
     $setup->addRound($groupRound);
     // adding bottom first walking upwards
     $crisCrossRound = RoundSetupAva::createStep(1);
     // create an AvA round with step-1 input
     $crisCrossRound->setAdvance(1);
     $crisCrossRound->setGameMode(new GameMode(GameMode::FIRST_TO, 3));
     $crisCrossRound->setLegMode(new LegMode(LegMode::SINGLE_OUT_301));
     $setup->addRound($crisCrossRound);
     $xRound = RoundSetupAva::createReduce();
     // create an AvA round with reduce input
     $xRound->setAdvance(2);
     $xRound->setGameMode(new GameMode(GameMode::FIRST_TO, 3));
     $xRound->setLegMode(new LegMode(LegMode::SINGLE_OUT_301));
     $setup->addRound($xRound);
     $yRound = RoundSetupAva::createSamePlace();
     // create an AvA round with same-place input
     $yRound->setAdvance(2);
     $yRound->setGameMode(new GameMode(GameMode::FIRST_TO, 3));
     $yRound->setLegMode(new LegMode(LegMode::SINGLE_OUT_301));
     $setup->addRound($yRound);
     $zRound = RoundSetupNull::createStack();
     // create an Null round with stack input
     $zRound->setAdvance(-1);
     // null defaults to advance -1
     $setup->addRound($zRound);
     return $setup;
 }
 /**
  * {@inheritDoc}
  */
 public function load(ObjectManager $manager)
 {
     /** @var Board[] $boards */
     $boards = array($this->getReference('board-0'));
     /** @var Player[] $players */
     $players = array($this->getReference('player-0'), $this->getReference('player-1'), $this->getReference('player-2'));
     $tournamentSetup = new TournamentSetup();
     $tournamentSetup->setSeed(RoundSetupSeed::create([[$players[0]->getId(), $players[1]->getId(), $players[2]->getId()]]));
     $round1 = RoundSetupAva::createStraight();
     $round1->setGameMode(new GameMode(GameMode::FIRST_TO, 1));
     $round1->setLegMode(new LegMode(LegMode::SINGLE_OUT_301));
     $tournamentSetup->addRound($round1);
     $tournament = new Tournament();
     $tournament->setName('real simple');
     $tournament->setSetup($tournamentSetup);
     $tournament->setBoards($boards);
     $tournament->setPlayers($players);
     $this->setReference('tournament-0', $tournament);
     $manager->persist($tournament);
     $manager->flush();
 }
 protected function getRealSimpleTournament()
 {
     /** @var Board[] $boards */
     $boards = array($this->fixtures->getReference('board-0'));
     /** @var Player[] $players */
     $players = array($this->fixtures->getReference('player-0'), $this->fixtures->getReference('player-1'), $this->fixtures->getReference('player-2'));
     $tournamentSetup = new TournamentSetup();
     $tournamentSetup->setSeed(RoundSetupSeed::create([[$players[0]->getId(), $players[1]->getId(), $players[2]->getId()]]));
     $round1 = RoundSetupAva::createStraight();
     $round1->setGameMode(new GameMode(GameMode::FIRST_TO, 3));
     $round1->setLegMode(new LegMode(LegMode::SINGLE_OUT_301));
     $tournamentSetup->addRound($round1);
     $tournament = new Tournament();
     $tournament->setName('real simple');
     $tournament->setSetup($tournamentSetup);
     $tournament->setBoards($boards);
     $tournament->setPlayers($players);
     /** @var \Doctrine\ORM\EntityManager $entityManager */
     $entityManager = $this->getContainer()->get('doctrine.orm.default_entity_manager');
     $entityManager->persist($tournament);
     return $tournament;
 }
Beispiel #6
0
 public function testFullTournament()
 {
     $setup = new TournamentSetup();
     $seed = RoundSetupSeed::create(4);
     // create seed with 4 groups
     $seed->setAdvance(-1);
     // seed defaults to advance -1
     $setup->setSeed($seed);
     $groupRound = RoundSetupAva::createStraight();
     // create an AvA round with straight input
     $groupRound->setAdvance(4);
     // each group, best 4 advance
     $setup->addRound($groupRound);
     // adding bottom first walking upwards
     $knockOutRound = RoundSetupBvw::createStep(1);
     // create an BvW round with step-1 input
     $knockOutRound->setAdvance(2);
     // each group, best 2 advance
     $setup->addRound($knockOutRound);
     $crisCrossRound = RoundSetupAva::createStep(2);
     // create an AvA round with step-2 input
     $crisCrossRound->setAdvance(1);
     $setup->addRound($crisCrossRound);
     $xRound = RoundSetupAva::createReduce();
     // create an AvA round with reduce input
     $xRound->setAdvance(2);
     $setup->addRound($xRound);
     $yRound = RoundSetupAva::createSamePlace();
     // create an AvA round with same-place input
     $yRound->setAdvance(2);
     $setup->addRound($yRound);
     $zRound = RoundSetupNull::createStack();
     // create an Null round with stack input
     $zRound->setAdvance(-1);
     // null defaults to advance -1
     $setup->addRound($zRound);
 }