Source for file DpNpc.php
Documentation is available at DpNpc.php
* A 'non playing character', a bot
* DutchPIPE version 0.4; PHP version 5
* LICENSE: This source file is subject to version 1.0 of the DutchPIPE license.
* If you did not receive a copy of the DutchPIPE license, you can obtain one at
* http://dutchpipe.org/license/1_0.txt or by sending a note to
* license@dutchpipe.org, in which case you will be mailed a copy immediately.
* @subpackage dpuniverse_std
* @author Lennert Stock <ls@dutchpipe.org>
* @copyright 2006, 2007 Lennert Stock
* @license http://dutchpipe.org/license/1_0.txt DutchPIPE License
* @version Subversion: $Id: DpNpc.php 278 2007-08-19 22:52:25Z ls $
* @link http://dutchpipe.org/manual/package/DutchPIPE
* Builts upon the standard DpLiving class
* A 'non playing character', a bot
* Creates the following DutchPIPE properties:<br />
* - boolean <b>isNpc</b> - Set to TRUE
* @subpackage dpuniverse_std
* @author Lennert Stock <ls@dutchpipe.org>
* @copyright 2006, 2007 Lennert Stock
* @license http://dutchpipe.org/license/1_0.txt DutchPIPE License
* @version Release: 0.2.1
* @link http://dutchpipe.org/manual/package/DutchPIPE
* Called by DpLiving when this object is created.
* Calls {@link createDpNpc()} in the inheriting class.
// Standard setup calls to set some default values:
$this->setTitleDefinite(dp_text('the NPC'));
$this->setTitleIndefinite(dp_text('a NPC'));
// Call CreateDpNpc for objects that extend on this object:
* Sets this NPC up at the time it is created
* An empty function which can be redefined by the NPC class extending on
* DpNpc. When the object is created, it has no title, HTML body, et cetera,
* so in this method methods like {@link DpObject::setTitle()} are called.
* Called by DpLiving at regular intervals as defined in dpuniverse-ini.php.
* Calls the method 'resetDpNpc' in this NPC. You can redefine that function
* to periodically do stuff such as alter the state of this NPC.
* Called by this NPC at regular intervals as defined in dpuniverse-ini.php.
* An empty function which can be redefined by the NPC class extending on
* DpNpc. To be used to periodically do stuff such as alter the state of the
* Tells data (message, window, location, ...) to this NPC
* Tells a message to this NPC, for instance a chat line or a new location.
* @param string $data message string
* @see DpObject::tell(), DpUser::tell(), DpPage::tell()
$data = $data[$this->displayMode];
&& FALSE !== ($pos = dp_strpos($data, '>'))) {
$data = "<message><![CDATA[$data]]></message>";
&& FALSE !== ($pos1 = dp_strpos($data, '<location><![CDATA['))
&& FALSE !== ($pos2 = dp_strpos($data, ']]></location>'))
if (!$newlocation || '/' === $newlocation) {
|| $env !== $newlocation) {
$newlocation->getTitle()), $this);
$newlocation->tell($from_where, $this);
|