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 store.php

Documentation is available at store.php

  1. <?php
  2. /**
  3.  * The Shop's Store
  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: store.php 308 2007-09-02 19:18:58Z 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.  * The Shop's Store
  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 Store extends DpPage
  40. {
  41.     private $mrSilverKeyObj;
  42.  
  43.     private $mrTrophyObj;
  44.  
  45.     /**
  46.      * Sets up the page at object creation time
  47.      */
  48.     public function createDpPage()
  49.     {
  50.         // Standard setup calls:
  51.         $this->title dp_text("The Shop's Store");
  52.         $this->setBody(sprintf(dp_text('You are in the store of the shop. You
  53. can leave <a href="%s">west</a> to the shop.<br />'),
  54.             DPSERVER_CLIENT_URL '?location=/page/shop.php'));
  55.         $this->setNavigationTrail(
  56.             array(DPUNIVERSE_NAVLOGO''),
  57.             array(dp_text('Showcases')DPUNIVERSE_PAGE_PATH
  58.             . 'showcases.php'));
  59.         $this->addExit(explode('#'dp_text('w#shop#out#exit')),
  60.             DPUNIVERSE_PAGE_PATH 'shop.php');
  61.     }
  62.  
  63.     /**
  64.      * Called at regular intervals
  65.      */
  66.     public function resetDpPage()
  67.     {
  68.         if (is_null($this->mrSilverKeyObj)
  69.                 || !$this->isPresent($this->mrSilverKeyObj)) {
  70.             // Creates a silver key based on the standard DpObject, moves it
  71.             // here:
  72.             $this->mrSilverKeyObj get_current_dpuniverse()->newDpObject(
  73.                 DPUNIVERSE_STD_PATH 'DpObject.php');
  74.             $this->mrSilverKeyObj->addId(dp_text('key'));
  75.             $this->mrSilverKeyObj->title dp_text('silver key');
  76.             $this->mrSilverKeyObj->titleDefinite dp_text('the silver key');
  77.             $this->mrSilverKeyObj->titleIndefinite dp_text('a silver key');
  78.             $this->mrSilverKeyObj->titleImg DPUNIVERSE_IMAGE_URL
  79.                 . 'silver_key.png';
  80.             $this->mrSilverKeyObj->titleImgWidth 44;
  81.             $this->mrSilverKeyObj->titleImgHeight 46;
  82.             $this->mrSilverKeyObj->body '<img src="' DPUNIVERSE_IMAGE_URL
  83.                 . 'silver_key.png" width="44" height="46" border="0" '
  84.                 . 'alt="" align="left" style="margin-right: 15px" />'
  85.                 . dp_text('A plain silver key.<br />You wonder what it can unlock...');
  86.             $this->mrSilverKeyObj->value 50;
  87.             $this->mrSilverKeyObj->coinherit(DPUNIVERSE_STD_PATH 'mass.php');
  88.             $this->mrSilverKeyObj->weight 1;
  89.             $this->mrSilverKeyObj->volume 1;
  90.             $this->mrSilverKeyObj->moveDpObject($this);
  91.         }
  92.  
  93.         if (is_null($this->mrTrophyObj||
  94.                 !$this->isPresent($this->mrTrophyObj)) {
  95.             // Creates a trophy based on the standard DpObject, moves it here:
  96.             $this->mrTrophyObj get_current_dpuniverse()->newDpObject(
  97.                 DPUNIVERSE_STD_PATH 'DpObject.php');
  98.             $this->mrTrophyObj->addId(explode('#',
  99.                 dp_text('trophy#dutchpipe trophy')));
  100.             $this->mrTrophyObj->title dp_text('DutchPIPE trophy');
  101.             $this->mrTrophyObj->titleDefinite dp_text('the DutchPIPE trophy');
  102.             $this->mrTrophyObj->titleIndefinite dp_text('a DutchPIPE trophy');
  103.             $this->mrTrophyObj->titleImg DPUNIVERSE_IMAGE_URL 'trophy.gif';
  104.             $this->mrTrophyObj->titleImgWidth 80;
  105.             $this->mrTrophyObj->titleImgHeight 100;
  106.             $this->mrTrophyObj->body '<img src="' DPUNIVERSE_IMAGE_URL
  107.                 . 'trophy_body.gif" width="129" height="161" border="0" '
  108.                 . 'alt="" align="left" style="margin-right: 15px" />'
  109.                 . dp_text('A shiny trophy earned on a DutchPIPE showcase.');
  110.             $this->mrTrophyObj->value 526;
  111.             $this->mrTrophyObj->coinherit(DPUNIVERSE_STD_PATH 'mass.php');
  112.             $this->mrTrophyObj->weight 3;
  113.             $this->mrTrophyObj->volume 2;
  114.             $this->mrTrophyObj->moveDpObject($this);
  115.         }
  116.     }
  117.  
  118.     function filterAppearance($level&$from$appearance&$user)
  119.     {
  120.         if (=== $level && !$from[0]->isNoBuy{
  121.             $appearance .= '<br />' sprintf(dp_text('%d credits'),
  122.                 $this->getBuyValue($from[0]->value));
  123.         }
  124.  
  125.         return $appearance;
  126.     }
  127.  
  128.     function getBonusValue($value)
  129.     {
  130.         if (== $value || !($user get_current_dpuser())) {
  131.             return 0;
  132.         }
  133.  
  134.         $bonus 5;
  135.  
  136.         return round(($value $bonus100);
  137.     }
  138.  
  139.     function getSellValue($value)
  140.     {
  141.         $result $value $this->getBonusValue($value);
  142.  
  143.         return == $result && $value $result;
  144.     }
  145.  
  146.     function getBuyValue($value)
  147.     {
  148.         $result $value $this->getBonusValue($value);
  149.  
  150.         return == $result && $value $result;
  151.     }
  152. }
  153. ?>

Documentation generated on Mon, 03 Sep 2007 22:22:42 +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.