Source for file mobile.php
Documentation is available at mobile.php
* 'Mobile' class to create a mobile computer generated character
* 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_npc
* @author Lennert Stock <ls@dutchpipe.org>
* @copyright 2006, 2007 Lennert Stock
* @license http://dutchpipe.org/license/1_0.txt DutchPIPE License
* @version Subversion: $Id: mobile.php 308 2007-09-02 19:18:58Z ls $
* @link http://dutchpipe.org/manual/package/DutchPIPE
* Builts upon the standard DpNpc class
* A mobile computer generated character
* Creates the following DutchPIPE properties:<br />
* - boolean <b>isSilent</b> - Set to FALSE
* - boolean <b>isNoCleanUp</b> - Set to TRUE
* @subpackage dpuniverse_npc
* @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
* Array to be filled with chat lines
* Sets up the NPC at object creation time
$this->title = dp_text('mobile NPC');
$this->titleDefinite = dp_text('the mobile NPC');
$this->titleIndefinite = dp_text('a mobile NPC');
$this->titleImgWidth = 66;
$this->titleImgHeight = 100;
dp_text('A mobile computer generated character that runs around the website.<br />');
dp_text("The mobile NPC says: This is sooo depressing.<br />"),
dp_text("The mobile NPC says: How boring.<br />"),
dp_text("The mobile NPC says: Oh this is so exciting.<br />"));
* Called each 'heartbeat', randomly chat and wander
// :KLUDGE: mt_rand behaves badly with small nummers on some
// systems, 30 is added/reduced everywhere
elseif ((33 === mt_rand(30, 40)) && FALSE === $env_is_bar
if ($env->isPresent(dp_text('glass'))) {
dp_text('say What a mess, and who has to clean it up? Yes...'));
DpNpc::timeoutHeartBeat();
* Leaves through a random link
|| !($exits = $env->getExits())
|| !($exits_cnt = count($exits))) {
$rnd = mt_rand(30, 30 + ($exits_cnt - 1)) - 30;
$rnd_link = $keys[mt_rand(0, $exits_cnt - 1)];
} while ($rnd_link === dp_text('login'));
$linkcommand = explode(' ', $rnd_link);
* Gives the mobile a good hard kick!
* @param string $verb the action, "kick"
* @param string $noun who to kick, could be empty
* @return boolean TRUE for action completed, FALSE otherwise
$living->setActionFailure(dp_text('Kick who?<br />'));
if (!$this->isId($noun)) {
dp_text('%s is not here.<br />'), $noun)));
'%s gives you a good hard kick!<br/>'),
$env->tell('<window autoclose="2500" styleclass="dpwindow_drink">'
. '<div style="text-align: center"><h1>' . dp_text('*KICK*')
. '</h1></div></window>');
// Fetch beer in a few seconds:
* Makes the mobile complain and take a random exit
dp_text("say Oh, ok, I know when I'm not wanted."));
* Toggles between silent/talking&moving mode, admininistators only
* @param string $verb the action, "silence!"
* @param string $noun who to silence, could be empty
* @return boolean TRUE for action completed, FALSE otherwise
$living->setActionFailure(dp_text('Silence who?<br />'));
if (!$this->isId($noun)) {
$this->isSilent = !$this->isSilent;
$living->getTitle(), $this->getTitle()), $living);
$living->getTitle(), $this->getTitle()), $living);
|