Ejemplo n.º 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());
 }
Ejemplo n.º 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());
 }
Ejemplo n.º 3
0
 /**
  * Save the current game
  *
  * @param Game $game
  */
 public function save(Game $game)
 {
     $data = $game->getContext();
     $this->storage->write($this->storage->getStorageName(), $data);
 }
Ejemplo n.º 4
0
 public function save(Game $game)
 {
     $data = $game->getContext();
     $this->storage->write('hangman', $data);
 }