From 1158d2063f00f38de19a4600566b244a942d86ba Mon Sep 17 00:00:00 2001 From: piernov Date: Tue, 10 May 2016 23:40:17 +0200 Subject: Add reset current game button --- craftmine.php | 1 + inc/craftmine.inc | 4 ++++ index.xhtml | 1 + js/craftmine.js | 6 ++++++ 4 files changed, 12 insertions(+) diff --git a/craftmine.php b/craftmine.php index 9a8806b..c79ddc2 100644 --- a/craftmine.php +++ b/craftmine.php @@ -61,6 +61,7 @@ switch($op) { case "listSaves": listSaves(); break; case "loadSave": loadSave(); break; case "deleteSave": deleteSave(); break; + case "resetGame": resetGame(); break; default: reportBadRequest(); } diff --git a/inc/craftmine.inc b/inc/craftmine.inc index 7dd5ba4..35a7e18 100644 --- a/inc/craftmine.inc +++ b/inc/craftmine.inc @@ -29,4 +29,8 @@ function sendCraftMine() { echo json_encode($data); } +function resetGame() { + $_SESSION = array(); +} + ?> diff --git a/index.xhtml b/index.xhtml index 7c32ee3..dc11052 100644 --- a/index.xhtml +++ b/index.xhtml @@ -114,6 +114,7 @@ + diff --git a/js/craftmine.js b/js/craftmine.js index fa70809..e88d84c 100644 --- a/js/craftmine.js +++ b/js/craftmine.js @@ -86,6 +86,12 @@ function updateMine() { updateData("mine"); } +function resetGame() { + sendRequest("craftmine.php", "op=resetGame", function() { + initCraftMine() + }); +} + function init() { initCraftMine(); changeTab(); // Switch to tab specified in URL -- cgit v1.2.3-54-g00ecf