aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorpiernov <piernov@piernov.org>2016-05-08 14:42:30 +0200
committerpiernov <piernov@piernov.org>2016-05-08 14:42:30 +0200
commitcdba8c2fd7785b0a6506d1369d790bbd1d8542ad (patch)
tree3938c31879a0c74058e83c112ae4bab0db623f2c
parentb0d42a638c35836f0bbf91080de2699791b4858e (diff)
downloadcandybox-cdba8c2fd7785b0a6506d1369d790bbd1d8542ad.tar.gz
candybox-cdba8c2fd7785b0a6506d1369d790bbd1d8542ad.tar.bz2
candybox-cdba8c2fd7785b0a6506d1369d790bbd1d8542ad.tar.xz
candybox-cdba8c2fd7785b0a6506d1369d790bbd1d8542ad.zip
Read features from XML + send updated perso stats on useItem()
-rw-r--r--inc/shop.inc13
1 files changed, 11 insertions, 2 deletions
diff --git a/inc/shop.inc b/inc/shop.inc
index 32ecea2..69161e1 100644
--- a/inc/shop.inc
+++ b/inc/shop.inc
@@ -4,6 +4,7 @@ require_once("messages.inc");
require_once("account.inc");
require_once("Item.inc");
require_once("Inventory.inc");
+require_once("perso.inc");
function loadShop(){
$items = simplexml_load_file('data/items.xml');
@@ -12,7 +13,15 @@ function loadShop(){
$category = (string)$cat["name"];
$shop["items"][$category] = array();
foreach($cat as $item){
- $shop["items"][$category][] = new Item((string)$item->name,intval($item->cost),(string)$item->icon,(string)$item->description);
+ $feats = array();
+ foreach($item->features[0] as $k => $v)
+ $feats[(string)$k] = (string)$v;
+ $shop["items"][$category][] = new Item(
+ (string)$item->name,
+ intval($item->cost),
+ (string)$item->icon,
+ (string)$item->description,
+ $feats);
}
}
return $shop;
@@ -63,7 +72,7 @@ function buyItem() {
function useItem(){
$item = getItem($_POST["item"]);
$it = Inventory::useItem($item);
- echo json_encode($it);
+ echo json_encode(array("perso" => sendPerso(), "item" => $it));
}