diff options
-rw-r--r-- | craftmine.php | 1 | ||||
-rw-r--r-- | inc/craftmine.inc | 4 | ||||
-rw-r--r-- | index.xhtml | 1 | ||||
-rw-r--r-- | js/craftmine.js | 6 |
4 files changed, 12 insertions, 0 deletions
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 @@ <input type="file" id="selectedFile" style="display: none;" accept=".save.xml" onchange="uploadSave()" /> <button class="btn btn-success" type="button" onclick="document.getElementById('selectedFile').click()">Upload</button> <button class="btn btn-success" type="button" onclick="deleteSave()">Delete</button> + <button class="btn btn-success" type="button" onclick="resetGame()">Reset current game</button> </div> </div> </div> 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 |