aboutsummaryrefslogtreecommitdiffstats
path: root/inc/perso.inc
diff options
context:
space:
mode:
authorpiernov <piernov@piernov.org>2016-05-10 22:24:50 +0200
committerpiernov <piernov@piernov.org>2016-05-10 22:24:50 +0200
commit9ad61ab6a23bd6fd51e67b85d743b4a7664ec637 (patch)
tree04c4ef3158c9848db91e56f9318162431a6040b4 /inc/perso.inc
parent204e838a7794bbce0d44fc35efb367abb052d02f (diff)
parent1e52affe15fb13e920f8942de998073238be6d01 (diff)
downloadcandybox-9ad61ab6a23bd6fd51e67b85d743b4a7664ec637.tar.gz
candybox-9ad61ab6a23bd6fd51e67b85d743b4a7664ec637.tar.bz2
candybox-9ad61ab6a23bd6fd51e67b85d743b4a7664ec637.tar.xz
candybox-9ad61ab6a23bd6fd51e67b85d743b4a7664ec637.zip
Merge branch 'phpdoc' into piernov
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;