From e82fa2d62a1f0a6d0496c54425633042d972eb83 Mon Sep 17 00:00:00 2001 From: piernov Date: Sun, 24 Apr 2016 22:12:56 +0200 Subject: Add shop related PHP request handling --- craftmine.php | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'craftmine.php') diff --git a/craftmine.php b/craftmine.php index 5df926f..4582f4e 100644 --- a/craftmine.php +++ b/craftmine.php @@ -2,6 +2,8 @@ session_start(); require_once("inc/mine.inc"); +require_once("inc/shop.inc"); + /** * Indique au client une message requete. */ @@ -33,6 +35,8 @@ $op = $_POST["op"]; switch($op) { case "withdrawMine": withdrawMine(); break; case "getCraftMine": sendMine(); break; + case "buildShop": buildShop(); break; + case "buyItem": buyItem(); break; default: reportBadRequest(); } -- cgit v1.2.3-70-g09d2 From f2c007680664004a0745d14ee375958ce4794330 Mon Sep 17 00:00:00 2001 From: piernov Date: Sun, 24 Apr 2016 22:13:44 +0200 Subject: Move session_start() after all requires (needed for classes to work correctly in $_SESSION) --- craftmine.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'craftmine.php') diff --git a/craftmine.php b/craftmine.php index 4582f4e..c5f09be 100644 --- a/craftmine.php +++ b/craftmine.php @@ -1,9 +1,10 @@ Date: Sun, 24 Apr 2016 22:17:13 +0200 Subject: Send gold, shop and inventory infos from PHP all at once when requested on loading by client --- craftmine.php | 2 +- inc/craftmine.inc | 14 ++++++++++++++ inc/mine.inc | 2 +- 3 files changed, 16 insertions(+), 2 deletions(-) create mode 100644 inc/craftmine.inc (limited to 'craftmine.php') diff --git a/craftmine.php b/craftmine.php index c5f09be..869c83a 100644 --- a/craftmine.php +++ b/craftmine.php @@ -35,7 +35,7 @@ if (!isset($_POST["op"])) { $op = $_POST["op"]; switch($op) { case "withdrawMine": withdrawMine(); break; - case "getCraftMine": sendMine(); break; + case "getCraftMine": sendCraftMine(); break; case "buildShop": buildShop(); break; case "buyItem": buyItem(); break; default: reportBadRequest(); diff --git a/inc/craftmine.inc b/inc/craftmine.inc new file mode 100644 index 0000000..a30538c --- /dev/null +++ b/inc/craftmine.inc @@ -0,0 +1,14 @@ + sendMine(), + "shop" => sendShop(), + "inventory" => Inventory::sendContent(), + ); + echo json_encode($data); +} + +?> diff --git a/inc/mine.inc b/inc/mine.inc index 4293243..6a04cc4 100644 --- a/inc/mine.inc +++ b/inc/mine.inc @@ -14,7 +14,7 @@ function withdrawMine() { function sendMine() { if(empty($_SESSION["mine"])) initCraftMine(); $mine = $_SESSION["mine"]; - echo $mine["gold"]; + return $mine["gold"]; } -- cgit v1.2.3-70-g09d2 From 8cb6c33190dc4133771705fefacb2cea14568c4d Mon Sep 17 00:00:00 2001 From: piernov Date: Sun, 24 Apr 2016 22:37:56 +0200 Subject: Include PHP inc/craftmine.php --- craftmine.php | 1 + 1 file changed, 1 insertion(+) (limited to 'craftmine.php') diff --git a/craftmine.php b/craftmine.php index 869c83a..4d08ffd 100644 --- a/craftmine.php +++ b/craftmine.php @@ -2,6 +2,7 @@ require_once("inc/mine.inc"); require_once("inc/shop.inc"); +require_once("inc/craftmine.inc"); session_start(); // Must be placed *BEFORE* $_SESSION is actually used and *AFTER* all classes are imported -- cgit v1.2.3-70-g09d2