From cdba8c2fd7785b0a6506d1369d790bbd1d8542ad Mon Sep 17 00:00:00 2001 From: piernov Date: Sun, 8 May 2016 14:42:30 +0200 Subject: Read features from XML + send updated perso stats on useItem() --- inc/shop.inc | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) (limited to 'inc') 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)); } -- cgit v1.2.3-70-g09d2