aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorpiernov <piernov@piernov.org>2016-05-10 23:40:17 +0200
committerpiernov <piernov@piernov.org>2016-05-10 23:40:17 +0200
commit1158d2063f00f38de19a4600566b244a942d86ba (patch)
tree5ada3489d5a7651f978623b8809a9cbcbff180ad
parent21aedf3aec9de4f87c8598b32a2a0b1c18a0c43d (diff)
downloadcandybox-1158d2063f00f38de19a4600566b244a942d86ba.tar.gz
candybox-1158d2063f00f38de19a4600566b244a942d86ba.tar.bz2
candybox-1158d2063f00f38de19a4600566b244a942d86ba.tar.xz
candybox-1158d2063f00f38de19a4600566b244a942d86ba.zip
Add reset current game buttonHEADmaster
-rw-r--r--craftmine.php1
-rw-r--r--inc/craftmine.inc4
-rw-r--r--index.xhtml1
-rw-r--r--js/craftmine.js6
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