aboutsummaryrefslogtreecommitdiffstats
path: root/inc/perso.inc
diff options
context:
space:
mode:
authorpiernov <piernov@piernov.org>2016-05-08 20:14:40 +0200
committerpiernov <piernov@piernov.org>2016-05-08 20:14:40 +0200
commitfaefddcb8b3d3ac491331b702f8a8ac6fe58a894 (patch)
tree106ee88e861eae0fc9c783243db3668e8c9c8ae1 /inc/perso.inc
parentf1677164c3f46785f6d9380b68cdeba58a680404 (diff)
downloadcandybox-faefddcb8b3d3ac491331b702f8a8ac6fe58a894.tar.gz
candybox-faefddcb8b3d3ac491331b702f8a8ac6fe58a894.tar.bz2
candybox-faefddcb8b3d3ac491331b702f8a8ac6fe58a894.tar.xz
candybox-faefddcb8b3d3ac491331b702f8a8ac6fe58a894.zip
First PHPDoc push, Inventory not complete
Diffstat (limited to 'inc/perso.inc')
-rw-r--r--inc/perso.inc27
1 files changed, 27 insertions, 0 deletions
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 @@
<?php
+/**
+ * Manages player's stats: life, experience, level.
+ *
+ * @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();
$_SESSION["perso"][$prop] += $num;
}
+/**
+ * Copies stats given in POST request to session.
+ *
+ * @return void
+ */
function updatePerso(){
$hp = $_POST["hp"];
$xp = $_POST["xp"];
@@ -21,6 +43,11 @@ function updatePerso(){
$_SESSION["perso"]["lv"] = +$lv;
}
+/**
+ * Initializes the player's stats.
+ *
+ * @return void
+ */
function initPerso(){
$_SESSION["perso"]["hp"] = 5;
$_SESSION["perso"]["xp"] = 0;