From faefddcb8b3d3ac491331b702f8a8ac6fe58a894 Mon Sep 17 00:00:00 2001 From: piernov Date: Sun, 8 May 2016 20:14:40 +0200 Subject: First PHPDoc push, Inventory not complete --- inc/Inventory.inc | 39 ++++++++++++++++++++++++++-- inc/Item.inc | 58 +++++++++++++++++++++++++++++++++++++++-- inc/Monster.inc | 44 ++++++++++++++++++++++++++++--- inc/account.inc | 19 ++++++++++++++ inc/craftmine.inc | 12 +++++++++ inc/dungeon.inc | 50 +++++++++++++++++++++++++++++++++--- inc/guild.inc | 29 +++++++++++++++++++++ inc/messages.inc | 33 ++++++++++++++++++++++++ inc/mine.inc | 21 +++++++++++++++ inc/perso.inc | 27 +++++++++++++++++++ inc/savegame.inc | 77 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ inc/shop.inc | 59 ++++++++++++++++++++++++++++++++++++------ 12 files changed, 449 insertions(+), 19 deletions(-) (limited to 'inc') diff --git a/inc/Inventory.inc b/inc/Inventory.inc index 2be48f8..dd65ee5 100644 --- a/inc/Inventory.inc +++ b/inc/Inventory.inc @@ -1,17 +1,40 @@ items; } + /** + * Returns the Inventory from the session. + * Implements the singleton pattern. + * + * @return Inventory the Inventory object + */ public static function get() { if(!self::created()) { $_SESSION["inventory"] = new Inventory(); @@ -19,6 +42,12 @@ class Inventory { return $_SESSION["inventory"]; } + /** + * Adds an Item object to the Inventory, incrementing the Item's count if it was already present. + * + * @param Item $item Item to add to the Inventory + * @return array Item and Item's count + */ private function _addItem($item) { foreach($this->items as $k => $object){ if($object[0] == $item){ @@ -31,6 +60,12 @@ class Inventory { return $tab; } + /** + * Adds an Item object to the singleton's Inventory from session. + * + * @param Item $item Item to add to the Inventory + * @return array Item and Item's count + */ public static function addItem($item) { $inv = self::get(); $tab = $inv->_addItem($item); diff --git a/inc/Item.inc b/inc/Item.inc index 8eebbf8..4ec984f 100644 --- a/inc/Item.inc +++ b/inc/Item.inc @@ -2,13 +2,49 @@ require_once("perso.inc"); +/** + * Represent an Item in the shop or in the Inventory. + * + * @author Alexandre Renoux + * @author Pierre-Emmanuel Novac + */ class Item { + + /** + * Name of the item. + */ public $name = ""; + + /** + * Item's cost. + */ public $cost = 0; + + /** + * Item's icon. + */ public $icon = ""; + + /** + * Item's description. + */ public $desc = ""; + + /** + * Item's features as an associative array + */ public $feat = array(); + /** + * Item's constructor + * + * @param string $name Item's name + * @param int $cost Item's cost + * @param string $icon Item's icon + * @param string $desc Item's description + * @param array $feat associative array of strings describing the Item's features + * @return void + */ function __construct($name, $cost, $icon, $desc, $feat) { $this->name = $name; $this->cost = $cost; @@ -17,15 +53,27 @@ class Item { $this->feat = $feat; } + /** + * Applies Item's features on the player. + * + * @return void + */ function consume() { foreach($this->feat as $k => $v) { switch($k) { case "hp": increasePerso("hp", +$v); break; - case "power": break; + case "power": break; // TODO: do something with power } } } + /** + * Generates an XML tree describing the Item + * + * @param SimpleXMLElement $xml root XML element to add the Item's property to + * @param int $count numbers of Items + * @return void + */ function addToXML($root, $count) { $item = $root->addChild("item"); $item->addChild("name", $this->name); @@ -38,12 +86,18 @@ class Item { $item->addChild("count", $count); } + /** + * Generates an Item object from an XML tree + * + * @param SimpleXMLElement $xml root XML element representing the Item + * @return void + */ public static function fromXML($xml) { $feats = array(); foreach($xml->feat[0] as $k => $v) $feats[(string)$k] = (string)$v; - return new static((string)$xml->name, +(string)$xml->cost /* convert to number */, (string)$xml->icon, (string)$xml->desc, $feats); + return new static((string)$xml->name, +(string)$xml->cost /* convert to number */, (string)$xml->icon, (string)$xml->desc, $feats); // Call constructor } } diff --git a/inc/Monster.inc b/inc/Monster.inc index c7063ec..4450b59 100644 --- a/inc/Monster.inc +++ b/inc/Monster.inc @@ -1,20 +1,58 @@ name = $name; $this->level = $level; $this->hp = $hp; $this->xp = $xp; $this->icon = $icon; - } } diff --git a/inc/account.inc b/inc/account.inc index 6f398bb..bfbd47b 100644 --- a/inc/account.inc +++ b/inc/account.inc @@ -1,6 +1,19 @@ sendMine(), "shop" => sendShop(), diff --git a/inc/dungeon.inc b/inc/dungeon.inc index c023cf8..05dc57d 100644 --- a/inc/dungeon.inc +++ b/inc/dungeon.inc @@ -1,12 +1,23 @@ (string)$monsters["cost"],"monsters"=>array()); + $dungeon = array("cost"=>(string)$monsters["cost"],"monsters"=>array()); //TODO: again, cost is a string? foreach($monsters as $f){ $floor = (string)$f["name"]; $dungeon["monsters"][$floor] = array(); @@ -21,16 +32,32 @@ function generateMonster(){ return $dungeon; } +/** + * Marks the dungeon as accessible in the session. + * + * @return void + */ function initDungeon() { - $_SESSION["dungeon"]["access"] = true; + $_SESSION["dungeon"]["access"] = true; // TODO: is the $_SESSION["dungeon"] array useful (and created beforehand)? } +/** + * Returns the dungeon array if it was created. + * + * @return array dungeon array as created by generateMonster + */ function sendDungeon() { if(!empty($_SESSION["dungeon"])) return $_SESSION["dungeon"]; else return false; } +/** + * Allows acces to the dungeon in the session and sends it to the client. + * Debits the dungeon's ticket cost from the player's gold. + * + * @return void + */ function buildDungeon() { $dungeon=generateMonster(); if(!empty($_SESSION["dungeon"])) { @@ -38,11 +65,16 @@ function buildDungeon() { } elseif(debitAccount($dungeon["cost"])) { initDungeon(); - $_SESSION["mine"]["gold"] -= $dungeon["cost"]; + $_SESSION["mine"]["gold"] -= $dungeon["cost"]; // TODO: Account was already debited echo json_encode($dungeon); } } +/** + * Sends monsters for a specific floor as specified by the floor POST parameter to the client. + * + * @return void + */ function launchDungeon(){ $f= $_POST["floor"]; $dungeon=generateMonster(); @@ -50,6 +82,11 @@ function launchDungeon(){ echo json_encode($opponent); } +/** + * Updates floor and monster number from the POST parameters in the session. + * + * @return void + */ function sendDungeonProgress(){ $f= $_POST["floor"]; $nb=$_POST["mob"]; @@ -57,6 +94,11 @@ function sendDungeonProgress(){ $_SESSION["dungeon"]["mob"] = $nb; } +/** + * Marks the dungeon as not accessible in the session. + * + * @return void + */ function exitDungeon(){ $_SESSION["dungeon"] = false; diff --git a/inc/guild.inc b/inc/guild.inc index c0e8264..f348348 100644 --- a/inc/guild.inc +++ b/inc/guild.inc @@ -1,8 +1,26 @@ "You have already built a shop.", "gold_insufficient" => "You don't have enough gold.", @@ -18,6 +27,14 @@ $messages = array( "upload_success" => "Save file uploaded successfully: %s", ); +/** + * Sends a message to the client. + * + * @param string $type message type, for example "info" or "error" + * @param string $msg message content + * @param string $fmt optional parameters to apply when formating message string + * @return void + */ function sendMessage($type, $msg, $fmt = null) { global $messages; $text = $messages[$msg]; @@ -25,10 +42,26 @@ function sendMessage($type, $msg, $fmt = null) { echo json_encode(array($type => $text)); } +/** + * Sends an error message to the client. + * Simple wrapper calling sendMessage with "error" as $type. + * + * @param string $msg message content + * @param string $fmt optional parameters to apply when formating message string + * @return void + */ function sendError($msg, $fmt = null) { sendMessage("error", $msg, $fmt); } +/** + * Sends an info message to the client. + * Simple wrapper calling sendMessage with "info" as $type. + * + * @param string $msg message content + * @param string $fmt optional parameters to apply when formating message string + * @return void + */ function sendInfo($msg, $fmt = null) { sendMessage("info", $msg, $fmt); } diff --git a/inc/mine.inc b/inc/mine.inc index 752fc69..38dc717 100644 --- a/inc/mine.inc +++ b/inc/mine.inc @@ -1,9 +1,25 @@ 0, "miners" => 0); } +/** + * Transfers all gold from the mine to the player's account. + * + * @return void + */ function withdrawMine() { $amount = intval($_POST["amount"]); if($amount == 0) return; @@ -11,6 +27,11 @@ function withdrawMine() { echo json_encode($_SESSION["mine"]["gold"]); } +/** + * Returns the amount of gold currently owned by the player. + * + * @return int amount of gold available + */ function sendMine() { if(empty($_SESSION["mine"])) initCraftMine(); $mine = $_SESSION["mine"]; diff --git a/inc/perso.inc b/inc/perso.inc index f455173..c81b72b 100644 --- a/inc/perso.inc +++ b/inc/perso.inc @@ -1,17 +1,39 @@ + * sudo chown :http data/save + * sudo chmod g+w data/save + * + */ define("SAVEDIR", "data/save"); +/** + * Recursively generates an XML tree from an array. + * If objects are found, call addToXML() methods which should serialize the object as a child of the XML tree passed as parameter. + * + * @param array $table an array with mixed type elements to convert to XML + * @param SimpleXMLElement $xml root XML to add the elements to + * @return void + */ function genXML($table, $xml) { foreach($table as $k => $v) { if(is_object($v)) { // Object: either Item or Inventory @@ -18,22 +41,44 @@ function genXML($table, $xml) { } } +/** + * Generates the XML save tree from the session. + * + * @return void + */ function genSave() { $save = new SimpleXMLElement(""); genXML($_SESSION, $save); return $save; } +/** + * Generates the save file name using current date/time. + * The date function will use the server's timezone which could be inconsistent with the client timezone. + * + * @return string the generated file name + */ function genFilename() { return "craftmine-".date("d-m-Y_H-i-s").".save.xml"; } +/** + * Save the XML save tree as an XML file named after the results of genFilename in SAVEDIR. + * Fails and send an error the the client if permissions are incorrectly set. Watch for errors in PHP log. + * + * @return void + */ function saveGame() { $save = genSave(); if($save->asXML(SAVEDIR."/".genFilename())) sendInfo("gamesave_ok"); else sendError("gamesave_error"); } +/** + * Sends the current game or a specific save file given by the filename GET parameter to the client. + * + * @return void + */ function downSave() { $save = ""; $filename = ""; @@ -53,11 +98,24 @@ function downSave() { echo $save; } +/** + * Sends the list of available saves to the client. + * Warning: this function changes directory. + * + * @return void + */ function listSaves() { chdir(SAVEDIR); // Go to SAVEDIR folder, avoiding leading folder name in file list echo json_encode(glob("*.save.xml")); } +/** + * Reads an XML tree and deserializes it to an array. + * + * @param SimpleXMLElement $xml root XML to read the elements from + * @param array $table an empty array to stores the elements to, passed by reference + * @return void + */ function parseSave($xml, &$table) { // Passing $table by reference foreach($xml as $k => $v) { if($v->count() == 0) { // No child, treat as string @@ -76,6 +134,11 @@ function parseSave($xml, &$table) { // Passing $table by reference } } +/** + * Deletes a save file given as the filename POST parameter. + * + * @return void + */ function deleteSave() { if(empty($_POST["filename"])) return; $path = SAVEDIR . "/" . basename($_POST["filename"]); // remove any leading directory @@ -84,6 +147,12 @@ function deleteSave() { else sendError("gamesave_delete_fail"); } +/** + * Loads a save file given as the filename POST parameter to the session. + * Empties the session beforehand. + * + * @return void + */ function loadSave() { if(empty($_POST["filename"])) return; $xml = simplexml_load_file(SAVEDIR . "/" . $_POST["filename"]); @@ -95,6 +164,14 @@ function loadSave() { parseSave($xml, $_SESSION); } +/** + * Reads a save file sent by the client. + * Parse the received file then generate it again to clean it for any unwanted + * and make sure that it is a valid XML save file. + * XML errors are simply ignored and an error is sent to the client if something wrong happens. + * + * @return void + */ function uploadSave() { $fname = basename($_FILES['savefile']['name']); $src = $_FILES['savefile']['tmp_name']; diff --git a/inc/shop.inc b/inc/shop.inc index 69161e1..79c6776 100644 --- a/inc/shop.inc +++ b/inc/shop.inc @@ -1,4 +1,10 @@ (string)$items["cost"],"items"=>array()); - foreach($items as $cat){ + $items = simplexml_load_file('data/items.xml'); //TODO: handle errors + $shop = array("cost"=>(string)$items["cost"],"items"=>array()); //TODO: cost is a string? + foreach($items as $cat){ // Loop over all categories $category = (string)$cat["name"]; $shop["items"][$category] = array(); - foreach($cat as $item){ + foreach($cat as $item){ // Loop over all items inside a category $feats = array(); - foreach($item->features[0] as $k => $v) + foreach($item->features[0] as $k => $v) // Reads features $feats[(string)$k] = (string)$v; $shop["items"][$category][] = new Item( (string)$item->name, - intval($item->cost), + intval($item->cost), //Note: cost is an int here. (string)$item->icon, (string)$item->description, $feats); @@ -27,6 +38,12 @@ function loadShop(){ return $shop; } +/** + * Gets an Item object from the shop from its name. + * + * @params string $name the name of the object to search for + * @return Item|false the Item object or false if the item was not found + */ function getItem($name) { $shop=loadShop(); foreach($shop["items"] as $cat) { @@ -40,16 +57,32 @@ function getItem($name) { return false; } +/** + * Marks the shop as created in the session. + * + * @return void + */ function initShop() { $_SESSION["shop"] = true; } +/** + * Returns the shop array if it was created. + * + * @return array shop array as created by loadShop + */ function sendShop() { if(!empty($_SESSION["shop"])) return loadShop(); else return false; } +/** + * Creates the shop in the session and sends it to the client. + * Debits the shop's cost from the player's gold. + * + * @return void + */ function buildShop() { $shop=loadShop(); if(!empty($_SESSION["shop"])) { @@ -61,14 +94,24 @@ function buildShop() { } } +/** + * Debits the item's cost specified as the item POST parameter, adds it to the Inventory and sends it to the client. + * + * @return void + */ function buyItem() { $item = getItem($_POST["item"]); if($item && debitAccount($item->cost)) { - $tab = Inventory::addItem($item); - echo json_encode($tab); //renvoyer un tableau avec comme première entrée $item et comme deuxième entrée le nombre + $tab = Inventory::addItem($item); + echo json_encode($tab); // Sends an array with the Item as first member and count as second. } } +/** + * Invoke useItem on an item passed as the item POST parameter, sends to the client the updated player stats and the item. + * + * @return void + */ function useItem(){ $item = getItem($_POST["item"]); $it = Inventory::useItem($item); -- cgit v1.2.3-54-g00ecf From 07f9658d2fecc5f88cc27fba8502246a30d8fdc0 Mon Sep 17 00:00:00 2001 From: piernov Date: Sun, 8 May 2016 20:39:15 +0200 Subject: Add @package and various fixes --- inc/Inventory.inc | 2 ++ inc/Item.inc | 11 ++++++----- inc/Monster.inc | 13 +++++++------ inc/account.inc | 1 + inc/craftmine.inc | 1 + inc/dungeon.inc | 1 + inc/guild.inc | 1 + inc/messages.inc | 1 + inc/mine.inc | 1 + inc/perso.inc | 1 + inc/savegame.inc | 1 + inc/shop.inc | 1 + 12 files changed, 24 insertions(+), 11 deletions(-) (limited to 'inc') diff --git a/inc/Inventory.inc b/inc/Inventory.inc index dd65ee5..73d82c8 100644 --- a/inc/Inventory.inc +++ b/inc/Inventory.inc @@ -3,6 +3,7 @@ * Represent the player's Inventory. * Implemented as a singleton in the session. * + * @package inc\Inventory.inc * @author Alexandre Renoux * @author Pierre-Emmanuel Novac */ @@ -25,6 +26,7 @@ class Inventory { * Returns the Inventory's content from the session. * * @return array array of Items and number + */ public static function sendContent() { return self::get()->items; } diff --git a/inc/Item.inc b/inc/Item.inc index 4ec984f..404c46b 100644 --- a/inc/Item.inc +++ b/inc/Item.inc @@ -5,33 +5,34 @@ require_once("perso.inc"); /** * Represent an Item in the shop or in the Inventory. * + * @package inc\Item.inc * @author Alexandre Renoux * @author Pierre-Emmanuel Novac */ class Item { /** - * Name of the item. + * @var string Name of the item. */ public $name = ""; /** - * Item's cost. + * @var int Item's cost. */ public $cost = 0; /** - * Item's icon. + * @var string Item's icon. */ public $icon = ""; /** - * Item's description. + * @var string Item's description. */ public $desc = ""; /** - * Item's features as an associative array + * @var array Item's features as an associative array */ public $feat = array(); diff --git a/inc/Monster.inc b/inc/Monster.inc index 4450b59..d8fe619 100644 --- a/inc/Monster.inc +++ b/inc/Monster.inc @@ -2,37 +2,38 @@ /** * Represent an Item in the shop or in the Inventory. * + * @package inc\Monster.inc * @author Alexandre Renoux * @author Pierre-Emmanuel Novac */ class Monster { /** - * Name of the Monster. + * @var string Name of the Monster. */ public $name = ""; /** - * Monster's icon. + * @var string Monster's icon. */ public $icon = ""; /** - * Monster's description. + * @var desc Monster's description. */ public $desc = ""; // TODO: unused /** - * HP of the Monster. + * @var int HP of the Monster. */ public $hp = 1; /** - * Exp given by this monster. + * @var int Exp given by this monster. */ public $xp = 0; /** - * Monster's level. + * @var int Monster's level. */ public $level = 1; diff --git a/inc/account.inc b/inc/account.inc index bfbd47b..f7e3c05 100644 --- a/inc/account.inc +++ b/inc/account.inc @@ -2,6 +2,7 @@ /** * Manages player's account: debit and credit. * + * @package inc\account.inc * @author Alexandre Renoux * @author Pierre-Emmanuel Novac */ diff --git a/inc/craftmine.inc b/inc/craftmine.inc index e72db34..7dd5ba4 100644 --- a/inc/craftmine.inc +++ b/inc/craftmine.inc @@ -2,6 +2,7 @@ /** * Sends all data from previous session on page load. * + * @package inc\craftmine.inc * @author Alexandre Renoux * @author Pierre-Emmanuel Novac */ diff --git a/inc/dungeon.inc b/inc/dungeon.inc index 05dc57d..32d58ac 100644 --- a/inc/dungeon.inc +++ b/inc/dungeon.inc @@ -2,6 +2,7 @@ /** * Manages the dungeon. * + * @package inc\dungeon.inc * @author Alexandre Renoux * @author Pierre-Emmanuel Novac */ diff --git a/inc/guild.inc b/inc/guild.inc index f348348..f4c10af 100644 --- a/inc/guild.inc +++ b/inc/guild.inc @@ -2,6 +2,7 @@ /** * Manages miners guild. * + * @package inc\guild.inc * @author Alexandre Renoux * @author Pierre-Emmanuel Novac */ diff --git a/inc/messages.inc b/inc/messages.inc index 50bbafb..8583dc0 100644 --- a/inc/messages.inc +++ b/inc/messages.inc @@ -2,6 +2,7 @@ /** * Server to client error/info messages list and helpers. * + * @package inc\messages.inc * @author Alexandre Renoux * @author Pierre-Emmanuel Novac */ diff --git a/inc/mine.inc b/inc/mine.inc index 38dc717..d27804a 100644 --- a/inc/mine.inc +++ b/inc/mine.inc @@ -2,6 +2,7 @@ /** * Manages the mine. * + * @package inc\mine.inc * @author Alexandre Renoux * @author Pierre-Emmanuel Novac */ diff --git a/inc/perso.inc b/inc/perso.inc index c81b72b..421b0a8 100644 --- a/inc/perso.inc +++ b/inc/perso.inc @@ -2,6 +2,7 @@ /** * Manages player's stats: life, experience, level. * + * @package inc\perso.inc * @author Alexandre Renoux * @author Pierre-Emmanuel Novac */ diff --git a/inc/savegame.inc b/inc/savegame.inc index 3c5613b..3e3ffcc 100644 --- a/inc/savegame.inc +++ b/inc/savegame.inc @@ -2,6 +2,7 @@ /** * Load and save the game. * + * @package inc\savegame.inc * @author Alexandre Renoux * @author Pierre-Emmanuel Novac */ diff --git a/inc/shop.inc b/inc/shop.inc index 79c6776..2dbd19d 100644 --- a/inc/shop.inc +++ b/inc/shop.inc @@ -2,6 +2,7 @@ /** * Manages the shop. * + * @package inc\shop.inc * @author Alexandre Renoux * @author Pierre-Emmanuel Novac */ -- cgit v1.2.3-54-g00ecf From 1e52affe15fb13e920f8942de998073238be6d01 Mon Sep 17 00:00:00 2001 From: piernov Date: Mon, 9 May 2016 14:05:50 +0200 Subject: Finish Inventory PHPDoc --- doc/phpdoc/classes.svg | 22 +- doc/phpdoc/classes/Inventory.html | 135 +++-------- doc/phpdoc/classes/Item.html | 2 +- doc/phpdoc/classes/Monster.html | 2 +- doc/phpdoc/deprecated.html | 2 +- doc/phpdoc/errors.html | 116 +++------ doc/phpdoc/graph_class.html | 2 +- doc/phpdoc/index.html | 4 +- doc/phpdoc/markers.html | 64 ++--- doc/phpdoc/namespaces/default.html | 28 +-- doc/phpdoc/packages/Default.html | 2 +- doc/phpdoc/packages/default.html | 368 ++++++++++++++--------------- doc/phpdoc/packages/inc.Inventory.inc.html | 2 +- doc/phpdoc/packages/inc.Item.inc.html | 2 +- doc/phpdoc/packages/inc.Monster.inc.html | 2 +- doc/phpdoc/packages/inc.account.inc.html | 2 +- doc/phpdoc/packages/inc.craftmine.inc.html | 2 +- doc/phpdoc/packages/inc.dungeon.inc.html | 2 +- doc/phpdoc/packages/inc.guild.inc.html | 2 +- doc/phpdoc/packages/inc.html | 368 ++++++++++++++--------------- doc/phpdoc/packages/inc.messages.inc.html | 2 +- doc/phpdoc/packages/inc.mine.inc.html | 2 +- doc/phpdoc/packages/inc.perso.inc.html | 2 +- doc/phpdoc/packages/inc.savegame.inc.html | 2 +- doc/phpdoc/packages/inc.shop.inc.html | 2 +- inc/Inventory.inc | 36 ++- 26 files changed, 545 insertions(+), 630 deletions(-) (limited to 'inc') diff --git a/doc/phpdoc/classes.svg b/doc/phpdoc/classes.svg index e64f82f..7422c49 100644 --- a/doc/phpdoc/classes.svg +++ b/doc/phpdoc/classes.svg @@ -13,20 +13,20 @@ Global - -\\Monster - -Monster - -\\Inventory - -Inventory +\\Inventory + +Inventory -\\Item - -Item +\\Item + +Item + + +\\Monster + +Monster diff --git a/doc/phpdoc/classes/Inventory.html b/doc/phpdoc/classes/Inventory.html index 48730e5..18149d5 100644 --- a/doc/phpdoc/classes/Inventory.html +++ b/doc/phpdoc/classes/Inventory.html @@ -124,8 +124,8 @@
  • - -
    addToXML
    +
    + Generates an XML tree describing the Inventory
    addToXML
  • @@ -142,8 +142,8 @@
  • - -
    removeItem
    +
    + Removes an Item object to the singleton's Inventory from session, not taking into account the Item's count.
    removeItem
  • @@ -154,8 +154,8 @@
  • - -
    useItem
    +
    + Consumes an Item object to the singleton's Inventory from session, decrementing the Item's count and removing it if count reaches 0.
    useItem
  • @@ -173,13 +173,13 @@
  • - -
    _removeItem
    +
    + Removes an Item object from the Inventory, not taking into account the Item's count.
    _removeItem
  • - -
    _useItem
    +
    + Consumes an Item object from the Inventory, decrementing the Item's count and removing it if count reaches 0.
    _useItem
  • @@ -264,8 +264,8 @@
    -

    _removeItem

    -
    _removeItem( $item) 
    +

    Removes an Item object from the Inventory, not taking into account the Item's count.

    +
    _removeItem(\Item $item) : void
    @@ -275,26 +275,12 @@
    - - - - - - - -
    - - -
    - - -

    Arguments

    $item

    -

    + \Item

    Item to remove from the Inventory

    @@ -303,8 +289,8 @@
    -

    _useItem

    -
    _useItem( $item) 
    +

    Consumes an Item object from the Inventory, decrementing the Item's count and removing it if count reaches 0.

    +
    _useItem(\Item $item) : array|false
    @@ -314,28 +300,16 @@
    - - - - - - - -
    - - -
    - - -

    Arguments

    $item

    -

    + \Item

    Item to consume from the Inventory

    +

    Response

    + array|false

    Item and updated Item's count, false if it was not found

    @@ -369,8 +343,8 @@
    -

    addToXML

    -
    addToXML( $root) 
    +

    Generates an XML tree describing the Inventory

    +
    addToXML(\SimpleXMLElement $root) : void
    @@ -380,26 +354,12 @@
    - - - - - - - -
    - - -
    - - -

    Arguments

    $root

    -

    + \SimpleXMLElement

    root XML element to add the Inventory's Items to

    @@ -466,8 +426,8 @@
    -

    removeItem

    -
    removeItem( $item) 
    +

    Removes an Item object to the singleton's Inventory from session, not taking into account the Item's count.

    +
    removeItem(\Item $item) : void
    static
    @@ -477,26 +437,12 @@
    - - - - - - - -
    - - -
    - - -

    Arguments

    $item

    -

    + \Item

    Item to remove from the Inventory

    @@ -534,8 +480,8 @@
    -

    useItem

    -
    useItem( $item) 
    +

    Consumes an Item object to the singleton's Inventory from session, decrementing the Item's count and removing it if count reaches 0.

    +
    useItem(\Item $item) : array|false
    static
    @@ -545,28 +491,16 @@
    - - - - - - - -
    - - -
    - - -

    Arguments

    $item

    -

    + \Item

    Item to consume from the Inventory

    +

    Response

    + array|false

    Item and updated Item's count, false if it was not found

    @@ -576,8 +510,8 @@

    Properties

    -

    Arrays of array with Item and Item's count

    -
    items : 
    +

    Arrays of array with Item object and Item's count as int

    +
    items : array
    @@ -587,15 +521,16 @@
    - + var +

    Arrays of array with Item object and Item's count as int

    Type(s)

    - + array
    @@ -619,7 +554,7 @@ Template is built using Twitter Bootstrap 2 and icons provided by Glyphicons.
    Documentation is powered by phpDocumentor and
    - generated on Sun, 08 May 2016 20:44:21 +0200.
    + generated on Mon, 09 May 2016 14:01:23 +0200.
    diff --git a/doc/phpdoc/classes/Item.html b/doc/phpdoc/classes/Item.html index 9dbd580..eab07f2 100644 --- a/doc/phpdoc/classes/Item.html +++ b/doc/phpdoc/classes/Item.html @@ -477,7 +477,7 @@ Template is built using Twitter Bootstrap 2 and icons provided by Glyphicons.
    Documentation is powered by phpDocumentor and
    - generated on Sun, 08 May 2016 20:44:21 +0200.
    + generated on Mon, 09 May 2016 14:01:23 +0200.
    diff --git a/doc/phpdoc/classes/Monster.html b/doc/phpdoc/classes/Monster.html index 5f22810..859dead 100644 --- a/doc/phpdoc/classes/Monster.html +++ b/doc/phpdoc/classes/Monster.html @@ -404,7 +404,7 @@ Template is built using Twitter Bootstrap 2 and icons provided by Glyphicons.
    Documentation is powered by phpDocumentor and
    - generated on Sun, 08 May 2016 20:44:21 +0200.
    + generated on Mon, 09 May 2016 14:01:23 +0200.
    diff --git a/doc/phpdoc/deprecated.html b/doc/phpdoc/deprecated.html index 0257223..9aaf18f 100644 --- a/doc/phpdoc/deprecated.html +++ b/doc/phpdoc/deprecated.html @@ -120,7 +120,7 @@ Template is built using Twitter Bootstrap 2 and icons provided by Glyphicons.
    Documentation is powered by phpDocumentor and
    - generated on Sun, 08 May 2016 20:44:22 +0200.
    + generated on Mon, 09 May 2016 14:01:23 +0200.
    diff --git a/doc/phpdoc/errors.html b/doc/phpdoc/errors.html index 2c096da..6d6d671 100644 --- a/doc/phpdoc/errors.html +++ b/doc/phpdoc/errors.html @@ -108,14 +108,14 @@ -
  • craftmine.php
  • -
  • upload.php
  • -
  • inc/Monster.inc
  • -
  • inc/Inventory.inc
  • -
  • inc/shop.inc
  • -
  • inc/perso.inc
  • +
  • upload.php
  • +
  • craftmine.php
  • +
  • inc/Inventory.inc
  • +
  • inc/shop.inc
  • +
  • inc/perso.inc
  • inc/Item.inc
  • - +
  • inc/Monster.inc
  • +
    @@ -126,10 +126,10 @@
    - +

    - craftmine.php + upload.php 1

    @@ -152,10 +152,10 @@
    - +

    - upload.php + craftmine.php 1

    @@ -178,10 +178,10 @@
    - +

    - inc/Monster.inc + inc/Inventory.inc 1

    @@ -208,11 +208,15 @@
    - +
    +
    +
    +
    +

    - inc/Inventory.inc - 11 + inc/shop.inc + 1

    @@ -226,58 +230,8 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + +
    error0No summary was found for this file
    error77Argument $item is missing from the Docblock of _removeItem
    error77No summary for method _removeItem()
    error86Argument $item is missing from the Docblock of removeItem
    error86No summary for method removeItem()
    error91Argument $item is missing from the Docblock of _useItem
    error91No summary for method _useItem()
    error106Argument $item is missing from the Docblock of useItem
    error106No summary for method useItem()
    error112Argument $root is missing from the Docblock of addToXML
    error112No summary for method addToXML()48Argument $name is missing from the Docblock of getItem
    @@ -290,10 +244,10 @@
    - +

    - inc/shop.inc + inc/perso.inc 1

    @@ -308,18 +262,18 @@ error - 48 - Argument $name is missing from the Docblock of getItem + 27 + Argument $num is missing from the Docblock of increasePerso
    - +

    - inc/perso.inc + inc/Item.inc 1

    @@ -334,18 +288,18 @@ error - 27 - Argument $num is missing from the Docblock of increasePerso + 0 + No summary was found for this file
    - +

    - inc/Item.inc + inc/Monster.inc 1

    @@ -367,10 +321,6 @@
    -
    -
    -
    -
    @@ -379,7 +329,7 @@ Template is built using Twitter Bootstrap 2 and icons provided by Glyphicons.
    Documentation is powered by phpDocumentor and
    - generated on Sun, 08 May 2016 20:44:21 +0200.
    + generated on Mon, 09 May 2016 14:01:23 +0200.
    diff --git a/doc/phpdoc/graph_class.html b/doc/phpdoc/graph_class.html index 0143bcc..068a2e8 100644 --- a/doc/phpdoc/graph_class.html +++ b/doc/phpdoc/graph_class.html @@ -121,7 +121,7 @@ Template is built using Twitter Bootstrap 2 and icons provided by Glyphicons.
    Documentation is powered by phpDocumentor and
    - generated on Sun, 08 May 2016 20:44:22 +0200.
    + generated on Mon, 09 May 2016 14:01:23 +0200.
    diff --git a/doc/phpdoc/index.html b/doc/phpdoc/index.html index 7fc372b..1c76dcf 100644 --- a/doc/phpdoc/index.html +++ b/doc/phpdoc/index.html @@ -129,7 +129,7 @@
  • - Errors 17 + Errors 7
  • @@ -155,7 +155,7 @@ Template is built using Twitter Bootstrap 2 and icons provided by Glyphicons.
    Documentation is powered by phpDocumentor and
    - generated on Sun, 08 May 2016 20:44:21 +0200.
    + generated on Mon, 09 May 2016 14:01:23 +0200.
    diff --git a/doc/phpdoc/markers.html b/doc/phpdoc/markers.html index 33d05f7..4765760 100644 --- a/doc/phpdoc/markers.html +++ b/doc/phpdoc/markers.html @@ -99,11 +99,11 @@
    @@ -115,29 +115,7 @@
    -
    - -

    - - inc/Monster.inc - 1 -

    -
    - - - - - - - - - - - -
    TypeLineDescription
    TODO23unused
    -
    -
    -
    +

    @@ -169,7 +147,7 @@

    -
    +

    @@ -196,7 +174,7 @@

    -
    +

    @@ -218,7 +196,29 @@

    -
    +
    + +

    + + inc/Monster.inc + 1 +

    +
    + + + + + + + + + + + +
    TypeLineDescription
    TODO23unused
    +
    +
    +
    @@ -227,7 +227,7 @@ Template is built using Twitter Bootstrap 2 and icons provided by Glyphicons.
    Documentation is powered by phpDocumentor and
    - generated on Sun, 08 May 2016 20:44:21 +0200.
    + generated on Mon, 09 May 2016 14:01:23 +0200.
    diff --git a/doc/phpdoc/namespaces/default.html b/doc/phpdoc/namespaces/default.html index fa3b993..87e1895 100644 --- a/doc/phpdoc/namespaces/default.html +++ b/doc/phpdoc/namespaces/default.html @@ -1580,19 +1580,6 @@ XML errors are simply ignored and an error is sent to the client if something wr

    Constants

    -
    -

    SAVEDIR

    -

    Directory to save to and load from.

    -
    -

    The PHP/Apache user must have write permission on this directory. -Use the following commands to give write permissions to the http group:

    - -sudo chown :http data/save -sudo chmod g+w data/save - -
    - « More »
    -

    GUILD_COST

    Amount of gold required to build the miners guild.

    @@ -1609,6 +1596,19 @@ sudo chmod g+w data/save
    « More »
    +
    +

    SAVEDIR

    +

    Directory to save to and load from.

    +
    +

    The PHP/Apache user must have write permission on this directory. +Use the following commands to give write permissions to the http group:

    + +sudo chown :http data/save +sudo chmod g+w data/save + +
    + « More »
    +
    @@ -1650,7 +1650,7 @@ sudo chmod g+w data/save Template is built using Twitter Bootstrap 2 and icons provided by Glyphicons.
    Documentation is powered by phpDocumentor and
    - generated on Sun, 08 May 2016 20:44:21 +0200.
    + generated on Mon, 09 May 2016 14:01:23 +0200.
    diff --git a/doc/phpdoc/packages/Default.html b/doc/phpdoc/packages/Default.html index 0ab1111..0caa25c 100644 --- a/doc/phpdoc/packages/Default.html +++ b/doc/phpdoc/packages/Default.html @@ -154,7 +154,7 @@ Template is built using Twitter Bootstrap 2 and icons provided by Glyphicons.
    Documentation is powered by phpDocumentor and
    - generated on Sun, 08 May 2016 20:44:21 +0200.
    + generated on Mon, 09 May 2016 14:01:23 +0200.
    diff --git a/doc/phpdoc/packages/default.html b/doc/phpdoc/packages/default.html index 36062e5..5b519ce 100644 --- a/doc/phpdoc/packages/default.html +++ b/doc/phpdoc/packages/default.html @@ -308,7 +308,7 @@
  • - \Monster.inc + \Inventory.inc
  • @@ -320,11 +320,11 @@

    Classes, interfaces and traits

    -
    -

    Monster

    -

    Represent an Item in the shop or in the Inventory.

    -
    - « More » +
    +

    Inventory

    +

    Represent the player's Inventory.

    +
    Implemented as a singleton in the session.
    + « More »
    @@ -342,7 +342,7 @@
  • - \craftmine.inc + \dungeon.inc
  • @@ -350,11 +350,53 @@

    Functions

    -
    -

    sendCraftMine

    -

    Sends all data from previous session on page load.

    -
    All data from the different modules are packed in an array.
    - « More » +
    +

    generateMonster

    +

    Loads all the dungeon's monsters from the XML file data/monsters.xml.

    +
    + « More » +
    + +
    +

    initDungeon

    +

    Marks the dungeon as accessible in the session.

    +
    + « More » +
    + +
    +

    sendDungeon

    +

    Returns the dungeon array if it was created.

    +
    + « More » +
    + +
    +

    buildDungeon

    +

    Allows acces to the dungeon in the session and sends it to the client.

    +
    Debits the dungeon's ticket cost from the player's gold.
    + « More » +
    + +
    +

    launchDungeon

    +

    Sends monsters for a specific floor as specified by the floor POST parameter to the client.

    +
    + « More » +
    + +
    +

    sendDungeonProgress

    +

    Updates floor and monster number from the POST parameters in the session.

    +
    + « More » +
    + +
    +

    exitDungeon

    +

    Marks the dungeon as not accessible in the session.

    +
    + « More »
    @@ -420,26 +462,55 @@
  • - \Inventory.inc + \guild.inc
  • - +
    +

    Functions

    +
    +

    createGuild

    +

    Create the miners guild in the session.

    +
    Debits GUILD_COST from the player's gold.
    + « More » +
    + +
    +

    hireMiner

    +

    Hire one miner.

    +
    Debits MINER_COST from the player's gold.
    + « More » +
    + +
    +

    sendMiners

    +

    Returns the number of miners currently in the guild.

    +
    + « More » +
    + +
    -

    Classes, interfaces and traits

    - - -
    -

    Inventory

    -

    Represent the player's Inventory.

    -
    Implemented as a singleton in the session.
    - « More » +

    Constants

    +
    +

    GUILD_COST

    +

    Amount of gold required to build the miners guild.

    +
    + « More » +
    + +
    +

    MINER_COST

    +

    Amount of gold required to hire a miner.

    +
    + « More »
    + @@ -566,7 +637,7 @@ sudo chmod g+w data/save
  • - \dungeon.inc + \shop.inc
  • @@ -574,53 +645,53 @@ sudo chmod g+w data/save

    Functions

    -
    -

    generateMonster

    -

    Loads all the dungeon's monsters from the XML file data/monsters.xml.

    +
    +

    loadShop

    +

    Loads all the shop's items from the XML file data/items.xml.

    - « More » + « More »
    -
    -

    initDungeon

    -

    Marks the dungeon as accessible in the session.

    +
    +

    getItem

    +

    Gets an Item object from the shop from its name.

    - « More » + « More »
    -
    -

    sendDungeon

    -

    Returns the dungeon array if it was created.

    +
    +

    initShop

    +

    Marks the shop as created in the session.

    - « More » + « More »
    -
    -

    buildDungeon

    -

    Allows acces to the dungeon in the session and sends it to the client.

    -
    Debits the dungeon's ticket cost from the player's gold.
    - « More » +
    +

    sendShop

    +

    Returns the shop array if it was created.

    +
    + « More »
    -
    -

    launchDungeon

    -

    Sends monsters for a specific floor as specified by the floor POST parameter to the client.

    -
    - « More » +
    +

    buildShop

    +

    Creates the shop in the session and sends it to the client.

    +
    Debits the shop's cost from the player's gold.
    + « More »
    -
    -

    sendDungeonProgress

    -

    Updates floor and monster number from the POST parameters in the session.

    +
    +

    buyItem

    +

    Debits the item's cost specified as the item POST parameter, adds it to the Inventory and sends it to the client.

    - « More » + « More »
    -
    -

    exitDungeon

    -

    Marks the dungeon as not accessible in the session.

    +
    +

    useItem

    +

    Invoke useItem on an item passed as the item POST parameter, sends to the client the updated player stats and the item.

    - « More » + « More »
    @@ -640,7 +711,7 @@ sudo chmod g+w data/save
  • - \account.inc + \mine.inc
  • @@ -648,18 +719,25 @@ sudo chmod g+w data/save

    Functions

    -
    -

    debitAccount

    -

    Debits the account of a certain amount of gold.

    +
    +

    initCraftMine

    +

    Initializes the gold amount and miners count in the session.

    - « More » + « More »
    -
    -

    creditAccount

    -

    Credits the account of a certain amount of gold.

    +
    +

    withdrawMine

    +

    Transfers all gold from the mine to the player's account.

    - « More » + « More » +
    + +
    +

    sendMine

    +

    Returns the amount of gold currently owned by the player.

    +
    + « More »
    @@ -679,7 +757,7 @@ sudo chmod g+w data/save
  • - \shop.inc + \craftmine.inc
  • @@ -687,53 +765,50 @@ sudo chmod g+w data/save

    Functions

    -
    -

    loadShop

    -

    Loads all the shop's items from the XML file data/items.xml.

    -
    - « More » -
    - -
    -

    getItem

    -

    Gets an Item object from the shop from its name.

    -
    - « More » +
    +

    sendCraftMine

    +

    Sends all data from previous session on page load.

    +
    All data from the different modules are packed in an array.
    + « More »
    -
    -

    initShop

    -

    Marks the shop as created in the session.

    -
    - « More » -
    +
    + + + + + + -
    -

    buyItem

    -

    Debits the item's cost specified as the item POST parameter, adds it to the Inventory and sends it to the client.

    + +
    +

    Functions

    +
    +

    debitAccount

    +

    Debits the account of a certain amount of gold.

    - « More » + « More »
    -
    -

    useItem

    -

    Invoke useItem on an item passed as the item POST parameter, sends to the client the updated player stats and the item.

    +
    +

    creditAccount

    +

    Credits the account of a certain amount of gold.

    - « More » + « More »
    @@ -840,101 +915,26 @@ sudo chmod g+w data/save
  • - \guild.inc + \Monster.inc
  • -
    -

    Functions

    -
    -

    createGuild

    -

    Create the miners guild in the session.

    -
    Debits GUILD_COST from the player's gold.
    - « More » -
    - -
    -

    hireMiner

    -

    Hire one miner.

    -
    Debits MINER_COST from the player's gold.
    - « More » -
    - -
    -

    sendMiners

    -

    Returns the number of miners currently in the guild.

    -
    - « More » -
    - -
    -
    -

    Constants

    -
    -

    GUILD_COST

    -

    Amount of gold required to build the miners guild.

    -
    - « More » -
    - -
    -

    MINER_COST

    -

    Amount of gold required to hire a miner.

    -
    - « More » -
    - -
    - - +
    +

    Classes, interfaces and traits

    - - - -
    -

    Functions

    -
    -

    initCraftMine

    -

    Initializes the gold amount and miners count in the session.

    -
    - « More » -
    - -
    -

    withdrawMine

    -

    Transfers all gold from the mine to the player's account.

    -
    - « More » -
    - -
    -

    sendMine

    -

    Returns the amount of gold currently owned by the player.

    +
    +

    Monster

    +

    Represent an Item in the shop or in the Inventory.

    - « More » + « More »
    - - @@ -947,7 +947,7 @@ sudo chmod g+w data/save Template is built using Twitter Bootstrap 2 and icons provided by Glyphicons.
    Documentation is powered by phpDocumentor and
    - generated on Sun, 08 May 2016 20:44:21 +0200.
    + generated on Mon, 09 May 2016 14:01:23 +0200.
    diff --git a/doc/phpdoc/packages/inc.Inventory.inc.html b/doc/phpdoc/packages/inc.Inventory.inc.html index 2316a5d..4cc9b21 100644 --- a/doc/phpdoc/packages/inc.Inventory.inc.html +++ b/doc/phpdoc/packages/inc.Inventory.inc.html @@ -162,7 +162,7 @@ Template is built using Twitter Bootstrap 2 and icons provided by Glyphicons.
    Documentation is powered by phpDocumentor and
    - generated on Sun, 08 May 2016 20:44:21 +0200.
    + generated on Mon, 09 May 2016 14:01:23 +0200.
    diff --git a/doc/phpdoc/packages/inc.Item.inc.html b/doc/phpdoc/packages/inc.Item.inc.html index f9c1c45..bea2d41 100644 --- a/doc/phpdoc/packages/inc.Item.inc.html +++ b/doc/phpdoc/packages/inc.Item.inc.html @@ -162,7 +162,7 @@ Template is built using Twitter Bootstrap 2 and icons provided by Glyphicons.
    Documentation is powered by phpDocumentor and
    - generated on Sun, 08 May 2016 20:44:21 +0200.
    + generated on Mon, 09 May 2016 14:01:23 +0200.
    diff --git a/doc/phpdoc/packages/inc.Monster.inc.html b/doc/phpdoc/packages/inc.Monster.inc.html index dada9c0..234a20d 100644 --- a/doc/phpdoc/packages/inc.Monster.inc.html +++ b/doc/phpdoc/packages/inc.Monster.inc.html @@ -162,7 +162,7 @@ Template is built using Twitter Bootstrap 2 and icons provided by Glyphicons.
    Documentation is powered by phpDocumentor and
    - generated on Sun, 08 May 2016 20:44:21 +0200.
    + generated on Mon, 09 May 2016 14:01:23 +0200.
    diff --git a/doc/phpdoc/packages/inc.account.inc.html b/doc/phpdoc/packages/inc.account.inc.html index 49b5440..b77b8f4 100644 --- a/doc/phpdoc/packages/inc.account.inc.html +++ b/doc/phpdoc/packages/inc.account.inc.html @@ -167,7 +167,7 @@ Template is built using Twitter Bootstrap 2 and icons provided by Glyphicons.
    Documentation is powered by phpDocumentor and
    - generated on Sun, 08 May 2016 20:44:21 +0200.
    + generated on Mon, 09 May 2016 14:01:23 +0200.
    diff --git a/doc/phpdoc/packages/inc.craftmine.inc.html b/doc/phpdoc/packages/inc.craftmine.inc.html index fa7ffff..3d98bbd 100644 --- a/doc/phpdoc/packages/inc.craftmine.inc.html +++ b/doc/phpdoc/packages/inc.craftmine.inc.html @@ -160,7 +160,7 @@ Template is built using Twitter Bootstrap 2 and icons provided by Glyphicons.
    Documentation is powered by phpDocumentor and
    - generated on Sun, 08 May 2016 20:44:21 +0200.
    + generated on Mon, 09 May 2016 14:01:23 +0200.
    diff --git a/doc/phpdoc/packages/inc.dungeon.inc.html b/doc/phpdoc/packages/inc.dungeon.inc.html index 7d5d6a3..a6c2668 100644 --- a/doc/phpdoc/packages/inc.dungeon.inc.html +++ b/doc/phpdoc/packages/inc.dungeon.inc.html @@ -202,7 +202,7 @@ Template is built using Twitter Bootstrap 2 and icons provided by Glyphicons.
    Documentation is powered by phpDocumentor and
    - generated on Sun, 08 May 2016 20:44:21 +0200.
    + generated on Mon, 09 May 2016 14:01:23 +0200.
    diff --git a/doc/phpdoc/packages/inc.guild.inc.html b/doc/phpdoc/packages/inc.guild.inc.html index f301c47..ed8ab9b 100644 --- a/doc/phpdoc/packages/inc.guild.inc.html +++ b/doc/phpdoc/packages/inc.guild.inc.html @@ -191,7 +191,7 @@ Template is built using Twitter Bootstrap 2 and icons provided by Glyphicons.
    Documentation is powered by phpDocumentor and
    - generated on Sun, 08 May 2016 20:44:21 +0200.
    + generated on Mon, 09 May 2016 14:01:23 +0200.
    diff --git a/doc/phpdoc/packages/inc.html b/doc/phpdoc/packages/inc.html index c5528a7..b1e32db 100644 --- a/doc/phpdoc/packages/inc.html +++ b/doc/phpdoc/packages/inc.html @@ -252,7 +252,7 @@
  • - \Monster.inc + \Inventory.inc
  • @@ -264,11 +264,11 @@

    Classes, interfaces and traits

    -
    -

    Monster

    -

    Represent an Item in the shop or in the Inventory.

    -
    - « More » +
    +

    Inventory

    +

    Represent the player's Inventory.

    +
    Implemented as a singleton in the session.
    + « More »
    @@ -286,7 +286,7 @@
  • - \craftmine.inc + \dungeon.inc
  • @@ -294,11 +294,53 @@

    Functions

    -
    -

    sendCraftMine

    -

    Sends all data from previous session on page load.

    -
    All data from the different modules are packed in an array.
    - « More » +
    +

    generateMonster

    +

    Loads all the dungeon's monsters from the XML file data/monsters.xml.

    +
    + « More » +
    + +
    +

    initDungeon

    +

    Marks the dungeon as accessible in the session.

    +
    + « More » +
    + +
    +

    sendDungeon

    +

    Returns the dungeon array if it was created.

    +
    + « More » +
    + +
    +

    buildDungeon

    +

    Allows acces to the dungeon in the session and sends it to the client.

    +
    Debits the dungeon's ticket cost from the player's gold.
    + « More » +
    + +
    +

    launchDungeon

    +

    Sends monsters for a specific floor as specified by the floor POST parameter to the client.

    +
    + « More » +
    + +
    +

    sendDungeonProgress

    +

    Updates floor and monster number from the POST parameters in the session.

    +
    + « More » +
    + +
    +

    exitDungeon

    +

    Marks the dungeon as not accessible in the session.

    +
    + « More »
    @@ -364,26 +406,55 @@
  • - \Inventory.inc + \guild.inc
  • - +
    +

    Functions

    +
    +

    createGuild

    +

    Create the miners guild in the session.

    +
    Debits GUILD_COST from the player's gold.
    + « More » +
    + +
    +

    hireMiner

    +

    Hire one miner.

    +
    Debits MINER_COST from the player's gold.
    + « More » +
    + +
    +

    sendMiners

    +

    Returns the number of miners currently in the guild.

    +
    + « More » +
    + +
    -

    Classes, interfaces and traits

    - - -
    -

    Inventory

    -

    Represent the player's Inventory.

    -
    Implemented as a singleton in the session.
    - « More » +

    Constants

    +
    +

    GUILD_COST

    +

    Amount of gold required to build the miners guild.

    +
    + « More » +
    + +
    +

    MINER_COST

    +

    Amount of gold required to hire a miner.

    +
    + « More »
    + @@ -510,7 +581,7 @@ sudo chmod g+w data/save
  • - \dungeon.inc + \shop.inc
  • @@ -518,53 +589,53 @@ sudo chmod g+w data/save

    Functions

    -
    -

    generateMonster

    -

    Loads all the dungeon's monsters from the XML file data/monsters.xml.

    +
    +

    loadShop

    +

    Loads all the shop's items from the XML file data/items.xml.

    - « More » + « More »
    -
    -

    initDungeon

    -

    Marks the dungeon as accessible in the session.

    +
    +

    getItem

    +

    Gets an Item object from the shop from its name.

    - « More » + « More »
    -
    -

    sendDungeon

    -

    Returns the dungeon array if it was created.

    +
    +

    initShop

    +

    Marks the shop as created in the session.

    - « More » + « More »
    -
    -

    buildDungeon

    -

    Allows acces to the dungeon in the session and sends it to the client.

    -
    Debits the dungeon's ticket cost from the player's gold.
    - « More » +
    +

    sendShop

    +

    Returns the shop array if it was created.

    +
    + « More »
    -
    -

    launchDungeon

    -

    Sends monsters for a specific floor as specified by the floor POST parameter to the client.

    -
    - « More » +
    +

    buildShop

    +

    Creates the shop in the session and sends it to the client.

    +
    Debits the shop's cost from the player's gold.
    + « More »
    -
    -

    sendDungeonProgress

    -

    Updates floor and monster number from the POST parameters in the session.

    +
    +

    buyItem

    +

    Debits the item's cost specified as the item POST parameter, adds it to the Inventory and sends it to the client.

    - « More » + « More »
    -
    -

    exitDungeon

    -

    Marks the dungeon as not accessible in the session.

    +
    +

    useItem

    +

    Invoke useItem on an item passed as the item POST parameter, sends to the client the updated player stats and the item.

    - « More » + « More »
    @@ -584,7 +655,7 @@ sudo chmod g+w data/save
  • - \account.inc + \mine.inc
  • @@ -592,18 +663,25 @@ sudo chmod g+w data/save

    Functions

    -
    -

    debitAccount

    -

    Debits the account of a certain amount of gold.

    +
    +

    initCraftMine

    +

    Initializes the gold amount and miners count in the session.

    - « More » + « More »
    -
    -

    creditAccount

    -

    Credits the account of a certain amount of gold.

    +
    +

    withdrawMine

    +

    Transfers all gold from the mine to the player's account.

    - « More » + « More » +
    + +
    +

    sendMine

    +

    Returns the amount of gold currently owned by the player.

    +
    + « More »
    @@ -623,7 +701,7 @@ sudo chmod g+w data/save
  • - \shop.inc + \craftmine.inc
  • @@ -631,53 +709,50 @@ sudo chmod g+w data/save

    Functions

    -
    -

    loadShop

    -

    Loads all the shop's items from the XML file data/items.xml.

    -
    - « More » -
    - -
    -

    getItem

    -

    Gets an Item object from the shop from its name.

    -
    - « More » +
    +

    sendCraftMine

    +

    Sends all data from previous session on page load.

    +
    All data from the different modules are packed in an array.
    + « More »
    -
    -

    initShop

    -

    Marks the shop as created in the session.

    -
    - « More » -
    +
    + + + + + + -
    -

    buyItem

    -

    Debits the item's cost specified as the item POST parameter, adds it to the Inventory and sends it to the client.

    + +
    +

    Functions

    +
    +

    debitAccount

    +

    Debits the account of a certain amount of gold.

    - « More » + « More »
    -
    -

    useItem

    -

    Invoke useItem on an item passed as the item POST parameter, sends to the client the updated player stats and the item.

    +
    +

    creditAccount

    +

    Credits the account of a certain amount of gold.

    - « More » + « More »
    @@ -784,101 +859,26 @@ sudo chmod g+w data/save
  • - \guild.inc + \Monster.inc
  • -
    -

    Functions

    -
    -

    createGuild

    -

    Create the miners guild in the session.

    -
    Debits GUILD_COST from the player's gold.
    - « More » -
    - -
    -

    hireMiner

    -

    Hire one miner.

    -
    Debits MINER_COST from the player's gold.
    - « More » -
    - -
    -

    sendMiners

    -

    Returns the number of miners currently in the guild.

    -
    - « More » -
    - -
    -
    -

    Constants

    -
    -

    GUILD_COST

    -

    Amount of gold required to build the miners guild.

    -
    - « More » -
    - -
    -

    MINER_COST

    -

    Amount of gold required to hire a miner.

    -
    - « More » -
    - -
    - - +
    +

    Classes, interfaces and traits

    - - - -
    -

    Functions

    -
    -

    initCraftMine

    -

    Initializes the gold amount and miners count in the session.

    -
    - « More » -
    - -
    -

    withdrawMine

    -

    Transfers all gold from the mine to the player's account.

    -
    - « More » -
    - -
    -

    sendMine

    -

    Returns the amount of gold currently owned by the player.

    +
    +

    Monster

    +

    Represent an Item in the shop or in the Inventory.

    - « More » + « More »
    - - @@ -890,7 +890,7 @@ sudo chmod g+w data/save Template is built using Twitter Bootstrap 2 and icons provided by Glyphicons.
    Documentation is powered by phpDocumentor and
    - generated on Sun, 08 May 2016 20:44:21 +0200.
    + generated on Mon, 09 May 2016 14:01:23 +0200.
    diff --git a/doc/phpdoc/packages/inc.messages.inc.html b/doc/phpdoc/packages/inc.messages.inc.html index eef0408..23ce6ad 100644 --- a/doc/phpdoc/packages/inc.messages.inc.html +++ b/doc/phpdoc/packages/inc.messages.inc.html @@ -174,7 +174,7 @@ Template is built using Twitter Bootstrap 2 and icons provided by Glyphicons.
    Documentation is powered by phpDocumentor and
    - generated on Sun, 08 May 2016 20:44:21 +0200.
    + generated on Mon, 09 May 2016 14:01:23 +0200.
    diff --git a/doc/phpdoc/packages/inc.mine.inc.html b/doc/phpdoc/packages/inc.mine.inc.html index 0fb2c21..734a429 100644 --- a/doc/phpdoc/packages/inc.mine.inc.html +++ b/doc/phpdoc/packages/inc.mine.inc.html @@ -174,7 +174,7 @@ Template is built using Twitter Bootstrap 2 and icons provided by Glyphicons.
    Documentation is powered by phpDocumentor and
    - generated on Sun, 08 May 2016 20:44:21 +0200.
    + generated on Mon, 09 May 2016 14:01:23 +0200.
    diff --git a/doc/phpdoc/packages/inc.perso.inc.html b/doc/phpdoc/packages/inc.perso.inc.html index d724706..8c471aa 100644 --- a/doc/phpdoc/packages/inc.perso.inc.html +++ b/doc/phpdoc/packages/inc.perso.inc.html @@ -181,7 +181,7 @@ Template is built using Twitter Bootstrap 2 and icons provided by Glyphicons.
    Documentation is powered by phpDocumentor and
    - generated on Sun, 08 May 2016 20:44:21 +0200.
    + generated on Mon, 09 May 2016 14:01:23 +0200.
    diff --git a/doc/phpdoc/packages/inc.savegame.inc.html b/doc/phpdoc/packages/inc.savegame.inc.html index 4009130..2ec1e2d 100644 --- a/doc/phpdoc/packages/inc.savegame.inc.html +++ b/doc/phpdoc/packages/inc.savegame.inc.html @@ -240,7 +240,7 @@ sudo chmod g+w data/save Template is built using Twitter Bootstrap 2 and icons provided by Glyphicons.
    Documentation is powered by phpDocumentor and
    - generated on Sun, 08 May 2016 20:44:21 +0200.
    + generated on Mon, 09 May 2016 14:01:23 +0200.
    diff --git a/doc/phpdoc/packages/inc.shop.inc.html b/doc/phpdoc/packages/inc.shop.inc.html index fbdefe6..6908e0f 100644 --- a/doc/phpdoc/packages/inc.shop.inc.html +++ b/doc/phpdoc/packages/inc.shop.inc.html @@ -202,7 +202,7 @@ Template is built using Twitter Bootstrap 2 and icons provided by Glyphicons.
    Documentation is powered by phpDocumentor and
    - generated on Sun, 08 May 2016 20:44:21 +0200.
    + generated on Mon, 09 May 2016 14:01:23 +0200.
    diff --git a/inc/Inventory.inc b/inc/Inventory.inc index 73d82c8..58cf709 100644 --- a/inc/Inventory.inc +++ b/inc/Inventory.inc @@ -8,9 +8,9 @@ * @author Pierre-Emmanuel Novac */ class Inventory { - /** - * Arrays of array with Item and Item's count - */ + /** + * @var array Arrays of array with Item object and Item's count as int + */ public $items = array(); /** @@ -74,6 +74,12 @@ class Inventory { return $tab; } + /** + * Removes an Item object from the Inventory, not taking into account the Item's count. + * + * @param Item $item Item to remove from the Inventory + * @return void + */ private function _removeItem($item) { foreach($this->items as $k => $object) { if($object[0] == $item) { @@ -83,11 +89,23 @@ class Inventory { } } + /** + * Removes an Item object to the singleton's Inventory from session, not taking into account the Item's count. + * + * @param Item $item Item to remove from the Inventory + * @return void + */ public static function removeItem($item) { $inv = self::get(); $inv->_removeItem($item); } + /** + * Consumes an Item object from the Inventory, decrementing the Item's count and removing it if count reaches 0. + * + * @param Item $item Item to consume from the Inventory + * @return array|false Item and updated Item's count, false if it was not found + */ private function _useItem($item) { foreach($this->items as $k => $object){ if($object[0] == $item) { @@ -103,12 +121,24 @@ class Inventory { return false; } + /** + * Consumes an Item object to the singleton's Inventory from session, decrementing the Item's count and removing it if count reaches 0. + * + * @param Item $item Item to consume from the Inventory + * @return array|false Item and updated Item's count, false if it was not found + */ public static function useItem($item) { $inv = self::get(); $it = $inv->_useItem($item); return $it; } + /** + * Generates an XML tree describing the Inventory + * + * @param SimpleXMLElement $root root XML element to add the Inventory's Items to + * @return void + */ public function addToXML($root) { foreach($this->items as $item) $item[0]->addToXML($root, $item[1]); -- cgit v1.2.3-54-g00ecf