Source for file DpDrink.php
Documentation is available at DpDrink.php
* A common drink which can be turned into beers, wine, etc.
* 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: DpDrink.php 278 2007-08-19 22:52:25Z ls $
* @link http://dutchpipe.org/manual/package/DutchPIPE
* Builts upon the standard DpObject class
* A common drink which can be turned into beers, wine, etc.
* Creates the following DutchPIPE properties:<br />
* - boolean <b>isFull</b> - Set to TRUE
* - boolean <b>isDrink</b> - Set to TRUE
* - boolean <b>isNoSell</b> - Set to TRUE
* - string <b>emptyTitle</b> - Title for empty drink
* - string <b>emptyTitleDefinite</b> - Definite title for empty drink
* - string <b>emptyTitleIndefinite</b> - Indefinite title for empty drink
* - string <b>emptyTitleImg</b> - Image for empty drink
* - array <b>emptyIds</b> - Id strings for empty drink
* - array <b>origIds</b> - Id strings for filled drink
* - string <b>origTitle</b> - Title for filled drink
* - string <b>origTitleImg</b> - Image for filled drink
* - string <b>origBody</b> - Body for filled drink
* @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
* Creates this drink object
* Called by DpDrink when this object is created. Adds standard actions
* which can be performed on this object.
* Calls {@link createDpDrink()} in the inheriting class.
$this->weight = 100; /* Grams */
$this->weight = 3.5; /* Ounces */
* Sets this drink object up at the time it is created
* An empty function which can be redefined by the drink object extending on
* DpDrink. When the object is created, it has no title, HTML body, et
* cetera, so in this method methods like {@link DpObject::setTitle()} are
* Resets this drink object
* Called by DpObject at regular intervals as defined in dpuniverse-ini.php.
* Calls the method 'resetDpDrink' in this drink object. You can redefine
* that function to periodically do stuff such as alter the state of this
* Resets this drink object
* Called by this drink object at regular intervals as defined in
* dpuniverse-ini.php. An empty function which can be redefined by the
* drink object extending on DpDrink. To be used to periodically do stuff
* such as alter the state of the drink object.
* Fill or empty the drink
* Adjusts the drink's appearance and behaviour. Without an argument,
* fills the drink. Drink objects are filled by default after being created.
* Drink objects which are filled have the property "isFull" set to TRUE in
* @param string $isFull TRUE to fill, FALSE to empty drink
public function setFull($isFull = TRUE)
$this->setIds($this->emptyIds);
$this->setTitleDefinite($this->emptyTitleDefinite);
$this->setTitleIndefinite($this->emptyTitleIndefinite);
$this->setTitleImg($this->emptyTitleImg);
$this->setIds($this->origIds);
$this->setTitleDefinite($this->origTitleDefinite);
$this->setTitleIndefinite($this->origTitleIndefinite);
$this->setTitleImg($this->origTitleImg);
* Makes a living object drink this object
* Drinks the drink if $noun is a valid id for this drink and the drink is
* @param string $verb the action, "drink"
* @param string $noun what to drink, could be empty
* @return boolean TRUE for action completed, FALSE otherwise
dp_text('What do you want to drink?<br />'));
&& $env->isPresent($noun) !== $this) {
$user->tell(dp_text('You must pick it up first.<br />'));
if (FALSE === $this->isFull) {
$this->origIds = $this->getIds();
$this->origTitleImg = $this->getTitleImg();
$this->origBody = $this->getBody();
if (FALSE !== ($env = $user->getEnvironment())) {
$env->tell('<window autoclose="2500" styleclass="dpwindow_drink">'
. '<h1>' . dp_text('BUUUUUUUUUUUUUURRRP!') . '</h1></window>',
$user->tell('<window autoclose="2500" styleclass="dpwindow_drink">'
. '<h1>' . dp_text('BUUUUUUUUUUUUUURRRP!') . '</h1></window>');
$env->tell(array('abstract' =>
. $this->getUniqueId() . '">'
'graphical' => '<changeDpElement id="'
. $this->getUniqueId() . '">'
. '</changeDpElement>'));
* Prevents insertion into containers, not used yet
* @return boolean TRUE if this drink can't be inserted, FALSE to allow
if (FALSE === $this->isFull) {
dp_text('You would spill it out.<br />'));
|