public function setUp()
 {
     $faker = Factory::create();
     $this->playerId = PlayerId::create($faker->uuid);
     $this->gameId = MiniGameId::create($faker->uuid);
     $this->context = \Mockery::mock(Context::class);
 }
Exemple #2
0
 public function setUp()
 {
     $faker = Factory::create();
     $this->managedMove = new ManagedMove();
     $this->unmanagedMove = new UnmanagedMove();
     $this->playerId = PlayerId::create($faker->uuid);
     $this->serviceUnderTest = new Playable();
 }
Exemple #3
0
 /**
  * @test
  */
 public function itShouldAssertTwoIdWithTheSameUuidAreEqual()
 {
     $innerId = $this->faker->uuid;
     $id = PlayerId::create($innerId);
     $sameId = PlayerId::create($innerId);
     $this->assertTrue($id->equals($sameId));
     $this->assertTrue($sameId->equals($id));
     $otherInnerId = $this->faker->uuid;
     $otherId = PlayerId::create($otherInnerId);
     $this->assertFalse($id->equals($otherId));
     $this->assertFalse($otherId->equals($id));
 }
 public function setUp()
 {
     $faker = Factory::create();
     $this->gameId = MiniGameId::create($faker->uuid);
     $this->playerId = PlayerId::create($faker->uuid);
     $this->miniGame = $this->getMiniGame($this->gameId, $faker->name);
     $this->player = $this->getPlayer($this->playerId, $faker->name);
     $this->move = \Mockery::mock(Move::class);
     $this->options = $this->getGameOptions();
     $this->playerOptions = \Mockery::mock(PlayerOptions::class);
     $this->context = \Mockery::mock(Context::class);
     $this->gameBuilder = \Mockery::mock(MiniGameFactory::class);
     $this->gameManager = \Mockery::mock(GameRepository::class);
     $this->errorHandler = \Mockery::mock(ErrorEventHandler::class);
     $this->miniGameCommandHandler = new MiniGameCommandHandler($this->gameBuilder, $this->gameManager, $this->errorHandler);
 }
 public function getId()
 {
     return PlayerId::create(1);
 }
 public function setUp()
 {
     $faker = Factory::create();
     $this->playerId = PlayerId::create($faker->uuid);
     $this->gameId = MiniGameId::create($faker->uuid);
 }
Exemple #7
0
 /**
  * @param  Player $player
  * @return bool
  */
 public function equals(Player $player)
 {
     return $player instanceof HangmanPlayer && $this->id->equals($player->id);
 }
Exemple #8
0
 /**
  * Returns the next player in line
  *
  * @return PlayerId
  */
 private function getNextPlayerId()
 {
     if ($this->currentPlayer === null) {
         return null;
     }
     $nbPlayers = count($this->gameOrder);
     $currentPlayerId = (string) $this->currentPlayer->getId();
     $nextPlayerPosition = (array_search($currentPlayerId, $this->gameOrder) + 1) % $nbPlayers;
     $pos = $nextPlayerPosition;
     do {
         $id = PlayerId::create($this->gameOrder[$pos]);
         $player = $this->getPlayer($id);
         if ($player->getState() === HangmanPlayer::STATE_IN_GAME) {
             return $id;
         }
         $pos = ($pos + 1) % $nbPlayers;
     } while ($pos !== $nextPlayerPosition);
     return null;
 }
Exemple #9
0
 /**
  * @test
  */
 public function testPlayerOneLosesAlone()
 {
     $letter = 'Z';
     $playerId = PlayerId::create(42);
     $playerOne = HangmanPlayerOptions::create($playerId, $this->hangmanId, self::P1_NAME, 1);
     $hangman = Hangman::createGame($this->hangmanId, self::WORD);
     $hangman->addPlayerToGame($playerOne);
     $hangman->startGame($playerId);
     /* @var $feedback \Hangman\Result\HangmanLost */
     $feedback = $hangman->play($playerId, $this->getProposition($letter));
     $this->assertInstanceOf(HangmanGameLostEvent::class, $feedback);
     $this->assertEquals($playerId, $feedback->getPlayerId());
     $this->assertEquals(self::WORD, $feedback->getSolution());
     $this->assertFalse($hangman->canPlayerPlay($playerId));
 }