Example #1
0
 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());
     }
 }
Example #2
0
File: Go.php Project: jaytaph/otas
 function execute(Adventure $adventure, Scene $scene, array $args)
 {
     if (count($args) <= 1) {
         $adventure->output("Where to?");
         return;
     }
     $direction = $args[1];
     if (!$scene->getExits()->containsKey($direction)) {
         $adventure->output('Cannot go ' . $direction);
         return;
     }
     $key = $scene->getExits()->get($direction);
     $newScene = $adventure->getScene($key);
     $adventure->getState()->setScene($newScene);
     list($action, $args) = $adventure->parse("look around");
     $action->execute($adventure, $adventure->getState()->getScene(), $args);
 }