Example #1
0
 public function testSetTeam()
 {
     $team = new Team();
     $this->player->setTeam($team);
     $this->assertEquals($team, $this->player->getTeam());
     $this->assertContains($this->player, $team->getPlayers());
 }
 public function testScorer()
 {
     $league = new League();
     $team1 = new Team();
     $team1->setId(1);
     $league->addTeam($team1);
     $player1 = new Player();
     $player1->setId(1);
     $player1->setTeam($team1);
     $team2 = new Team();
     $team2->setId(2);
     $league->addTeam($team2);
     $player2 = new Player();
     $player2->setId(2);
     $player2->setTeam($team2);
     $fixture = new Fixture();
     $fixture->setTeamHome($team1);
     $fixture->setTeamAway($team2);
     $league->addFixture($fixture);
     $fixture->addEvent(Event::createGoal($fixture, $team1, $player1, 1));
     $fixture->addEvent(Event::createGoal($fixture, $team1, $player1, 2));
     $fixture->addEvent(Event::createGoal($fixture, $team2, $player2, 3));
     $scorer = $this->leagueService->getScorer(array($fixture));
     $this->assertEquals($player1, $scorer[0]->getPlayer());
     $this->assertEquals($player2, $scorer[1]->getPlayer());
     $this->assertEquals(2, $scorer[0]->getGoals());
     $this->assertEquals(1, $scorer[1]->getGoals());
 }
 /**
  * @param UserEvent $event
  */
 public function onRegister(UserEvent $event)
 {
     /** @var User $user */
     $user = $event->getUser();
     $player = new Player();
     $player->setName($user->getUsername());
     $player->setSkillDefense(rand(1, 100));
     $player->setSkillOffense(rand(1, 100));
     /** @var Team[] $teams */
     $teams = $this->entityManager->getRepository('CoreBundle:Team')->findAll();
     $player->setTeam($teams[rand(0, count($teams) - 1)]);
     $this->entityManager->persist($player);
     $user->setPlayer($player);
     $this->entityManager->flush();
 }
Example #4
0
 /**
  * @param GameDate $gameDate
  *
  * @return Transfer
  */
 public function execute(GameDate $gameDate)
 {
     $this->targetTeam->sendMoney($this->originTeam, $this->amount);
     $this->player->setTeam($this->targetTeam);
     return Transfer::createFromOffer($this, $gameDate);
 }
Example #5
0
 public function testCreateTransferOffer()
 {
     $originTeam = new Team();
     $targetTeam = new Team();
     $this->manager->setTeam($targetTeam);
     $player = new Player();
     $player->setSkillDefense(10);
     $player->setSkillOffense(10);
     $player->setTeam($originTeam);
     $transferOffer = $this->manager->createTransferOffer($player);
     $this->assertEquals($originTeam, $transferOffer->getOriginTeam());
     $this->assertEquals($targetTeam, $transferOffer->getTargetTeam());
     $this->assertEquals($player, $transferOffer->getPlayer());
     $this->assertEquals(100, $transferOffer->getAmount());
 }