Esempio n. 1
0
 function look($words)
 {
     $words = $this->findSynonym($words);
     $obj = load(ROOMFILE, 'mirar', $words);
     // Si no hay un objeto en el lugar, busca en el inventario...
     if ($obj === NULL) {
         $inventory = new Inventory();
         return $inventory->look($words);
     }
     // ** Simple format
     if (is_string($obj)) {
         return array("mirar", $obj);
     }
     // ** Complex format
     // No hay restricciones
     if (!property_exists($obj, 'required')) {
         $this->check_optional_param($obj);
         return array("mirar", $obj->message);
     }
     // ¿Se cumplen las restricciones?
     $required = new Required();
     if ($required->check($obj->required)) {
         // Only first time
         if (!load(USERFILE, 'actions', $words . '_seen')) {
             $this->check_optional_param($obj);
             save(USERFILE, 'actions', $words . '_seen', "1");
         }
         return array("mirar", $obj->message);
     }
     // No se cumplen las restricciones
     if (property_exists($obj, 'excuse')) {
         return array("mirar", $obj->excuse);
     } else {
         return array("mirar", "FAIL");
     }
     // No hay excusa definida => objeto no encontrado
     return array("mirar", "FAIL");
 }