aboutsummaryrefslogtreecommitdiffstats
path: root/inc/perso.inc
diff options
context:
space:
mode:
Diffstat (limited to 'inc/perso.inc')
-rw-r--r--inc/perso.inc28
1 files changed, 28 insertions, 0 deletions
diff --git a/inc/perso.inc b/inc/perso.inc
index 2a514bb..e38fb4c 100644
--- a/inc/perso.inc
+++ b/inc/perso.inc
@@ -1,11 +1,29 @@
<?php
+/**
+ * Manages player's stats: life, experience, level.
+ *
+ * @package inc\perso.inc
+ * @author Alexandre Renoux
+ * @author Pierre-Emmanuel Novac
+ */
+/**
+ * Returns all player's stats after initializing them if needed.
+ *
+ * @return int[] arrays containing player's stats
+ */
function sendPerso() {
if(empty($_SESSION["perso"]))
initPerso();
return $_SESSION["perso"];
}
+/**
+ * Increases a player's stat.
+ *
+ * @param int $prop stat to increase
+ * @return void
+ */
function increasePerso($prop, $num) {
if(empty($_SESSION["perso"]))
initPerso();
@@ -69,6 +87,11 @@ function reusable(){
}
}
+/**
+ * Copies stats given in POST request to session.
+ *
+ * @return void
+ */
function updatePerso(){
$hp = $_POST["hp"];
$maxHP = $_POST["maxHP"];
@@ -84,6 +107,11 @@ function updatePerso(){
$_SESSION["perso"]["bonusPower"] = +$bonusPower;
}
+/**
+ * Initializes the player's stats.
+ *
+ * @return void
+ */
function initPerso(){
$_SESSION["perso"]["hp"] = 5;
$_SESSION["perso"]["maxHP"] = 5;