aboutsummaryrefslogtreecommitdiffstats
path: root/inc/mine.inc
diff options
context:
space:
mode:
Diffstat (limited to 'inc/mine.inc')
-rw-r--r--inc/mine.inc22
1 files changed, 22 insertions, 0 deletions
diff --git a/inc/mine.inc b/inc/mine.inc
index 752fc69..d27804a 100644
--- a/inc/mine.inc
+++ b/inc/mine.inc
@@ -1,9 +1,26 @@
<?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 initCraftMine() {
$_SESSION["mine"] = array("gold" => 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 +28,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"];