/**
  * This is an unique obstacle in a area. We will check if here is any drops for the character...
  */
 function view($id = null)
 {
     if (isset($id) && !empty($id)) {
         $AreasObstacle = $this->AreasObstacle->find('first', array('conditions' => array('AreasObstacle.id' => $id)));
         // Kijken of deze items geloot mogen worden...
         App::import('Model', 'Drop');
         $Drop = new Drop();
         foreach ($AreasObstacle['Item'] as $index => $item) {
             if (!$Drop->canLoot($this->characterInfo, $item['AreasObstaclesItem']['id'])) {
                 unset($AreasObstacle['Item'][$index]);
             }
         }
         // Kijken voor questen om in te leveren
         App::import('Model', 'Quest');
         $Quest = new Quest();
         foreach ($AreasObstacle['Quest'] as $index => $quest) {
             if (!$Quest->canView($this->characterInfo['Character']['id'], $quest['id'], $quest['ActionsObstacle']['type'])) {
                 unset($AreasObstacle['Quest'][$index]);
             }
         }
         $this->set('AreasObstacle', $AreasObstacle);
     } else {
         $this->render(false);
     }
 }
示例#2
0
 /**
  * Get actions for a specific area
  *
  * @param int $character_id the ID of the character
  * @param int $area_id the ID of the current location of the character
  * @return array a list of available actions
  */
 function getActions($character_id = null, $area_id = null)
 {
     if (!isset($area_id) || !isset($character_id)) {
         return array();
     }
     $actions = array();
     App::import('Model', 'Drop');
     $Drop = new Drop();
     App::import('Model', 'Quest');
     $Quest = new Quest();
     $this->contain(array('AreasObstacle' => array('Item', 'Quest'), 'Npc', 'AreasMob' => array('Mob')));
     $areaInfo = $this->find('first', array('conditions' => array('Area.id' => $area_id)));
     if ($areaInfo['Area']['travel_to'] != 0) {
         if ($this->canMove($area_id, $areaInfo['Area']['travel_to'], $character_id)) {
             $areaTo = $this->find('first', array('conditions' => array('Area.id' => $areaInfo['Area']['travel_to'])));
             $actions[] = array('type' => 'Area', 'data' => $areaTo);
         }
     }
     // Doorlopen van de Obstacles, en kijken of er iets te halen valt...
     foreach ($areaInfo['AreasObstacle'] as $index => $obstacle) {
         // Looting items
         if (!empty($obstacle['Item'])) {
             foreach ($obstacle['Item'] as $item) {
                 if ($Drop->canLoot($item['AreasObstaclesItem']['id'], $character_id, $area_id)) {
                     $actions[] = array('type' => 'Item', 'data' => $item);
                 }
             }
         }
         // Quest inleveren of ophalen
         if (!empty($obstacle['Quest'])) {
             foreach ($obstacle['Quest'] as $quest) {
                 if ($Quest->canView($character_id, $quest['id'], $quest['ActionsObstacle']['type'])) {
                     $actions[] = array('type' => 'Quest', 'data' => $quest);
                 }
             }
         }
     }
     // Talking to npcs
     if (!empty($areaInfo['Npc'])) {
         foreach ($areaInfo['Npc'] as $npc) {
             $actions[] = array('type' => 'Npc', 'data' => $npc);
         }
     }
     // Killing mobs
     if (!empty($areaInfo['AreasMob'])) {
         foreach ($areaInfo['AreasMob'] as $index => $mob) {
             if ($this->AreasMob->canAttack($mob['id'], $character_id, $area_id)) {
                 $actions[] = array('type' => 'Mob', 'data' => $mob);
             }
         }
     }
     return $actions;
 }