aboutsummaryrefslogtreecommitdiffstats
path: root/inc/mine.inc
diff options
context:
space:
mode:
Diffstat (limited to 'inc/mine.inc')
-rw-r--r--inc/mine.inc24
1 files changed, 23 insertions, 1 deletions
diff --git a/inc/mine.inc b/inc/mine.inc
index 76dfb50..fb5f612 100644
--- a/inc/mine.inc
+++ b/inc/mine.inc
@@ -1,5 +1,17 @@
<?php
+/**
+ * Manages the mine.
+ *
+ * @packageĀ inc\mine.inc
+ * @author Alexandre Renoux
+ * @author Pierre-Emmanuel Novac
+ */
+/**
+ * Initializes the gold amount and miners count in the session.
+ *
+ * @return void
+ */
function initMineIfNeeded() {
if(empty($_SESSION["mine"]))
$_SESSION["mine"] = array("gold" => 0);
@@ -7,9 +19,14 @@ function initMineIfNeeded() {
$_SESSION["mine"]["gold"] = 0;
}
+/**
+ * Transfers all gold from the mine to the player's account.
+ *
+ * @return void
+ */
function withdrawMine() {
$amount = intval($_POST["amount"]);
- if(!empty($_SESSION["dungeon"])) {
+ if(!empty($_SESSION["dungeon"]) && !empty($_SESSION["dungeon"]["flat"])) { // player in dungeon
sendError("cant_withdraw_in_dungeon");
return;
}
@@ -19,6 +36,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() {
initMineIfNeeded();
$mine = $_SESSION["mine"];