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

Source for file alley.php

Documentation is available at alley.php

  1. <?php
  2. /**
  3.  * In Front Of A House
  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_page
  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: alley.php 278 2007-08-19 22:52:25Z ls $
  18.  * @link       http://dutchpipe.org/manual/package/DutchPIPE
  19.  * @see        DpPage
  20.  */
  21.  
  22. /**
  23.  * Builts upon the standard DpPage class
  24.  */
  25. inherit(DPUNIVERSE_STD_PATH 'DpPage.php');
  26.  
  27. /**
  28.  * In Front Of A House
  29.  *
  30.  * @package    DutchPIPE
  31.  * @subpackage dpuniverse_page
  32.  * @author     Lennert Stock <ls@dutchpipe.org>
  33.  * @copyright  2006, 2007 Lennert Stock
  34.  * @license    http://dutchpipe.org/license/1_0.txt  DutchPIPE License
  35.  * @version    Release: 0.2.1
  36.  * @link       http://dutchpipe.org/manual/package/DutchPIPE
  37.  * @see        DpPage
  38.  */
  39. final class Alley extends DpPage
  40. {
  41.     /**
  42.      * Sets up the page at object creation time
  43.      */
  44.     public function createDpPage()
  45.     {
  46.         // Standard setup calls:
  47.         $this->title dp_text('In Front Of A House');
  48.         $this->addItem(explode('#'dp_text('door#simple door')),
  49.             dp_text('A simple door. It is %s.')'getDoorStatusStr',
  50.             'door_area');
  51.         $this->setNavigationTrail(
  52.             array(DPUNIVERSE_NAVLOGO''),
  53.             array(dp_text('Showcases')DPUNIVERSE_PAGE_PATH
  54.             . 'showcases.php'));
  55.         $this->setMapArea('alley_map''door_area''rect''142,223,196,274');
  56.         $this->addExit(explode('#'dp_text('sw#square')),
  57.             DPUNIVERSE_PAGE_PATH 'square.php'NULL,
  58.             array('alley_map''square_area''rect''25,311,400,336'));
  59.  
  60.         $this->houseObj new_dp_property(FALSE);
  61.         $this->isDoorUnlocked new_dp_property(FALSE);
  62.         $this->isDoorUnlocked FALSE;
  63.     }
  64.  
  65.     /**
  66.      * Called at regular intervals
  67.      */
  68.     public function resetDpPage()
  69.     {
  70.         if ($this->isDoorUnlocked{
  71.             $this->isDoorUnlocked FALSE;
  72.         }
  73.     }
  74.  
  75.     function isExitOpened()
  76.     {
  77.         if (!$this->isDoorUnlocked{
  78.             $user get_current_dpobject();
  79.  
  80.             $user->tell(dp_text("The door of the house is locked.<br />"));
  81.             return FALSE;
  82.         }
  83.  
  84.         return TRUE;
  85.     }
  86.  
  87.     public function setIsDoorUnlocked($isDoorUnlocked$updateHouse TRUE)
  88.     {
  89.         $this->setDpProperty('isDoorUnlocked'$isDoorUnlocked);
  90.  
  91.         if ($updateHouse{
  92.             if (!$this->houseObj{
  93.                 $this->houseObj get_current_dpuniverse()->getDpObject(
  94.                     DPUNIVERSE_PAGE_PATH 'house.php');
  95.             }
  96.  
  97.             $this->houseObj->setIsDoorUnlocked($isDoorUnlockedFALSE);
  98.         }
  99.  
  100.         $this->body '<img src="' DPUNIVERSE_IMAGE_URL
  101.             . 'alley.jpg" width="450" height="336" border="0"
  102. usemap="#alley_map" style="border: solid 1px black; margin-right: 10px""
  103. title="" alt="" align="left" /><div style="width: 220px; float: left"><br /><b>'
  104.             . dp_text('In Front Of A House''</b><br /><p align="justify">'
  105.             . (!$isDoorUnlocked
  106. sprintf(dp_text('The stone paved alley ends here in front of a large brick
  107. house.</p><p align="justify">To the <a href="%s">southwest</a> you see a
  108. square.')DPSERVER_CLIENT_URL '?location=/page/square.php')
  109. sprintf(dp_text('The stone paved alley ends here in front of a large brick
  110. house.</p><p align="justify">A door leads <a href="%s">inside</a>. To the
  111. <a href="%s">southwest</a> you see a square.'),
  112.             DPSERVER_CLIENT_URL '?location=/page/house.php',
  113.             DPSERVER_CLIENT_URL '?location=/page/square.php'))
  114.             . '</p></div><br clear="all" />';
  115.  
  116.         $this->removeAction(dp_text('unlock')'door_area');
  117.         $this->removeAction(dp_text('lock')'door_area');
  118.         $this->removeExit(dp_text('n'));
  119.  
  120.         if (!$isDoorUnlocked{
  121.             $this->addAction(dp_text('unlock door')dp_text('unlock'),
  122.                 'actionUnlock'DP_ACTION_OPERANT_MENUDP_ACTION_TARGET_SELF,
  123.                 DP_ACTION_AUTHORIZED_ALLDP_ACTION_SCOPE_INVENTORY,
  124.                 'door_area'dp_text('unlock door'));
  125.             $this->addAction(dp_text('lock')dp_text('lock')'actionLock',
  126.                 DP_ACTION_OPERANT_MENUDP_ACTION_TARGET_SELF,
  127.                 DP_ACTION_AUTHORIZED_ALLDP_ACTION_SCOPE_INVENTORY);
  128.             $this->addExit(explode('#',
  129.                 dp_text('n#house#enter house#inside#door#enter door')),
  130.                 DPUNIVERSE_PAGE_PATH 'house.php''isExitOpened');
  131.         else {
  132.             $this->addAction(dp_text('unlock')dp_text('unlock'),
  133.                 'actionUnlock'DP_ACTION_OPERANT_MENUDP_ACTION_TARGET_SELF,
  134.                 DP_ACTION_AUTHORIZED_ALLDP_ACTION_SCOPE_INVENTORY);
  135.             $this->addAction(dp_text('lock door')dp_text('lock'),
  136.                 'actionLock'DP_ACTION_OPERANT_MENUDP_ACTION_TARGET_SELF,
  137.                 DP_ACTION_AUTHORIZED_ALLDP_ACTION_SCOPE_INVENTORY,
  138.                 'door_area'dp_text('lock door'));
  139.             $this->addExit(explode('#',
  140.                 dp_text('n#house#enter house#inside#door#enter door')),
  141.                 DPUNIVERSE_PAGE_PATH 'house.php',
  142.                 'isExitOpened''door_area'dp_text('enter house'));
  143.         }
  144.  
  145.         $this->tell('<changeDpElement id="dppage_body">' $this->getBody()
  146.             . '</changeDpElement>');
  147.     }
  148.  
  149.     public function actionUnlock($verb$noun)
  150.     {
  151.         if (dp_text('door'!= $noun && dp_text('door with key'!= $noun
  152.                 && dp_text('door with silver key'!= $noun{
  153.             $this->setActionFailure(dp_text('Unlock what?'));
  154.             return FALSE;
  155.         }
  156.         $user get_current_dpuser();
  157.  
  158.         if (!($key $user->isPresent(dp_text('silver key')))) {
  159.             $user->tell(dp_text("You don't have the right key to unlock the door.<br />"));
  160.             return TRUE;
  161.         }
  162.  
  163.         if ($this->isDoorUnlocked{
  164.             $user->tell(dp_text('The door is already unlocked.<br />'));
  165.             return TRUE;
  166.         }
  167.  
  168.         $user->tell(sprintf(
  169.             dp_text('You unlock the door with %s. You can now enter the building.<br />'),
  170.             $key->getTitle(DPUNIVERSE_TITLE_TYPE_DEFINITE)));
  171.         $this->tell(ucfirst(sprintf(
  172.             dp_text('%s unlocks the door.<br />'),
  173.             $user->getTitle(DPUNIVERSE_TITLE_TYPE_DEFINITE))),
  174.             $user);
  175.         $this->isDoorUnlocked TRUE;
  176.  
  177.         return TRUE;
  178.     }
  179.  
  180.     public function actionLock($verb$noun)
  181.     {
  182.         if (dp_text('door'!= $noun && dp_text('door with key'!= $noun
  183.                 && dp_text('door with silver key'!= $noun{
  184.             $this->setActionFailure(dp_text('Lock what?'));
  185.             return FALSE;
  186.         }
  187.  
  188.         $user get_current_dpuser();
  189.  
  190.         if (!($key $user->isPresent(dp_text('silver key')))) {
  191.             $user->tell(dp_text("You don't have the right key to lock the door.<br />"));
  192.             return TRUE;
  193.         }
  194.  
  195.         if (!$this->isDoorUnlocked{
  196.             $user->tell(dp_text('The door is already locked.<br />'));
  197.             return TRUE;
  198.         }
  199.  
  200.         $user->tell(sprintf(dp_text('You lock the door with %s.<br />'),
  201.             $key->getTitle(DPUNIVERSE_TITLE_TYPE_DEFINITE)));
  202.         $this->tell(ucfirst(sprintf(
  203.             dp_text('%s locks the door.<br />'),
  204.             $user->getTitle(DPUNIVERSE_TITLE_TYPE_DEFINITE))),
  205.             $user);
  206.         $this->isDoorUnlocked FALSE;
  207.  
  208.         return TRUE;
  209.     }
  210.  
  211.     public function getDoorStatusStr($item)
  212.     {
  213.         return $this->isDoorUnlocked dp_text('unlocked'dp_text('locked');
  214.     }
  215. }
  216. ?>

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

Click me!
Guest#214
 
 
 
  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.