aboutsummaryrefslogtreecommitdiffstats
path: root/inc
diff options
context:
space:
mode:
Diffstat (limited to 'inc')
-rw-r--r--inc/Monster.inc4
-rw-r--r--inc/craftmine.inc2
-rw-r--r--inc/dungeon.inc5
-rw-r--r--inc/perso.inc17
4 files changed, 25 insertions, 3 deletions
diff --git a/inc/Monster.inc b/inc/Monster.inc
index fbb0fe9..c7063ec 100644
--- a/inc/Monster.inc
+++ b/inc/Monster.inc
@@ -5,12 +5,14 @@ class Monster {
public $icon = "";
public $desc = "";
public $hp = 1;
+ public $xp = 0;
public $level = 1;
- function __construct($name, $level, $hp, $icon) {
+ function __construct($name, $level, $hp, $xp, $icon) {
$this->name = $name;
$this->level = $level;
$this->hp = $hp;
+ $this->xp = $xp;
$this->icon = $icon;
}
diff --git a/inc/craftmine.inc b/inc/craftmine.inc
index 0d6a445..f5dbbb1 100644
--- a/inc/craftmine.inc
+++ b/inc/craftmine.inc
@@ -3,6 +3,7 @@
require_once("mine.inc");
require_once("shop.inc");
require_once("dungeon.inc");
+require_once("perso.inc");
function sendCraftMine() {
$data = array("gold" => sendMine(),
@@ -10,6 +11,7 @@ function sendCraftMine() {
"inventory" => Inventory::sendContent(),
"miners" => sendMiners(),
"dungeon" => sendDungeon(),
+ "perso" => sendPerso(),
);
echo json_encode($data);
}
diff --git a/inc/dungeon.inc b/inc/dungeon.inc
index ebe74b7..c023cf8 100644
--- a/inc/dungeon.inc
+++ b/inc/dungeon.inc
@@ -12,8 +12,9 @@ function generateMonster(){
$dungeon["monsters"][$floor] = array();
foreach($f as $monster){
$dungeon["monsters"][$floor][] = new Monster((string)$monster->name,
- intval($monster->level),
- intval($monster->hp),
+ intval($monster->level),
+ intval($monster->hp),
+ intval($monster->xp),
(string)$monster->icon);
}
}
diff --git a/inc/perso.inc b/inc/perso.inc
new file mode 100644
index 0000000..075f8ae
--- /dev/null
+++ b/inc/perso.inc
@@ -0,0 +1,17 @@
+<?php
+function sendPerso() {
+ if(!empty($_SESSION["perso"]))
+ return $_SESSION["perso"];
+ else return false;
+}
+
+function updatePerso(){
+ $hp = $_POST["hp"];
+ $xp = $_POST["xp"];
+ $lv = $_POST["lv"];
+ $_SESSION["perso"]["hp"] = $hp;
+ $_SESSION["perso"]["xp"] = $xp;
+ $_SESSION["perso"]["lv"] = $lv;
+}
+
+?>