Beispiel #1
0
 public function renderGame($user, GameView $gameView, $cellNumbers)
 {
     ?>
     <!DOCTYPE html>
     <html>
         <head>
             <meta charset="utf-8">
             <title>The 15 Puzzle</title>
         </head>
         <body>
             <h1>The 15 Puzzle</h1>
             <?php 
     echo "<h2>" . $user . "</h2>";
     ?>
             <div class="container" >
                 <?php 
     echo $gameView->createGameTable();
     ?>
             </div>
             <div>
                 <em>This site uses cookies to improve user experience. By continuing to browse the site you are agreeing to our use of cookies.</em>
             </div>
         </body>
     </html>
     <?php 
 }
Beispiel #2
0
 public static function showAll()
 {
     $_SESSION['headertitle'] = "Games";
     $_SESSION['styles'] = array('jumbotron.css', 'games.css');
     MasterView::showHeader();
     MasterView::showNav();
     GameView::showAllDetails();
     MasterView::showFooter(null);
     MasterView::showPageEnd();
 }
 public static function run()
 {
     $action = array_key_exists('action', $_SESSION) ? $_SESSION['action'] : "";
     $arguments = $_SESSION['arguments'];
     switch ($action) {
         case "all":
             $_SESSION['games'] = GameDB::getAllGamesDesc();
             GameView::showAll();
             break;
         default:
     }
 }
Beispiel #4
0
 /**
  * Main method for handling user input. If a letter hyperlink is pressed, the input is evaluated.
  * If the input is correct a guess is performed. Upon exception - an error message is generated by the 
  * GameView. There is a check after each guess about the status of guesses. 
  * @return void
  */
 public function doPlay()
 {
     $userGuess = $this->view->getInput();
     try {
         $this->game->doGuess($userGuess);
     } catch (InvalidArgumentException $iea) {
         $this->view->setMessageBadChar();
     } catch (Exception $e) {
         $this->view->setMessageDublicate();
     }
     if ($this->game->isOver()) {
         $this->view->setMessageLose();
     } else {
         if ($this->game->isWon()) {
             $this->view->setMessageWin();
         }
     }
 }