예제 #1
0
 private function _loadDBSession()
 {
     $db_session = new Gamesession_delegate($this->id);
     $db_session->load();
     if (true === empty($db_session->id)) {
         ObjectHelper::shallowCopy($this, $db_session);
         $db_session->store();
         $this->id = $db_session->id;
         $this->_refreshSession();
     }
 }
예제 #2
0
파일: maze.php 프로젝트: GothamGazette/Maze
 /**
  * Serialize a room to JSON
  *
  * @param Room_delegate $room
  * @return RoomVO
  */
 private function _serializeRoom(&$room)
 {
     $this->load->helper('badge');
     $public_dir = Badge_helper::getPublicDirectoryPath();
     $room_vo = new RoomVO();
     ObjectHelper::shallowCopy($room, $room_vo);
     $question =& $this->current_room->getQuestion();
     if (false === empty($question)) {
         $question_vo = new QuestionVO();
         ObjectHelper::shallowCopy($question, $question_vo);
         $question_vo->completed = in_array($question->id, $this->gamesession->getCompletedQuestions());
         $responses =& $this->current_room->getResponses();
         foreach ($responses as $response) {
             $response_vo = new ResponseVO();
             ObjectHelper::shallowCopy($response, $response_vo);
             $filename = $public_dir . DIRECTORY_SEPARATOR . $response_vo->image;
             /**
              * Get image sizes to avoid issues in IE6
              */
             if (true === file_exists($filename)) {
                 $sizes = getimagesize($filename);
                 $response_vo->width = $sizes[0];
                 $response_vo->height = $sizes[1];
             }
             $response_vo->image = site_url($response_vo->image);
             $response_vo->image_hover = site_url($response_vo->image_hover);
             $question_vo->responses[] = $response_vo;
         }
         $room_vo->question = $question_vo;
     }
     $room_vo->image = site_url($room_vo->image);
     $room_vo->map_image = site_url($room_vo->map_image);
     foreach ($room_vo->navigation as $direction => $value) {
         $navigation_allowed = new AllowedNavigationVO();
         $navigation_allowed->allowed = $this->_isDirectionAllowed($this->gamesession->getCurrentOrientation(), $direction, &$room);
         if (true == $navigation_allowed->allowed) {
             switch ($direction) {
                 case 'left':
                 case 'right':
                     $navigation_allowed->message = 'Turn ' . $this->_getOrientationFromDirection($direction, $this->gamesession->getCurrentOrientation());
                     break;
                 case 'forward':
                     $navigation_allowed->message = 'Proceed ' . $this->_getOrientationFromDirection($direction, $this->gamesession->getCurrentOrientation());
                     break;
                 case 'back':
                     $navigation_allowed->message = 'Backtrack';
                     break;
             }
         }
         $room_vo->navigation[$direction] = $navigation_allowed;
         //$this->_isDirectionAllowed($this->gamesession->getCurrentOrientation(), $direction, &$room);
     }
     return $room_vo;
 }
예제 #3
0
 /**
  * Binds the table delegate to an associative array or object with keys or public attributes
  * that match the table delegates public attributes
  *
  * @access public
  * @param mixed $source		The source of the binding
  */
 function bind($source)
 {
     if (true === is_array($source)) {
         ArrayHelper::bindArrayToObject($source, $this, true);
     } else {
         if (true === is_object($source)) {
             ObjectHelper::shallowCopy($source, $this, true, true);
         }
     }
 }