Ejemplo n.º 1
0
 /**
  * Start
  * 
  * @return \rvilbrandt\gamebook\Model\GameState Game state
  * 
  * @throws Parser\SceneNotFoundException
  */
 public function run()
 {
     $gamebook = new Gamebook($this->loader->load());
     $currentScene = $gamebook->fetchScene(true === isset($this->strCurrentSceneId) ? $this->strCurrentSceneId : $gamebook->startScene);
     if (false === isset($currentScene)) {
         throw new Parser\SceneNotFoundException("Scene-ID is not valid: " . $this->strCurrentSceneId);
     }
     foreach ($currentScene->inventory->add as $strItemId) {
         $this->inventory->addItem($strItemId, $gamebook->fetchItem($strItemId));
     }
     foreach ($currentScene->inventory->remove as $strItemId) {
         $this->inventory->removeItem($strItemId);
     }
     foreach ($currentScene->states as $strStateName => $mixedValue) {
         $this->stateList->setState($strStateName, $mixedValue);
     }
     $gameState = new Model\GameState();
     $gameState->inventory = $this->inventory;
     $gameState->stateList = $this->stateList;
     $gameState->scene = $currentScene;
     return $gameState;
 }