示例#1
0
文件: Look.php 项目: jaytaph/otas
 function execute(Adventure $adventure, Scene $scene, array $args)
 {
     if (count($args) <= 1) {
         $adventure->output("Look at what?");
         return;
     }
     if ($args[1] == 'around') {
         // Look around
         $adventure->output("<question>" . $adventure->getState()->getScene()->getTitle() . "</question>\n");
         $adventure->output("\n");
         $adventure->output($adventure->getState()->getScene()->getDescription() . "\n");
         $adventure->output("\n");
         $exits = $adventure->getState()->getScene()->getExits();
         $str = join(", ", $adventure->getState()->getScene()->getExits()->getKeys());
         if (count($exits) == 1) {
             $adventure->output("There is " . count($exits) . " exit to the " . $str . ".\n");
         } else {
             $adventure->output("There are " . count($exits) . " exits: " . $str . "\n");
         }
         $adventure->output("\n");
     } else {
         //Look at object
         $object = $scene->getObject($args[1]);
         if (!$object) {
             $adventure->output("There is no " . $args[1] . " to look at.");
         }
         $adventure->output("You look at " . $object->getName());
         $adventure->output($object->getDescription());
     }
 }