Пример #1
0
 public function testTryLetter()
 {
     $game = new Game(new Word('php'));
     $this->assertFalse($game->tryLetter('3'));
     $this->assertEquals(1, $game->getAttempts());
     $this->assertFalse($game->tryLetter('e'));
     $this->assertEquals(2, $game->getAttempts());
     $this->assertTrue($game->tryLetter('p'));
     $this->assertEquals(2, $game->getAttempts());
     $this->assertFalse($game->tryLetter('p'));
     $this->assertEquals(3, $game->getAttempts());
 }
Пример #2
0
 public function testIsHangedWithLetterTrial()
 {
     $game = new Game(new Word('filament'), 0, 5);
     $game->tryLetter('g');
     $this->assertFalse($game->isHanged());
     $game->tryLetter('h');
     $this->assertFalse($game->isHanged());
     $game->tryLetter('j');
     $this->assertFalse($game->isHanged());
     $game->tryLetter('k');
     $this->assertFalse($game->isHanged());
     $game->tryLetter('y');
     $this->assertTrue($game->isHanged());
 }
Пример #3
0
 /**
  * Save the current game
  *
  * @param Game $game
  */
 public function save(Game $game)
 {
     $data = $game->getContext();
     $this->storage->write($this->storage->getStorageName(), $data);
 }
Пример #4
0
 public function save(Game $game)
 {
     $data = $game->getContext();
     $this->storage->write('hangman', $data);
 }