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/guild.inc | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) (limited to 'inc/guild.inc') 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 @@ 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/guild.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-70-g09d2 From 58b1893e6c820ce8810c33f09bfcc16c3e59f4eb Mon Sep 17 00:00:00 2001 From: piernov Date: Tue, 10 May 2016 22:21:31 +0200 Subject: Various fixes --- inc/guild.inc | 9 +++++++++ inc/messages.inc | 1 + inc/mine.inc | 14 +++++++++++--- index.xhtml | 6 +++--- 4 files changed, 24 insertions(+), 6 deletions(-) (limited to 'inc/guild.inc') diff --git a/inc/guild.inc b/inc/guild.inc index c0e8264..1666b15 100644 --- a/inc/guild.inc +++ b/inc/guild.inc @@ -3,6 +3,13 @@ define("GUILD_COST",10); define("MINER_COST",5); +function initMinersIfNeeded() { + if(empty($_SESSION["mine"])) + $_SESSION["mine"] = array("miners" => 0); + else if(!array_key_exists("miners", $_SESSION["mine"])) + $_SESSION["mine"]["miners"] = 0; +} + function createGuild(){ if(!empty($_SESSION["guild"])) { sendError("guild_already_built"); @@ -18,12 +25,14 @@ function hireMiner(){ sendError("guild_not_yet_created"); } elseif(debitAccount(MINER_COST)){ + initMinersIfNeeded(); $_SESSION["mine"]["miners"]++; echo json_encode(array("cost" => MINER_COST , "miners" => $_SESSION["mine"]["miners"])); } } function sendMiners(){ + initMinersIfNeeded(); return $_SESSION["mine"]["miners"]; } diff --git a/inc/messages.inc b/inc/messages.inc index 3a7d9b1..97e1da2 100644 --- a/inc/messages.inc +++ b/inc/messages.inc @@ -6,6 +6,7 @@ $messages = array( "shop_missing_item" => "This item does not exist.", "guild_not_yet_created" => "You need to create a guild first.", "guild_already_built" => "You have aready built a guild.", + "cant_withdraw_in_dungeon" => "You cannot withdraw gold from the mine while you are in the dungeon.", "dungeon_already_available" => "You can already access the dungeon", "gamesave_ok" => "Game saved.", diff --git a/inc/mine.inc b/inc/mine.inc index 752fc69..76dfb50 100644 --- a/inc/mine.inc +++ b/inc/mine.inc @@ -1,18 +1,26 @@ 0, "miners" => 0); +function initMineIfNeeded() { + if(empty($_SESSION["mine"])) + $_SESSION["mine"] = array("gold" => 0); + else if(!array_key_exists("gold", $_SESSION["mine"])) + $_SESSION["mine"]["gold"] = 0; } function withdrawMine() { $amount = intval($_POST["amount"]); + if(!empty($_SESSION["dungeon"])) { + sendError("cant_withdraw_in_dungeon"); + return; + } if($amount == 0) return; + initMineIfNeeded(); $_SESSION["mine"]["gold"] += $amount; echo json_encode($_SESSION["mine"]["gold"]); } function sendMine() { - if(empty($_SESSION["mine"])) initCraftMine(); + initMineIfNeeded(); $mine = $_SESSION["mine"]; return $mine["gold"]; } diff --git a/index.xhtml b/index.xhtml index eba0f43..8ee8c52 100644 --- a/index.xhtml +++ b/index.xhtml @@ -44,9 +44,9 @@
-- cgit v1.2.3-70-g09d2