Ejemplo n.º 1
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.º 2
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);
 }
Ejemplo n.º 3
0
 /**
  * Turn a lamp on and off
  *
  * @otas\command('turn_lamp_on');
  * @otas\command('turn_lamp_off');
  */
 function turn_lamp_on(Adventure $adventure, Scene $scene, array $command)
 {
     if ($command[2] == 'on') {
         if ($scene->objects['lamp']->vars['lit']) {
             $adventure->output('The lamp is already on');
         } else {
             $scene->objects['lamp']->vars['lit'] = true;
             $scene->lit = true;
             $adventure->output('You turn on the light. The room seems a lot less darker now. You notice a small piece of paper lying on the floor.');
         }
     }
     if ($command[2] == 'off') {
         if (!$scene->objects['lamp']->vars['lit']) {
             $adventure->output('The lamp is already off');
         } else {
             $scene->objects['lamp']->vars['lit'] = false;
             $scene->lit = false;
             $adventure->output('You turn off the light. Strangely enough, you can see less.');
         }
     }
 }
Ejemplo n.º 4
0
    function execute(Adventure $adventure, Scene $scene, array $args)
    {
        $help = <<<EOT
Generic actions:
  <info>help</info>                   <comment>Give help info</comment>
  <info>inventory</info>              <comment>Display all items in your inventory</comment>
  <info>look [around]</info>          <comment>Get detailed information about your surroundings</comment>
  <info>look [at [object]]</info>     <comment>View object details</comment>
  <info>pick up [object]</info>       <comment>Pick up object into inventory</comment>
  <info>drop [object]</info>          <comment>Drop object from inventory</comment>
  <info>go north | north | n</info>   <comment>Go north (or south, west, east)</comment>

Other actions are available too, just use your imagination to '<info>use key on chest</info>' or '<info>talk to stranger</info>'.

EOT;
        $adventure->output($help);
    }
Ejemplo n.º 5
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());
     }
 }