예제 #1
0
 public function runGame($post, $dbsettings)
 {
     $this->processInput($post);
     switch ($this->state) {
         case CDiceGame100::$enterPlayers:
             echo CDiceGameMenus::chosePlayersMenu();
             break;
         case CDiceGame100::$enterNames:
             echo CDiceGameMenus::enterNamesForHumansMenu($this->humans);
             break;
         case CDiceGame100::$gameRunning:
             echo CDiceGameMenus::gameBoard($this, false, $dbsettings);
             break;
         case CDiceGame100::$haveWinner:
             echo CDiceGameMenus::gameBoard($this, true, $dbsettings);
             break;
     }
 }
예제 #2
0
파일: dicegame.php 프로젝트: bthurvi/oophp
<?php

//restart game
if (isset($_POST['restart']) && $_POST['restart'] == "starta ett nytt spel") {
    unset($_SESSION['game']);
}
//new game, continue old, restart or run the game
if (!isset($_SESSION['game'])) {
    echo "<h1>Startar ny spelomgång</h1>";
    $_SESSION['game'] = new CDiceGame100();
    $theGame = $_SESSION['game'];
} else {
    if (isset($_SESSION['game']) && (isset($_POST['cont']) && $_POST['cont'] == "fortsätta spela")) {
        $theGame = $_SESSION['game'];
    } else {
        if (isset($_SESSION['game']) && !isset($_POST['game-on'])) {
            echo CDiceGameMenus::restartMenu();
        }
    }
}
//if we got a instance - run the game
if (isset($theGame)) {
    $theGame->runGame($_POST);
}