public function run()
 {
     $boolStatus = true;
     foreach ($this->conditions->states->eq as $strStateName => $mixedValue) {
         if (false === $this->stateList->hasState($strStateName) || $mixedValue !== $this->stateList->getState($strStateName)) {
             $boolStatus = false;
             break;
         }
     }
     foreach ($this->conditions->states->gt as $strStateName => $mixedValue) {
         if (false === $this->stateList->hasState($strStateName) || $mixedValue >= $this->stateList->getState($strStateName)) {
             $boolStatus = false;
             break;
         }
     }
     foreach ($this->conditions->states->lt as $strStateName => $mixedValue) {
         if (false === $this->stateList->hasState($strStateName) || $mixedValue <= $this->stateList->getState($strStateName)) {
             $boolStatus = false;
             break;
         }
     }
     foreach ($this->conditions->states->ne as $strStateName => $mixedValue) {
         if (false === $this->stateList->hasState($strStateName) || $mixedValue === $this->stateList->getState($strStateName)) {
             $boolStatus = false;
             break;
         }
     }
     foreach ($this->conditions->inventory->has as $strItemId) {
         if (false === $this->inventory->hasItem($strItemId)) {
             $boolStatus = false;
             break;
         }
     }
     foreach ($this->conditions->inventory->hasNot as $strItemId) {
         if (true === $this->inventory->hasItem($strItemId)) {
             $boolStatus = false;
             break;
         }
     }
     return $boolStatus;
 }
Exemple #2
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;
 }