Source for file shop.php
Documentation is available at shop.php
* 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://www.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_page
* @author Lennert Stock <ls@dutchpipe.org>
* @copyright 2006, 2007 Lennert Stock
* @license http://dutchpipe.org/license/1_0.txt DutchPIPE License
* @version Subversion: $Id: shop.php 281 2007-08-20 21:45:53Z ls $
* @link http://dutchpipe.org/manual/package/DutchPIPE
* Builts upon the standard DpPage class
* @subpackage dpuniverse_page
* @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
* Sets up the page at object creation time
$this->title = dp_text('A Small Shop');
width="352" height="264" border="0" usemap="#shop_map" alt=""
style="border: solid 1px black; margin-right: 10px" title="" alt=""
<div style="width: 220px; float: left">
<br /><b>' . dp_text('Small Shop') . '</b><br />'
where you can buy and sell things. Try this
<a href="javascript:send_action2server(\'list\')">list</a> to view all items for
<a href="javascript: send_action2server(\'inventory\')">inventory</a> to see
what you can sell.</p><p align="justify">An exit <a href="%s">west</a> leads
back to the village square.</p>',
. '</div><br clear="all" />'), 'text');
dp_text('w#square#out#exit#leave#leave shop')),
array('shop_map', 'square_area', 'rect',
$who->removeAction('sell');
* Called at regular intervals
$inventory = $store->getAppearance(0, TRUE, NULL,
$title = dp_text('The shop has the following items for sale:');
"<window name=\"list\">$title$inventory</window>");
if ($from[0]->getEnvironment() === $user && 1 === $level
&& !$from[0]->isNoSell) {
$appearance .= '<br /><a href="javascript:send_action2server(\''
$store->getSellValue($from[0]->value)) . '</a>';
if (!($item = $store->isPresent($noun))) {
dp_text('That item ("%s") is not for sale here.<br />'),
$price = $store->getBuyValue($item->value);
if ($user->credits < $price) {
dp_text("%s costs %d credits, which you don't have.<br />"),
if (TRUE !== ($move_result = $item->moveDpObject($user))) {
dp_text("You cannot carry %s, it is too heavy. Drop something else first.<br />"),
dp_text("You cannot carry %s, it takes too much volume. Drop something else first.<br />"),
dp_text("You fail to buy %s as it cannot be moved.<br />"),
$user->credits -= $price;
if (($env = $user->getEnvironment()) && $env === $this) {
$user->tell('<refreshDpWindow name="list" action="' . dp_text('list')
. '"> </refreshDpWindow>');
$user->tell('<refreshDpWindow name="inventory" action="'
. dp_text('inventory') . '"> </refreshDpWindow>');
if (!($item = $user->isPresent($noun))) {
dp_text("You don't own that item (\"%s\").<br />"), $noun));
if ($item->isDrink && $item->isFull) {
$user->tell(dp_text("The shop doesn't accept filled glasses and liquids.<br />"));
if (0 == ($price = $store->getSellValue($item->value))) {
} elseif ($item->isNoSell
|| TRUE !== ($move_result = $item->moveDpObject($store))) {
$user->credits += $price;
if (($env = $user->getEnvironment()) && $env === $this) {
* Makes this living object examine an object
* @param string $verb the action, "examine"
* @param string $noun what to examine, could be empty
* @return boolean TRUE for action completed, FALSE otherwise
$user->setActionFailure(dp_text('See what item for sale?<br />'));
if (!($item = $store->isPresent($noun))) {
dp_text('That item ("%s") is not for sale here.<br />'), $noun));
$user->tell('<window>' . $item->getAppearance(0, TRUE, NULL,
$this->displayMode, FALSE, 'dpobinv') . '</window>');
|