Ejemplo n.º 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());
     }
 }
Ejemplo n.º 2
0
 /**
  * Returns an action alias map from the generic commands, plus the commands from the current scene
  *
  * @return array
  */
 protected function getActionAliasMap()
 {
     // Generic aliases
     $aliases = $this->adventure->getActionAliasMap();
     // Merge with current scene aliases
     $aliases = array_merge($aliases, $this->adventure->getState()->getScene()->getActionAliasMap());
     return $aliases;
 }
Ejemplo n.º 3
0
 function execute(Adventure $adventure, Scene $scene, array $args)
 {
     $inv = $adventure->getState()->getInventory();
     if (count($inv) == 0) {
         $adventure->output("You don't carry anything with you.");
         return;
     }
     $adventure->output(sprintf("You carry %d item(s) in your inventory:\n", count($inv)));
     foreach ($inv as $object) {
         $adventure->output(sprintf(" *  <info>%s</info> : %s\n", $object->getName(), $object->getSummary()));
     }
 }
Ejemplo n.º 4
0
Archivo: Go.php Proyecto: 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);
 }