diff options
author | alexichi <alexbankai96@gmail.com> | 2016-05-05 23:06:29 +0200 |
---|---|---|
committer | alexichi <alexbankai96@gmail.com> | 2016-05-05 23:09:21 +0200 |
commit | f171811a44364f605712aff1ca0808bfe570ef6e (patch) | |
tree | a970a69853e19ef43d97c2f48d61a6fb34637ff6 /inc | |
parent | 1efc4a15c8ab913bf8bdb1aef9f3b5720b3b7762 (diff) | |
download | candybox-f171811a44364f605712aff1ca0808bfe570ef6e.tar.gz candybox-f171811a44364f605712aff1ca0808bfe570ef6e.tar.bz2 candybox-f171811a44364f605712aff1ca0808bfe570ef6e.tar.xz candybox-f171811a44364f605712aff1ca0808bfe570ef6e.zip |
add xp system and perso server side
Diffstat (limited to 'inc')
-rw-r--r-- | inc/Monster.inc | 4 | ||||
-rw-r--r-- | inc/craftmine.inc | 2 | ||||
-rw-r--r-- | inc/dungeon.inc | 5 | ||||
-rw-r--r-- | inc/perso.inc | 17 |
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; +} + +?> |