Your browser must have JavaScript enabled in order to view this page.
 >  >
 
Welcome Guest#215 Login/register    Go to Bottom
Go to Top

Source for file DpLiving.php

Documentation is available at DpLiving.php

  1. <?php
  2. /**
  3.  * An object which is "alive", common code shared between users and NPCs
  4.  *
  5.  * DutchPIPE version 0.4; PHP version 5
  6.  *
  7.  * LICENSE: This source file is subject to version 1.0 of the DutchPIPE license.
  8.  * If you did not receive a copy of the DutchPIPE license, you can obtain one at
  9.  * http://dutchpipe.org/license/1_0.txt or by sending a note to
  10.  * license@dutchpipe.org, in which case you will be mailed a copy immediately.
  11.  *
  12.  * @package    DutchPIPE
  13.  * @subpackage dpuniverse_std
  14.  * @author     Lennert Stock <ls@dutchpipe.org>
  15.  * @copyright  2006, 2007 Lennert Stock
  16.  * @license    http://dutchpipe.org/license/1_0.txt  DutchPIPE License
  17.  * @version    Subversion: $Id: DpLiving.php 311 2007-09-03 12:48:09Z ls $
  18.  * @link       http://dutchpipe.org/manual/package/DutchPIPE
  19.  * @see        DpObject
  20.  */
  21.  
  22. /**
  23.  * Builts upon the standard DpObject class
  24.  */
  25. inherit(DPUNIVERSE_STD_PATH 'DpObject.php');
  26.  
  27. /**
  28.  * An object which is "alive", common code shared between users and NPCs
  29.  *
  30.  * Creates the following DutchPIPE properties:<br />
  31.  *
  32.  * - boolean <b>isLiving</b> - Set to TRUE
  33.  * - string <b>displayMode</b> - "graphical" or "abstract"
  34.  * - integer <b>sessionAge</b> - Age in seconds of this object
  35.  * - integer <b>weightCarry</b> - Combined weight of objects in our inventory
  36.  * - integer <b>maxWeightCarry</b> - Maximum weight this object can carry
  37.  * - integer <b>volumeCarry</b> - Combined volume of objects in our inventory
  38.  * - integer <b>maxVolumeCarry</b> - Maximum volume this object can carry
  39.  * - string <b>actionFailure</b> - Last action error message, "Read what?"
  40.  * - string <b>actionDefaultFailure</b> - Default action error message, "What?"
  41.  * - int <b>lastActionTime</b> - UNIX time stamp of last action performed
  42.  * - string <b>inputMode</b> - Input area mode, 'say' or 'cmd'
  43.  *
  44.  * @package    DutchPIPE
  45.  * @subpackage dpuniverse_std
  46.  * @author     Lennert Stock <ls@dutchpipe.org>
  47.  * @copyright  2006, 2007 Lennert Stock
  48.  * @license    http://dutchpipe.org/license/1_0.txt  DutchPIPE License
  49.  * @version    Release: 0.2.1
  50.  * @link       http://dutchpipe.org/manual/package/DutchPIPE
  51.  * @see        DpObject
  52.  */
  53. class DpLiving extends DpObject
  54. {
  55.     /**
  56.      * Creates this living object
  57.      *
  58.      * Called by DpObject when this object is created. Adds standard actions
  59.      * which can be performed by this object, usually a user or a computer
  60.      * controlled character.
  61.      *
  62.      * Calls {@link createDpLiving()} in the inheriting class.
  63.      *
  64.      * Starts a "heartbeat", see {@link timeoutHeartBeat()}.
  65.      *
  66.      * @access     private
  67.      * @see        createDpLiving(), timeoutHeartBeat()
  68.      */
  69.     final function createDpObject()
  70.     {
  71.         $this->isLiving new_dp_property(TRUE);
  72.         $this->displayMode new_dp_property('graphical');
  73.         $this->sessionAge new_dp_property(0FALSE);
  74.         $this->inputMode new_dp_property('cmd');
  75.         $this->isDraggable FALSE;
  76.  
  77.         if (WEIGHT_TYPE_NONE !== WEIGHT_TYPE{
  78.             $this->weightCarry new_dp_property(0FALSE);
  79.  
  80.             $this->coinherit(DPUNIVERSE_STD_PATH 'mass.php');
  81.             if (WEIGHT_TYPE_ABSTRACT === WEIGHT_TYPE{
  82.                 $this->weight 7;
  83.                 $this->maxWeightCarry new_dp_property(7);
  84.             elseif (WEIGHT_TYPE_METRIC === WEIGHT_TYPE{
  85.                 $this->weight 70000/* Grams */
  86.                 $this->maxWeightCarry new_dp_property(30000);
  87.             elseif (WEIGHT_TYPE_USA === WEIGHT_TYPE{
  88.                 $this->weight 2458/* Ounces */
  89.                 $this->maxWeightCarry new_dp_property(1054);
  90.             }
  91.         }
  92.  
  93.         if (VOLUME_TYPE_NONE !== VOLUME_TYPE{
  94.             $this->volumeCarry new_dp_property(0FALSE);
  95.  
  96.             $this->coinherit(DPUNIVERSE_STD_PATH 'mass.php');
  97.             if (VOLUME_TYPE_ABSTRACT === VOLUME_TYPE{
  98.                 $this->volume 7;
  99.                 $this->maxVolumeCarry new_dp_property(5);
  100.             elseif (VOLUME_TYPE_METRIC === VOLUME_TYPE{
  101.                 $this->volume 70000;
  102.                 $this->maxVolumeCarry new_dp_property(30000);
  103.             elseif (VOLUME_TYPE_USA === VOLUME_TYPE{
  104.                 $this->volume 2458;
  105.                 $this->maxVolumeCarry new_dp_property(1054);
  106.             }
  107.         }
  108.  
  109.         /**
  110.          * Sets the message shown to the user when an action fails
  111.          *
  112.          * Call this method from action methods, for example actionFoo(). When the
  113.          * user performs an action but the action fails, there are two ways for the
  114.          * method implementing the action to communicate the failure to the user.
  115.          *
  116.          * <ol>
  117.          * <li>
  118.          * Call {@link DpUser:tell()} in the user and return TRUE, for
  119.          * example:<br><br>
  120.          * <code>
  121.          *$user->tell('Action foo failed because of bar.');
  122.          *return TRUE;
  123.          * </code>
  124.          * <br>
  125.          * The action system will stop looking for other ways to perform the
  126.          * action.<br><br>
  127.          * </li>
  128.          * <li>
  129.          * Call this setActionFailure method in the user and return FALSE. This
  130.          * failure setup is used when different objects can have the same actions
  131.          * implemented with addAction - if one fails, another might still
  132.          * succeed. Example:<br><br>
  133.          * <code>
  134.          *$user->setActionFailure('Action foo failed because of bar.');
  135.          *return FALSE;
  136.          * </code>
  137.          * <br>
  138.          * The action system will continue looking for other ways to perform
  139.          * the action. If it doesn't find any, the previously set failure message
  140.          * is communicated to the user. Otherwise, the next method implementing
  141.          * the action takes over. The action system will continue looking for
  142.          * object/methods implementing the action, until TRUE is returned or no
  143.          * more implementations are found. In that case, the last set action
  144.          * failure is returned. If no action failure was set, the default failure
  145.          * message is shown, see {@link setActionDefaultFailure()}.
  146.          * </li>
  147.          * </ol>
  148.          *
  149.          * @param   string  $actionFailure message to be shown when an action fails
  150.          * @example /websites/dutchpipe.org/dpuniverse/obj/note.php A readable note
  151.          * @see     getActionFailure(), setActionDefaultFailure(),
  152.          *          getActionDefaultFailure()
  153.          */
  154.         $this->actionFailure new_dp_property(DPUNIVERSE_ACTION_DEFAULT_FAILURE);
  155.  
  156.  
  157.         /**
  158.          * Sets the default message shown to the user when an action fails
  159.          *
  160.          * Used when no message was set with setActionFailure, for example "What?".
  161.          *
  162.          * @param   string  $actionDefaultFailure default message to be shown when
  163.          *                                        an action fails
  164.          * @see     setActionFailure(), getActionFailure(),
  165.          *          getActionDefaultFailure()
  166.          */
  167.         $this->actionDefaultFailure new_dp_property(DPUNIVERSE_ACTION_DEFAULT_FAILURE);
  168.  
  169.         $this->setBody(dp_text("This description hasn't been set yet.<br />"));
  170.  
  171.         /* Actions for both NPCs and users */
  172.         $this->addAction(dp_text('take')explode('#'dp_text('take#get'))'actionTake'DP_ACTION_OPERANT_MENUDP_ACTION_TARGET_OBJENVDP_ACTION_AUTHORIZED_ALLDP_ACTION_SCOPE_SELF);
  173.         $this->addAction(dp_text('inventory')explode('#'dp_text('inventory#inv#i'))'actionInventory'DP_ACTION_OPERANT_NONEDP_ACTION_TARGET_SELFDP_ACTION_AUTHORIZED_ALLDP_ACTION_SCOPE_SELF);
  174.         //$this->addAction(array($this, 'getMenuGiveLabel'), dp_text('give'), 'actionGive', DP_ACTION_OPERANT_METHOD_MENU, DP_ACTION_TARGET_OBJINV, DP_ACTION_AUTHORIZED_ALL, DP_ACTION_SCOPE_SELF);
  175.         $this->addAction(dp_text('give to...')dp_text('give')'actionGive'DP_ACTION_OPERANT_METHOD_MENUDP_ACTION_TARGET_OBJINVarray($this'getMenuGiveAuth')DP_ACTION_SCOPE_SELF);
  176.         $this->addAction(dp_text('<div style="width: 81px; margin: 0px"><div style="float: left">page chat</div> <div style="float: right">TAB</div></div>')dp_text('say')'actionSay'DP_ACTION_OPERANT_COMPLETEDP_ACTION_TARGET_SELFDP_ACTION_AUTHORIZED_ALLDP_ACTION_SCOPE_SELF);
  177.  
  178.         $this->addAction(array(dp_text('more chat')dp_text('emotions')dp_text('smile'))dp_text('smile')'actionSmile'DP_ACTION_OPERANT_NONEDP_ACTION_TARGET_SELFDP_ACTION_AUTHORIZED_ALLDP_ACTION_SCOPE_SELF);
  179.         $this->addAction(array(dp_text('more chat')dp_text('emotions')dp_text('grin'))dp_text('grin')'actionGrin'DP_ACTION_OPERANT_NONEDP_ACTION_TARGET_SELFDP_ACTION_AUTHORIZED_ALLDP_ACTION_SCOPE_SELF);
  180.         $this->addAction(array(dp_text('more chat')dp_text('emotions')dp_text('laugh'))dp_text('laugh')'actionLaugh'DP_ACTION_OPERANT_NONEDP_ACTION_TARGET_SELFDP_ACTION_AUTHORIZED_ALLDP_ACTION_SCOPE_SELF);
  181.         $this->addAction(array($this'getEmotionsMenu')dp_text('cheer')'actionCheer'DP_ACTION_OPERANT_MENUDP_ACTION_TARGET_SELF DP_ACTION_TARGET_LIVINGDP_ACTION_AUTHORIZED_ALLDP_ACTION_SCOPE_SELF);
  182.         $this->addAction(array(dp_text('more chat')dp_text('emotions')dp_text('nod'))dp_text('nod')'actionNod'DP_ACTION_OPERANT_NONEDP_ACTION_TARGET_SELFDP_ACTION_AUTHORIZED_ALLDP_ACTION_SCOPE_SELF);
  183.         $this->addAction(array(dp_text('more chat')dp_text('emotions')dp_text('shrug'))dp_text('shrug')'actionShrug'DP_ACTION_OPERANT_NONEDP_ACTION_TARGET_SELFDP_ACTION_AUTHORIZED_ALLDP_ACTION_SCOPE_SELF);
  184.         $this->addAction(array($this'getEmotionsMenu')dp_text('pat')'actionPat'DP_ACTION_OPERANT_MENUDP_ACTION_TARGET_LIVINGDP_ACTION_AUTHORIZED_ALLDP_ACTION_SCOPE_SELF);
  185.         $this->addAction(array($this'getEmotionsMenu')dp_text('high5')'actionHighFive'DP_ACTION_OPERANT_MENUDP_ACTION_TARGET_LIVINGDP_ACTION_AUTHORIZED_ALLDP_ACTION_SCOPE_SELF);
  186.         $this->addAction(array($this'getEmotionsMenu')dp_text('hug')'actionHug'DP_ACTION_OPERANT_MENUDP_ACTION_TARGET_LIVINGDP_ACTION_AUTHORIZED_ALLDP_ACTION_SCOPE_SELF);
  187.         $this->addAction(array($this'getEmotionsMenu')dp_text('kiss')'actionKiss'DP_ACTION_OPERANT_MENUDP_ACTION_TARGET_LIVINGDP_ACTION_AUTHORIZED_ALLDP_ACTION_SCOPE_SELF);
  188.         $this->addAction(array($this'getEmotionsMenu')dp_text('dance')'actionDance'DP_ACTION_OPERANT_MENUDP_ACTION_TARGET_LIVINGDP_ACTION_AUTHORIZED_ALLDP_ACTION_SCOPE_SELF);
  189.         $this->addAction(array(dp_text('more chat')dp_text('emotions')dp_text('emote...'))dp_text('emote')'actionEmote'DP_ACTION_OPERANT_NONEDP_ACTION_TARGET_SELFDP_ACTION_AUTHORIZED_ALLDP_ACTION_SCOPE_SELF);
  190.  
  191.         $this->addAction(array(dp_text('more chat')dp_text('send message to...'))dp_text('tell')'actionTell'DP_ACTION_OPERANT_METHOD_MENUDP_ACTION_TARGET_SELFarray($this'getMenuTellAuth')DP_ACTION_SCOPE_SELF);
  192.         $this->addAction(dp_text('send message...')dp_text('tell')'actionTell'array($this"getTellOperant")DP_ACTION_TARGET_USERDP_ACTION_AUTHORIZED_ALLDP_ACTION_SCOPE_SELF);
  193.         $this->addAction(array(dp_text('more chat')dp_text('shout to site...'))dp_text('shout')'actionShout'DP_ACTION_OPERANT_NONEDP_ACTION_TARGET_SELFDP_ACTION_AUTHORIZED_ALLDP_ACTION_SCOPE_SELF);
  194.  
  195.         $this->setTimeout('timeoutHeartBeat'2);
  196.  
  197.         $this->createDpLiving();
  198.     }
  199.  
  200.     /**
  201.      * Sets this living object up at the time it is created
  202.      *
  203.      * An empty function which can be redefined by the living class extending
  204.      * on DpLiving. When the object is created, it has no title, HTML body, et
  205.      * cetera, so in this method methods like {@link DpObject::setTitle()} are
  206.      * called. Building blocks extending on DpLiving may define their own create
  207.      * function. For example, DpNpc defines {@link DpNpc:createDpNpc}.
  208.      *
  209.      * @see        resetDpLiving()
  210.      */
  211.     function createDpLiving()
  212.     {
  213.     }
  214.  
  215.     /**
  216.      * Resets this living object
  217.      *
  218.      * Called by DpObject at regular intervals as defined in dpuniverse-ini.php.
  219.      * Calls the method 'resetDpLiving' in this living object. You can redefine
  220.      * that function to periodically do stuff such as alter the state of this
  221.      * living object.
  222.      *
  223.      * @access     private
  224.      * @see        resetDpLiving()
  225.      */
  226.     final function resetDpObject()
  227.     {
  228.         $this->resetDpLiving();
  229.     }
  230.  
  231.     /**
  232.      * Resets this living object
  233.      *
  234.      * Called by this living object at regular intervals as defined in
  235.      * dpuniverse-ini.php. An empty function which can be redefined by the
  236.      * living class extending on DpLiving. To be used to periodically do stuff
  237.      * such as alter the state of the living object.
  238.      *
  239.      * @see        createDpLiving()
  240.      */
  241.     function resetDpLiving()
  242.     {
  243.     }
  244.  
  245.     /**
  246.      * Reports an event
  247.      *
  248.      * Called when certain events occur, given with $name.
  249.      *
  250.      * Calls the method 'eventDpLiving' in this living object.
  251.      *
  252.      * @param      object    $name       Name of event
  253.      * @param      mixed     $args       One or more arguments, depends on event
  254.      * @since      DutchPIPE 0.2.0
  255.      */
  256.     final function eventDpObject($name)
  257.     {
  258.         $args func_get_args();
  259.         call_user_func_array(array($this'eventDpLiving')$args);
  260.     }
  261.  
  262.     /**
  263.      * Reports an event
  264.      *
  265.      * Called when certain events occur, given with $name.
  266.      *
  267.      * @param      object    $name       Name of event
  268.      * @param      mixed     $args       One or more arguments, depends on event
  269.      * @since      DutchPIPE 0.2.0
  270.      */
  271.     function eventDpLiving($name)
  272.     {
  273.     }
  274.  
  275.     /**
  276.      * Calls itself every "heartbeat"
  277.      *
  278.      * Redefine this method to make timed stuff happen.
  279.      */
  280.     function timeoutHeartBeat()
  281.     {
  282.         $this->setTimeout('timeoutHeartBeat'2);
  283.     }
  284.  
  285.     /**
  286.      * Gets the livings's age since it was created as an object in a string
  287.      *
  288.      * Returns the livings's age in a format like "6 hours and 14 minutes".
  289.      *
  290.      * @return  string  livings's age
  291.      * @see     DpUser::getInactive(), DpUser::isInactive(), DpUser::getStatus()
  292.      */
  293.     function getSessionAge()
  294.     {
  295.         return get_age2string(time($this->creationTime);
  296.     }
  297.  
  298.     /**
  299.      * Tries to perform the action given by the living object
  300.      *
  301.      * Called by the system to handle both actions performed by clicking on
  302.      * menus and actions from the input area. The first method will result in an
  303.      * $action parameter such as "take object_242" (using an unique object id).
  304.      * With the second method, $action will contain what the user typed, such as
  305.      * "take beer".
  306.      *
  307.      * Searches and calls for the right method linked to the action, which could
  308.      * be in another object. Handles failure messages when the action failed.
  309.      *
  310.      * This method can also be used to force living objects to perform actions.
  311.      *
  312.      * @param   string  $action     the action given by the living object
  313.      * @return  boolean TRUE for success, FALSE for unsuccessful action
  314.      * @see     setActionFailure(), getActionFailure(), setActionDefaultFailure(),
  315.      *           getActionDefaultFailure(), DpObject::addAction(),
  316.      *           DpObject::getActionData(), DpObject::getActionsMenu(),
  317.      *           DpObject::getTargettedActions(),
  318.      *           DpObject::performActionSubject()
  319.      */
  320.     public function performAction($action)
  321.     {
  322.         global $grCurrentDpObject;
  323.  
  324.         $this->lastActionTime !isset($this->lastActionTime)
  325.             ? new_dp_property(time()) time();
  326.  
  327.         $action trim($action);
  328.         $grCurrentDpObject $this;
  329.  
  330.         echo sprintf(dp_text("Action by %s: %s\n")$this->getTitle()$action);
  331.  
  332.         $rval = (bool)$this->performActionSubject($action$this);
  333.         if (TRUE !== $rval{
  334.             if (dp_strlen($action&& $action !== dp_text('look')
  335.                     && $action !== dp_text('l')) {
  336.                 $action_failure $this->getActionFailure();
  337.                 if (!isset($this->_GET['menuaction'])) {
  338.                     $this->tell($action_failure);
  339.                     if ($this->isUser && $this === get_current_dpuser()) {
  340.                         get_current_dpuniverse()->setToldSomething();
  341.                     }
  342.                 }
  343.                 $this->setActionFailure($this->getActionDefaultFailure());
  344.             }
  345.         }
  346.         $grCurrentDpObject FALSE;
  347.         return $rval;
  348.     }
  349.  
  350.     function getWeightCarry()
  351.     {
  352.         $inv $this->getInventory();
  353.         $weight 0;
  354.  
  355.         foreach ($inv as &$ob{
  356.             if (isset($ob->weight)) {
  357.                 $weight += $ob->weight;
  358.             }
  359.         }
  360.  
  361.         return $weight;
  362.     }
  363.  
  364.     function getVolumeCarry()
  365.     {
  366.         $inv $this->getInventory();
  367.         $volume 0;
  368.  
  369.         foreach ($inv as &$ob{
  370.             if (isset($ob->volume)) {
  371.                 $volume += $ob->volume;
  372.             }
  373.         }
  374.  
  375.         return $volume;
  376.     }
  377.  
  378.     /**
  379.      * Makes this living object examine an object
  380.      *
  381.      * @param   string  $verb       the action, "examine"
  382.      * @param   string  $noun       what to examine, could be empty
  383.      * @return  boolean TRUE for action completed, FALSE otherwise
  384.      */
  385.     function actionExamine($verb$noun)
  386.     {
  387.         if ($verb == dp_text('look'|| $verb == dp_text('l')) {
  388.             $at dp_text('at');
  389.             $at_len dp_strlen($at);
  390.             if (dp_strlen($noun>= $at_len
  391.                     && dp_substr($noun0$at_len== $at{
  392.                 $noun $noun == $at '' trim(dp_substr($noun$at_len));
  393.             }
  394.         }
  395.  
  396.         if (!dp_strlen($noun)) {
  397.             $this->setActionFailure($verb == dp_text('look')
  398.                 || $verb == dp_text('l')
  399.                 ? dp_text('Look at what?<br />')
  400.                 : dp_text('Examine what?<br />'));
  401.             return FALSE;
  402.         }
  403.  
  404.         if (FALSE === ($env $this->getEnvironment())) {
  405.             return FALSE;
  406.         }
  407.  
  408.         if (!($ob $this->isPresent($noun))
  409.                 && !($description $this->getItemDescription($noun))) {
  410.             if (!($ob $env->isPresent($noun))
  411.                     && !($description $env->getItemDescription($noun))) {
  412.                 $this->setActionFailure(sprintf(
  413.                     dp_text('There is no %s here.<br />')$noun));
  414.                 return FALSE;
  415.             }
  416.         }
  417.  
  418.         if ($ob{
  419.             $description $ob->getAppearance(0TRUENULL$this->displayMode,
  420.                 FALSE'dpexamine');
  421.         }
  422.  
  423.         $this->tell("<window>$description</window>");
  424.         return TRUE;
  425.     }
  426.  
  427.     /**
  428.      * Makes this living object take an object
  429.      *
  430.      * @param   string  $verb       the action, "take"
  431.      * @param   string  $noun       what to take, could be empty
  432.      * @return  boolean TRUE for action completed, FALSE otherwise
  433.      */
  434.     function actionTake($verb$noun)
  435.     {
  436.         if (FALSE === ($env $this->getEnvironment())) {
  437.             return FALSE;
  438.         }
  439.  
  440.         if (!dp_strlen($noun)) {
  441.             $this->setActionFailure(ucfirst(sprintf(dp_text('%s what?<br />'),
  442.                 $noun)));
  443.             return FALSE;
  444.         }
  445.  
  446.         if ($noun == dp_text('all')) {
  447.             $inv $env->getInventory();
  448.             $picked_up FALSE;
  449.             foreach ($inv as &$ob{
  450.                 if (!isset($ob->isLiving|| TRUE !== $ob->isLiving{
  451.                     $result $ob->moveDpObject($this);
  452.                     $picked_up TRUE;
  453.                     if (TRUE !== $result{
  454.                         if (E_MOVEOBJECT_HEAVY === $result{
  455.                             $this->tell(dp_text("You can't carry more weight, drop something first.<br />"));
  456.                         }
  457.                         if (E_MOVEOBJECT_VOLUME === $result{
  458.                             $this->tell(dp_text("You can't carry more volume, drop something first.<br />"));
  459.                         }
  460.                         continue;
  461.                     }
  462.                     $this->tell(dp_text('You take %s.<br />',
  463.                         $ob->getTitle(DPUNIVERSE_TITLE_TYPE_DEFINITE)));
  464.                     $env->tell(ucfirst(sprintf(dp_text('%s takes %s.<br />'),
  465.                         $this->getTitle(DPUNIVERSE_TITLE_TYPE_DEFINITE),
  466.                         $ob->getTitle(DPUNIVERSE_TITLE_TYPE_INDEFINITE))),
  467.                         $this);
  468.                 }
  469.             }
  470.             if (FALSE === $picked_up{
  471.                $this->tell(dp_text('There is nothing to pick up here.<br />'));
  472.             }
  473.             return TRUE;
  474.         }
  475.  
  476.         if (FALSE === ($ob $env->isPresent($noun))) {
  477.             $this->setActionFailure(sprintf(
  478.                 dp_text('There is no %s here.<br />')$noun));
  479.             return FALSE;
  480.         }
  481.  
  482.         if (isset($ob->isLiving&& TRUE === $ob->isLiving{
  483.             $this->tell(ucfirst(sprintf(
  484.                 dp_text('%s refuses to be taken.<br />')$ob->getTitle())));
  485.             return TRUE;
  486.         }
  487.  
  488.         if ($ob->isHeap && ((!DPSERVER_ENABLE_MBSTRING
  489.                 && preg_match(dp_text('/^(\d+) /')$noun$matches))
  490.                 || (DPSERVER_ENABLE_MBSTRING && mb_ereg(dp_text('^([0-9]+) '),
  491.                 $noun$matches))) && $matches[10
  492.                 && $matches[1$ob->amount{
  493.             $result $ob->moveDpObject($thisFALSE$matches[1]);
  494.             $title_definite $title_indefinite $noun;
  495.         else {
  496.             $result $ob->moveDpObject($this);
  497.             $title_definite $ob->getTitle(DPUNIVERSE_TITLE_TYPE_DEFINITE);
  498.             $title_indefinite $ob->getTitle(DPUNIVERSE_TITLE_TYPE_INDEFINITE);
  499.         }
  500.  
  501.         if (TRUE !== $result{
  502.             if (E_MOVEOBJECT_HEAVY === $result{
  503.                 $this->tell(ucfirst(
  504.                     dp_text("You can't carry more weight, drop something first.<br />")));
  505.             }
  506.             if (E_MOVEOBJECT_VOLUME === $result{
  507.                 $this->tell(ucfirst(
  508.                     dp_text("You can't carry more volume, drop something first.<br />")));
  509.             }
  510.             return TRUE;
  511.         }
  512.         $this->tell(sprintf(dp_text('You take %s.<br />'),
  513.             $title_definite));
  514.         $env->tell(ucfirst(sprintf(dp_text('%s takes %s.<br />'),
  515.             $this->getTitle(DPUNIVERSE_TITLE_TYPE_DEFINITE),
  516.             $title_indefinite)),
  517.             $this);
  518.         return TRUE;
  519.     }
  520.  
  521.     /**
  522.      * Drops an object in the user's environment
  523.      *
  524.      * @param   string  $verb       the action, "drop"
  525.      * @param   string  $noun       what to drop, could be empty
  526.      * @return  boolean TRUE for action completed, FALSE otherwise
  527.      */
  528.     function actionDrop($verb$noun$silently FALSE)
  529.     {
  530.         if (!dp_strlen($noun)) {
  531.             if (FALSE === $silently{
  532.                 $this->setActionFailure(dp_text('Drop what?<br />'));
  533.             }
  534.             return FALSE;
  535.         }
  536.         if (FALSE === ($env $this->getEnvironment())) {
  537.             return FALSE;
  538.         }
  539.         if ($noun == dp_text('all')) {
  540.             $inv $this->getInventory();
  541.             if (sizeof($inv== 0{
  542.                if (FALSE === $silently{
  543.                    $this->tell(dp_text('You have nothing to drop.<br />'));
  544.                }
  545.                return TRUE;
  546.             }
  547.             foreach ($inv as &$ob{
  548.                 $ob->moveDpObject($env);
  549.                 if (FALSE === $silently{
  550.                     $this->tell(sprintf(dp_text('You drop %s.<br />'),
  551.                         $ob->getTitle(DPUNIVERSE_TITLE_TYPE_DEFINITE)));
  552.                 }
  553.                 $env->tell(ucfirst(sprintf(dp_text('%s drops %s.<br />'),
  554.                     $this->getTitle(DPUNIVERSE_TITLE_TYPE_DEFINITE),
  555.                     $ob->getTitle(DPUNIVERSE_TITLE_TYPE_INDEFINITE))),
  556.                     $this);
  557.             }
  558.             return TRUE;
  559.         }
  560.  
  561.         if (FALSE === ($ob $this->isPresent($noun))) {
  562.             if (FALSE === $silently{
  563.                 $this->setActionFailure(sprintf(
  564.                     dp_text('There is no %s here.<br />')$noun));
  565.             }
  566.             return FALSE;
  567.         }
  568.         if ($ob->isHeap && ((!DPSERVER_ENABLE_MBSTRING
  569.                 && preg_match(dp_text('/^(\d+) /')$noun$matches))
  570.                 || (DPSERVER_ENABLE_MBSTRING && mb_ereg(dp_text('^([0-9]+) '),
  571.                 $noun$matches))) && $matches[10
  572.                 && $matches[1$ob->amount{
  573.             $ob->moveDpObject($envFALSE$matches[1]);
  574.             $title_definite $title_indefinite $noun;
  575.         else {
  576.             $ob->moveDpObject($env);
  577.             $title_definite $ob->getTitle(DPUNIVERSE_TITLE_TYPE_DEFINITE);
  578.             $title_indefinite $ob->getTitle(DPUNIVERSE_TITLE_TYPE_INDEFINITE);
  579.         }
  580.         if (FALSE === $silently{
  581.             $this->tell(sprintf(dp_text('You drop %s.<br />'),
  582.                 $title_definite));
  583.         }
  584.  
  585.         $env->tell(ucfirst(sprintf(dp_text('%s drops %s.<br />'),
  586.             $this->getTitle(DPUNIVERSE_TITLE_TYPE_DEFINITE),
  587.             $title_indefinite))$this);
  588.         return TRUE;
  589.     }
  590.  
  591.     /**
  592.      * Shows this living object a list of objects it is carrying
  593.      *
  594.      * @param   string  $verb       the action, "inventory"
  595.      * @param   string  $noun       empty string
  596.      * @return  boolean TRUE for action completed, FALSE otherwise
  597.      */
  598.     function actionInventory($verb$noun)
  599.     {
  600.         $inventory $this->getAppearance(0TRUENULL,
  601.             $this->displayMode-1'dpobinv');
  602.         /* :KLUDGE: */
  603.         $carrying_str dp_text('You are carrying:');
  604.         $inventory str_replace($carrying_str"<b>$carrying_str</b>",
  605.             $inventory);
  606.         $this->tell("<window name=\"inventory\">$inventory</window>");
  607.         return TRUE;
  608.     }
  609.  
  610.     /**
  611.      * Makes this living object say something
  612.      *
  613.      * @param   string  $verb       the action, "say"
  614.      * @param   string  $noun       what to say, could be empty
  615.      * @return  boolean TRUE for action completed, FALSE otherwise
  616.      */
  617.     function actionSay($verb$noun)
  618.     {
  619.         if (empty($noun)) {
  620.             $this->tell(dp_text('Say what?<br />'));
  621.             return TRUE;
  622.         }
  623.         if (FALSE === ($env $this->getEnvironment())) {
  624.             return FALSE;
  625.         }
  626.         $env->tell(ucfirst(sprintf(dp_text('%s says: %s<br />'),
  627.             $this->getTitle(DPUNIVERSE_TITLE_TYPE_DEFINITE)$noun))$this);
  628.         $this->tell(sprintf(dp_text('You say: %s<br />')$noun));
  629.         return TRUE;
  630.     }
  631.  
  632.     function getEmotionsMenu($verb&$defined_by&$target&$performer)
  633.     {
  634.         //echo "$verb: THIS: {$this->title} DEFINED: {$defined_by->title}; TARGET: " . $target->title . "; PERFORMER: " . $performer->title . "\n";
  635.         return $defined_by === $performer
  636.             ? array(dp_text('more chat')dp_text('emotions')$verb)
  637.             : array(dp_text('emotions')$verb);
  638.     }
  639.  
  640.     function getTellOperant($verb&$defined_by&$target&$performer)
  641.     {
  642.         return $defined_by->title;
  643.     }
  644.  
  645.     /**
  646.      * Completes the give action performed by clicking on an object
  647.      *
  648.      * Called by the action system when someone clicks on an object and selects
  649.      * "give...". Returns something like "beer to", which allows the system to
  650.      * fill the input area with "give beer to " using the title of the object
  651.      * which was clicked on.
  652.      *
  653.      * @param   string  $verb       the action, "give"
  654.      * @return  string  a string such as "beer to "
  655.      * @see     actionGive()
  656.      */
  657.     function getActionOperantMenu($verb&$menuobj)
  658.     {
  659.         $user get_current_dpuser();
  660.  
  661.         if ($verb === dp_text('give')) {
  662.             $ob_title dp_strtolower($menuobj->getTitle());
  663.             $rval dp_text('give %s to %s');
  664.             if (FALSE !== ($env $this->getEnvironment())) {
  665.                 $menu array();
  666.                 $inv $env->getInventory();
  667.                 foreach ($inv as &$ob{
  668.                     if ($ob->isLiving && $ob !== $user{
  669.                         $to_title dp_strtolower($ob->getTitle());
  670.                         $menu[$to_titlesprintf($rval$ob_title$to_title);
  671.                     }
  672.                 }
  673.             }
  674.             return !count($menuFALSE $menu;
  675.         elseif ($verb === dp_text('tell')) {
  676.             $rval dp_text('tell %s');
  677.             $users get_current_dpuniverse()->getUsers();
  678.             if (sizeof($users)) {
  679.                 $menu array();
  680.                 foreach ($users as &$u{
  681.                     if ($u !== $user{
  682.                         $to_title dp_strtolower($u->getTitle());
  683.                         $menu[$to_titlesprintf($rval$to_title);
  684.                     }
  685.                 }
  686.             }
  687.             return !count($menuFALSE $menu;
  688.         }
  689.         return FALSE;
  690.     }
  691.  
  692.     function getMenuGiveAuth()
  693.     {
  694.         if (FALSE !== ($env $this->getEnvironment())) {
  695.             $inv $env->getInventory();
  696.             foreach ($inv as &$ob{
  697.                 if ($ob->isLiving && $ob !== get_current_dpuser()) {
  698.                     return DP_ACTION_AUTHORIZED_ALL;
  699.                 }
  700.             }
  701.         }
  702.  
  703.         return DP_ACTION_AUTHORIZED_DISABLED;
  704.     }
  705.  
  706.     function getMenuTellAuth()
  707.     {
  708.         if (get_current_dpuniverse()->getNrOfUsers()) {
  709.             return DP_ACTION_AUTHORIZED_ALL;
  710.         }
  711.  
  712.         return DP_ACTION_AUTHORIZED_DISABLED;
  713.     }
  714.  
  715.     function getMenuGiveLabel()
  716.     {
  717.         if (FALSE !== ($env $this->getEnvironment())) {
  718.             $inv $env->getInventory();
  719.             foreach ($inv as &$ob{
  720.                 if ($ob->isLiving && $ob !== get_current_dpuser()) {
  721.                     return dp_text('give...');
  722.                 }
  723.             }
  724.         }
  725.  
  726.         return dp_text("<span style='color: #999'>give to...</span>");
  727.     }
  728.  
  729.  
  730.     /**
  731.      * Makes this living object give an object to another living object
  732.      *
  733.      * @param   string  $verb       the action, "give"
  734.      * @param   string  $noun       what and who to give, could be empty
  735.      * @return  boolean TRUE for action completed, FALSE otherwise
  736.      * @see     actionGiveOperant()
  737.      */
  738.     function actionGive($verb$noun)
  739.     {
  740.         if (empty($noun)) {
  741.             return FALSE;
  742.         }
  743.         $to ' ' dp_text('to'' ';
  744.         $to_len dp_strlen($to);
  745.         if (FALSE === ($pos dp_strpos($noun$to))
  746.                 || $pos dp_strlen($noun$to_len{
  747.             $this->Tell(dp_text('Give what to who?<br />'));
  748.             return TRUE;
  749.         }
  750.         $what dp_substr($noun0$pos);
  751.         $who dp_substr($noun$pos $to_len);
  752.  
  753.         if (!($what_ob $this->isPresent($what))) {
  754.             $this->tell(sprintf(dp_text('You have no %s.<br />')$what));
  755.             return TRUE;
  756.         }
  757.         $env $this->getEnvironment();
  758.         if (!is_object($env|| !($who_ob $env->isPresent($who))) {
  759.             $this->tell(ucfirst(sprintf(dp_text('%s is not here.<br />'),
  760.                 $who)));
  761.             return TRUE;
  762.         }
  763.  
  764.         $env->tell(ucfirst(sprintf(dp_text('%s gives %s to %s.<br />'),
  765.             $this->getTitle(DPUNIVERSE_TITLE_TYPE_DEFINITE),
  766.             $what_ob->getTitle(DPUNIVERSE_TITLE_TYPE_INDEFINITE),
  767.             $who_ob->getTitle(DPUNIVERSE_TITLE_TYPE_INDEFINITE))),
  768.             $this$who_ob);
  769.         $who_ob->tell(ucfirst(sprintf(dp_text('%s gives %s to you.<br />'),
  770.             $this->getTitle(DPUNIVERSE_TITLE_TYPE_DEFINITE),
  771.             $what_ob->getTitle(DPUNIVERSE_TITLE_TYPE_INDEFINITE))));
  772.         $what_ob->moveDpObject($who_ob);
  773.         $this->tell(sprintf(dp_text('You give %s to %s.<br />'),
  774.             $what_ob->getTitle(DPUNIVERSE_TITLE_TYPE_DEFINITE),
  775.             $who_ob->getTitle(DPUNIVERSE_TITLE_TYPE_INDEFINITE)));
  776.         return TRUE;
  777.     }
  778.  
  779.     /**
  780.      * Makes this living object tell something to another user object
  781.      *
  782.      * @param   string  $verb       the action, "tell"
  783.      * @param   string  $noun       who and what to tell, could be empty
  784.      * @return  boolean TRUE for action completed, FALSE otherwise
  785.      */
  786.     function actionTell($verb$noun)
  787.     {
  788.         if (empty($noun)) {
  789.             return FALSE;
  790.         }
  791.  
  792.         if (FALSE === ($pos dp_strpos($noun' '))) {
  793.             $this->Tell(dp_text('Tell who what?<br />'));
  794.             return TRUE;
  795.         }
  796.         $who dp_substr($noun0$pos);
  797.         $what dp_substr($noun$pos 1);
  798.         if (FALSE === ($who_ob get_current_dpuniverse()->findUser($who))) {
  799.             $this->tell(sprintf(dp_text('User %s was not found.<br />')$who));
  800.             return TRUE;
  801.         }
  802.  
  803.         $who_ob->tell(ucfirst(sprintf(dp_text('%s tells you: %s<br />'),
  804.             $this->getTitle(DPUNIVERSE_TITLE_TYPE_DEFINITE)$what)));
  805.         $this->tell(sprintf(dp_text('You tell %s: %s<br />'),
  806.             $who_ob->getTitle(DPUNIVERSE_TITLE_TYPE_DEFINITE)$what));
  807.  
  808.         return TRUE;
  809.     }
  810.  
  811.     /**
  812.      * Makes this living object shout something to everyone on the site
  813.      *
  814.      * @param   string  $verb       the action, "shout"
  815.      * @param   string  $noun       what to shout, could be empty
  816.      * @return  boolean TRUE for action completed, FALSE otherwise
  817.      */
  818.     function actionShout($verb$noun)
  819.     {
  820.         if (is_null($noun)) {
  821.             return FALSE;
  822.         }
  823.  
  824.         $users get_current_dpuniverse()->getUsers();
  825.         if (sizeof($users)) {
  826.             $msg FALSE === ($env $this->getEnvironment())
  827.                 ? ucfirst(sprintf(dp_text('%s shouts from nowhere: %s<br />'),
  828.                     $this->getTitle(DPUNIVERSE_TITLE_TYPE_DEFINITE)$noun))
  829.                 : ucfirst(sprintf(dp_text('%s shouts from %s: %s<br />'),
  830.                     $this->getTitle(DPUNIVERSE_TITLE_TYPE_DEFINITE),
  831.                     $env->getTitle()$noun));
  832.             foreach ($users as &$u{
  833.                 if ($u !== $this{
  834.                     $u->tell($msg);
  835.                 }
  836.             }
  837.         }
  838.         $this->tell(sprintf(dp_text('You shout: %s<br />')$noun));
  839.         return TRUE;
  840.     }
  841.  
  842.     /**
  843.      * Makes this living object smile happily
  844.      *
  845.      * @param   string  $verb       the action, "smile"
  846.      * @param   string  $noun       empty string
  847.      * @return  boolean TRUE
  848.      */
  849.     function actionSmile($verb$noun)
  850.     {
  851.         $this->tell(dp_text('You smile happily.<br />'));
  852.         if (FALSE !== ($env $this->getEnvironment())) {
  853.             $env->tell(ucfirst(sprintf(dp_text('%s smiles happily.<br />'),
  854.                 $this->getTitle(DPUNIVERSE_TITLE_TYPE_DEFINITE)))$this);
  855.         }
  856.         return TRUE;
  857.     }
  858.  
  859.     /**
  860.      * Makes this living object grin evilly
  861.      *
  862.      * @param   string  $verb       the action, "grin"
  863.      * @param   string  $noun       empty string
  864.      * @return  boolean TRUE
  865.      */
  866.     function actionGrin($verb$noun)
  867.     {
  868.         $this->tell(dp_text('You grin evilly.<br />'));
  869.         if (FALSE !== ($env $this->getEnvironment())) {
  870.             $env->tell(ucfirst(sprintf(dp_text('%s grins evilly.<br />'),
  871.                 $this->getTitle(DPUNIVERSE_TITLE_TYPE_DEFINITE)))$this);
  872.         }
  873.         return TRUE;
  874.     }
  875.  
  876.     /**
  877.      * Makes this living object fall down on the floor laughing
  878.      *
  879.      * @param   string  $verb       the action, "laugh"
  880.      * @param   string  $noun       empty string
  881.      * @return  boolean TRUE
  882.      */
  883.     function actionLaugh($verb$noun)
  884.     {
  885.         $this->tell(dp_text('You fall down on the floor laughing.<br />'));
  886.         if (FALSE !== ($env $this->getEnvironment())) {
  887.             $env->tell(ucfirst(sprintf(
  888.                 dp_text('%s falls down on the floor laughing.<br />'),
  889.                 $this->getTitle(DPUNIVERSE_TITLE_TYPE_DEFINITE)))$this);
  890.         }
  891.         return TRUE;
  892.     }
  893.  
  894.     /**
  895.      * Makes this living object cheer wildly
  896.      *
  897.      * @param   string  $verb       the action, "cheer"
  898.      * @param   string  $noun       who to cheer on, could be empty
  899.      * @return  boolean TRUE
  900.      */
  901.     function actionCheer($verb$noun)
  902.     {
  903.         if (!dp_strlen($noun|| $this->isId($noun)) {
  904.             $this->tell(dp_text('You jump up and down cheering.<br />'));
  905.             if (FALSE !== ($env $this->getEnvironment())) {
  906.                 $env->tell(ucfirst(sprintf(
  907.                     dp_text('%s jumps up and down cheering.<br />'),
  908.                     $this->getTitle(DPUNIVERSE_TITLE_TYPE_DEFINITE)))$this);
  909.             }
  910.             return TRUE;
  911.         }
  912.  
  913.         if (FALSE === ($env $this->getEnvironment()) ||
  914.                 ($noun && !($dest_ob $env->isPresent($noun)))) {
  915.             $this->setActionFailure(sprintf(dp_text("Couldn't find: %s<br />"),
  916.                 $noun));
  917.             return FALSE;
  918.         }
  919.         if (!isset($dest_ob)) {
  920.             $this->setActionFailure(dp_text('Cheer on who?<br />'));
  921.             return FALSE;
  922.         }
  923.         $this->tell(sprintf(
  924.             dp_text('You jump up and down cheering on %s.<br />'),
  925.             $dest_ob->getTitle(DPUNIVERSE_TITLE_TYPE_DEFINITE)));
  926.         $env->tell(ucfirst(sprintf(
  927.             dp_text('%s jumps up and down cheering on %s.<br />'),
  928.             $this->getTitle(DPUNIVERSE_TITLE_TYPE_DEFINITE),
  929.             $dest_ob->getTitle(DPUNIVERSE_TITLE_TYPE_DEFINITE))),
  930.             $this$dest_ob);
  931.         $dest_ob->tell(ucfirst(sprintf(
  932.             dp_text('%s jumps up and down cheering you on.<br />'),
  933.             $this->getTitle(DPUNIVERSE_TITLE_TYPE_DEFINITE))));
  934.  
  935.         return TRUE;
  936.     }
  937.  
  938.     /**
  939.      * Makes this living object nod solemnly
  940.      *
  941.      * @param   string  $verb       the action, "nod"
  942.      * @param   string  $noun       empty string
  943.      * @return  boolean TRUE
  944.      */
  945.     function actionNod($verb$noun)
  946.     {
  947.         $this->tell(dp_text('You nod solemnly.<br />'));
  948.         if (FALSE !== ($env $this->getEnvironment())) {
  949.             $env->tell(ucfirst(sprintf(dp_text('%s nods solemnly.<br />'),
  950.                 $this->getTitle(DPUNIVERSE_TITLE_TYPE_DEFINITE)))$this);
  951.         }
  952.         return TRUE;
  953.     }
  954.  
  955.     /**
  956.      * Makes this living object shrug
  957.      *
  958.      * @param   string  $verb       the action, "laugh"
  959.      * @param   string  $noun       empty string
  960.      * @return  boolean TRUE
  961.      */
  962.     function actionShrug($verb$noun)
  963.     {
  964.         $this->tell(dp_text('You shrug.<br />'));
  965.         if (FALSE !== ($env $this->getEnvironment())) {
  966.             $env->tell(ucfirst(sprintf(dp_text('%s shrugs.<br />'),
  967.                 $this->getTitle(DPUNIVERSE_TITLE_TYPE_DEFINITE)))$this);
  968.         }
  969.         return TRUE;
  970.     }
  971.  
  972.     /**
  973.      * Makes this living object pat another living object on the head
  974.      *
  975.      * @param   string  $verb       the action, "pat"
  976.      * @param   string  $noun       who to pat, could be empty
  977.      * @return  boolean TRUE for action completed, FALSE otherwise
  978.      */
  979.     function actionPat($verb$noun)
  980.     {
  981.         if (FALSE === ($env $this->getEnvironment()) ||
  982.                 ($noun && !($dest_ob $env->isPresent($noun)))) {
  983.             $this->setActionFailure(sprintf(dp_text("Couldn't find: %s<br />"),
  984.                 $noun));
  985.             return FALSE;
  986.         }
  987.         if (!isset($dest_ob)) {
  988.             $this->setActionFailure(dp_text('Pat who?<br />'));
  989.             return FALSE;
  990.         }
  991.         $this->tell(sprintf(
  992.             dp_text('You pat %s on the head with a bone-crushing sound.<br />'),
  993.             $dest_ob->getTitle(DPUNIVERSE_TITLE_TYPE_DEFINITE)));
  994.         $env->tell(ucfirst(sprintf(
  995.             dp_text('%s pats %s on the head with a bone-crushing sound.<br />'),
  996.             $this->getTitle(DPUNIVERSE_TITLE_TYPE_DEFINITE),
  997.             $dest_ob->getTitle(DPUNIVERSE_TITLE_TYPE_DEFINITE))),
  998.             $this$dest_ob);
  999.         $dest_ob->tell(ucfirst(sprintf(
  1000.             dp_text('%s pats you on the head with a bone-crushing sound.<br />'),
  1001.             $this->getTitle(DPUNIVERSE_TITLE_TYPE_DEFINITE))));
  1002.  
  1003.         return TRUE;
  1004.     }
  1005.  
  1006.     /**
  1007.      * Makes this living object slap a high-five with another living object
  1008.      *
  1009.      * @param   string  $verb       the action, "high5"
  1010.      * @param   string  $noun       who to high5, could be empty
  1011.      * @return  boolean TRUE for action completed, FALSE otherwise
  1012.      */
  1013.     function actionHighFive($verb$noun)
  1014.     {
  1015.         if (FALSE === ($env $this->getEnvironment()) ||
  1016.                 ($noun && !($dest_ob $env->isPresent($noun)))) {
  1017.             $this->setActionFailure(sprintf(dp_text("Couldn't find: %s<br />"),
  1018.                 $noun));
  1019.             return FALSE;
  1020.         }
  1021.         if (!isset($dest_ob)) {
  1022.             $this->setActionFailure(dp_text('High5 who?<br />'));
  1023.             return FALSE;
  1024.         }
  1025.         $this->tell(sprintf(
  1026.             dp_text('You jump up, and slap a thundering high-five with %s.<br />'),
  1027.             $dest_ob->getTitle(DPUNIVERSE_TITLE_TYPE_DEFINITE)));
  1028.         $env->tell(ucfirst(sprintf(
  1029.             dp_text('%s jumps up, and slaps a thundering high-five with %s.<br />'),
  1030.             $this->getTitle(DPUNIVERSE_TITLE_TYPE_DEFINITE),
  1031.             $dest_ob->getTitle(DPUNIVERSE_TITLE_TYPE_DEFINITE))),
  1032.             $this$dest_ob);
  1033.         $dest_ob->tell(ucfirst(sprintf(
  1034.             dp_text('%s jumps up, and slaps a thundering high-five with you.<br />'),
  1035.             $this->getTitle(DPUNIVERSE_TITLE_TYPE_DEFINITE))));
  1036.  
  1037.         return TRUE;
  1038.     }
  1039.  
  1040.     /**
  1041.      * Makes this living object hug another living object
  1042.      *
  1043.      * @param   string  $verb       the action, "hug"
  1044.      * @param   string  $noun       who to hug, could be empty
  1045.      * @return  boolean TRUE for action completed, FALSE otherwise
  1046.      */
  1047.     function actionHug($verb$noun)
  1048.     {
  1049.         if (FALSE === ($env $this->getEnvironment()) ||
  1050.                 ($noun && !($dest_ob $env->isPresent($noun)))) {
  1051.             $this->setActionFailure(sprintf(dp_text("Couldn't find: %s<br />"),
  1052.                 $noun));
  1053.             return FALSE;
  1054.         }
  1055.         if (!isset($dest_ob)) {
  1056.             $this->setActionFailure(dp_text('Hug who?<br />'));
  1057.             return FALSE;
  1058.         }
  1059.         $this->tell(sprintf(dp_text('You hug %s.<br />'),
  1060.             $dest_ob->getTitle(DPUNIVERSE_TITLE_TYPE_DEFINITE)));
  1061.         $env->tell(ucfirst(sprintf(dp_text('%s hugs %s.<br />'),
  1062.             $this->getTitle(DPUNIVERSE_TITLE_TYPE_DEFINITE),
  1063.             $dest_ob->getTitle(DPUNIVERSE_TITLE_TYPE_DEFINITE))),
  1064.             $this$dest_ob);
  1065.         $dest_ob->tell(ucfirst(sprintf(dp_text('%s hugs you.<br />'),
  1066.             $this->getTitle(DPUNIVERSE_TITLE_TYPE_DEFINITE))));
  1067.  
  1068.         return TRUE;
  1069.     }
  1070.  
  1071.     /**
  1072.      * Makes this living object give another living object a passionate kiss
  1073.      *
  1074.      * @param   string  $verb       the action, "kiss"
  1075.      * @param   string  $noun       who to kiss, could be empty
  1076.      * @return  boolean TRUE for action completed, FALSE otherwise
  1077.      */
  1078.     function actionKiss($verb$noun)
  1079.     {
  1080.         if (FALSE === ($env $this->getEnvironment()) ||
  1081.                 ($noun && !($dest_ob $env->isPresent($noun)))) {
  1082.             $this->setActionFailure(sprintf(dp_text("Couldn't find: %s<br />"),
  1083.                 $noun));
  1084.             return FALSE;
  1085.         }
  1086.         if (!isset($dest_ob)) {
  1087.             $this->setActionFailure(dp_text('Kiss who?<br />'));
  1088.             return FALSE;
  1089.         }
  1090.         $this->tell(sprintf(
  1091.             dp_text('You give %s a deep and passionate kiss... It seems to last forever...<br />'),
  1092.             $dest_ob->getTitle(DPUNIVERSE_TITLE_TYPE_DEFINITE)));
  1093.         $env->tell(ucfirst(sprintf(
  1094.             dp_text('%s gives %s a deep and passionate kiss... It seems to last forever...<br />'),
  1095.             $this->getTitle(DPUNIVERSE_TITLE_TYPE_DEFINITE),
  1096.             $dest_ob->getTitle(DPUNIVERSE_TITLE_TYPE_DEFINITE))),
  1097.             $this$dest_ob);
  1098.         $dest_ob->tell(ucfirst(sprintf(
  1099.             dp_text('%s gives you a deep and passionate kiss... It seems to last forever...<br />'),
  1100.             $this->getTitle(DPUNIVERSE_TITLE_TYPE_DEFINITE))));
  1101.  
  1102.         return TRUE;
  1103.     }
  1104.  
  1105.     /**
  1106.      * Makes this living object take another living object for a dance
  1107.      *
  1108.      * @param   string  $verb       the action, "dance"
  1109.      * @param   string  $noun       who to dance with, could be empty
  1110.      * @return  boolean TRUE for action completed, FALSE otherwise
  1111.      */
  1112.     function actionDance($verb$noun)
  1113.     {
  1114.         if (FALSE === ($env $this->getEnvironment()) ||
  1115.                 ($noun && !($dest_ob $env->isPresent($noun)))) {
  1116.             $this->setActionFailure(sprintf(dp_text("Couldn't find: %s<br />"),
  1117.                 $noun));
  1118.             return FALSE;
  1119.         }
  1120.         if (!isset($dest_ob)) {
  1121.             $this->setActionFailure(dp_text('Dance with who?<br />'));
  1122.             return FALSE;
  1123.         }
  1124.         $this->tell(sprintf(
  1125.             dp_text('You take %s for a dance... The tango!<br />'),
  1126.             $dest_ob->getTitle(DPUNIVERSE_TITLE_TYPE_DEFINITE)));
  1127.         $env->tell(ucfirst(sprintf(
  1128.             dp_text('%s takes %s for a dance... The tango!<br />'),
  1129.             $this->getTitle(DPUNIVERSE_TITLE_TYPE_DEFINITE),
  1130.             $dest_ob->getTitle(DPUNIVERSE_TITLE_TYPE_DEFINITE))),
  1131.             $this$dest_ob);
  1132.         $dest_ob->tell(ucfirst(sprintf(
  1133.             dp_text('%s takes you for a dance... The tango!<br />'),
  1134.             $this->getTitle(DPUNIVERSE_TITLE_TYPE_DEFINITE))));
  1135.  
  1136.         return TRUE;
  1137.     }
  1138.  
  1139.     /**
  1140.      * Makes this living object communicate a custom message to its environment
  1141.      *
  1142.      * @param   string  $verb       the action, "emote"
  1143.      * @param   string  $noun       string to "emote"
  1144.      * @return  boolean TRUE for action completed, FALSE otherwise
  1145.      */
  1146.     function actionEmote($verb$noun)
  1147.     {
  1148.         if (FALSE === ($env $this->getEnvironment())) {
  1149.             return FALSE;
  1150.         }
  1151.         if (!dp_strlen($noun)) {
  1152.             $this->setActionFailure(dp_text('Try: emote <i>text</i><br />'));
  1153.             return FALSE;
  1154.         }
  1155.         $this->tell(ucfirst($this->getTitle(DPUNIVERSE_TITLE_TYPE_DEFINITE))
  1156.             . " $noun<br />");
  1157.         $env->tell(ucfirst($this->getTitle(DPUNIVERSE_TITLE_TYPE_DEFINITE))
  1158.             . " $noun<br />"$this);
  1159.         return TRUE;
  1160.     }
  1161. }
  1162. ?>

Documentation generated on Mon, 03 Sep 2007 22:19:40 +0200 by phpDocumentor 1.3.0RC6

Click me!
Guest#215
 
 
 
  Go to Top
 
 
Input Field OptionsClose Input Field Go to Top
 
Legal Notices | Copyright © 2006, 2007 Lennert Stock. All rights reserved. Last update: Mon Sep 03 2007, 21:50 CET.