From 0133251e523b1c984b2b5cdb60c7392c18e6bd73 Mon Sep 17 00:00:00 2001 From: piernov Date: Wed, 27 Apr 2016 19:51:32 +0200 Subject: Add button for saving on server/downloading the game --- index.xhtml | 2 ++ 1 file changed, 2 insertions(+) (limited to 'index.xhtml') diff --git a/index.xhtml b/index.xhtml index aa29615..d12585f 100644 --- a/index.xhtml +++ b/index.xhtml @@ -32,6 +32,8 @@
+ +
-- cgit v1.2.3-70-g09d2 From 31866085151518f468794dc71b541543e6b2f691 Mon Sep 17 00:00:00 2001 From: alexichi Date: Sun, 1 May 2016 11:32:08 +0200 Subject: add the beginning part of the dungeon When you have enough money you can buy a ticket and access the dungeon I made a file monsters.xml . It's a bit like the code with the shop but modified When you press the button launch in the onglet dungeon , it display "Battle!" in the console --- craftmine.php | 3 ++- data/monsters.xml | 63 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ inc/Monster.inc | 19 +++++++++++++++++ inc/dungeon.inc | 39 ++++++++++++++++++++++++++++++++++ inc/messages.inc | 3 ++- index.xhtml | 3 +++ js/dungeon.js | 18 ++++++++++++++++ 7 files changed, 146 insertions(+), 2 deletions(-) create mode 100644 data/monsters.xml create mode 100644 inc/Monster.inc create mode 100644 inc/dungeon.inc create mode 100644 js/dungeon.js (limited to 'index.xhtml') diff --git a/craftmine.php b/craftmine.php index 78c5e37..4cd6b00 100644 --- a/craftmine.php +++ b/craftmine.php @@ -4,7 +4,7 @@ require_once("inc/mine.inc"); require_once("inc/guild.inc"); require_once("inc/shop.inc"); require_once("inc/craftmine.inc"); - +require_once("inc/dungeon.inc"); session_start(); // Must be placed *BEFORE* $_SESSION is actually used and *AFTER* all classes are imported /** @@ -42,6 +42,7 @@ switch($op) { case "getCraftMine": sendCraftMine(); break; case "buildShop": buildShop(); break; case "buyItem": buyItem(); break; + case "buildDungeon" : buildDungeon(); break; default: reportBadRequest(); } diff --git a/data/monsters.xml b/data/monsters.xml new file mode 100644 index 0000000..86cf422 --- /dev/null +++ b/data/monsters.xml @@ -0,0 +1,63 @@ + + + + + monster1 + 1 + 2 + m + + + monster2 + 2 + 3 + m + + + monster3 + 3 + 4 + m + + + + + monster4 + 4 + 5 + m + + + monster5 + 5 + 6 + m + + + monster5 + 6 + 7 + m + + + + + monster6 + 8 + 9 + m + + + monster7 + 9 + 10 + m + + + Boss + 10 + 12 + m + + + diff --git a/inc/Monster.inc b/inc/Monster.inc new file mode 100644 index 0000000..fbb0fe9 --- /dev/null +++ b/inc/Monster.inc @@ -0,0 +1,19 @@ +name = $name; + $this->level = $level; + $this->hp = $hp; + $this->icon = $icon; + + } +} + +?> diff --git a/inc/dungeon.inc b/inc/dungeon.inc new file mode 100644 index 0000000..b2277f0 --- /dev/null +++ b/inc/dungeon.inc @@ -0,0 +1,39 @@ +(string)$monsters["cost"],"monsters"=>array()); + foreach($monsters as $f){ + $floor = (string)$f["name"]; + $dungeon["monsters"][$floor] = array(); + foreach($f as $monster){ + $dungeon["monsters"][$floor][] = new Monster((string)$monster->name, + intval($monster->level), + intval($monster->hp), + (string)$monster->icon); + } + } + return $dungeon; +} + +function initDungeon() { + $_SESSION["dungeon"] = true; +} + +function buildDungeon() { + $dungeon=generateMonster(); + if(!empty($_SESSION["dungeon"])) { + sendError("dungeon_already_available"); + } + elseif(debitAccount($dungeon["cost"])) { + initDungeon(); + $_SESSION["mine"]["gold"] -= $dungeon["cost"]; + echo json_encode($dungeon); + } +} + +?> diff --git a/inc/messages.inc b/inc/messages.inc index d6ea87e..c24bd18 100644 --- a/inc/messages.inc +++ b/inc/messages.inc @@ -5,7 +5,8 @@ $messages = array( "gold_insufficient" => "You don't have enough gold.", "shop_missing_item" => "This item does not exist.", "guild_not_yet_created" => "You need to create a guild first.", - "guild_already_built" => "You have aready built a guild." + "guild_already_built" => "You have aready built a guild.", + "dungeon_already_available" => "You can already access the dungeon" ); function sendError($msg) { diff --git a/index.xhtml b/index.xhtml index aa29615..2745c8a 100644 --- a/index.xhtml +++ b/index.xhtml @@ -15,6 +15,8 @@ + +
@@ -69,6 +71,7 @@
  • +
diff --git a/js/dungeon.js b/js/dungeon.js new file mode 100644 index 0000000..1760afa --- /dev/null +++ b/js/dungeon.js @@ -0,0 +1,18 @@ +function buildDungeon(){ + sendRequest("craftmine.php", "op=buildDungeon", function(ret) { + displayDungeon(); + debitAccount(ret.cost); + showInfo("You can acces the dungeon now. Good Luck."); + }); +} + +function displayDungeon(){ + var tmphtml = "
"; + tmphtml += ""; + //tmphtml += ""; + document.getElementById("tab4").innerHTML = tmphtml; +} + +function launchDungeon(){ + console.log("Battle!"); +} -- cgit v1.2.3-70-g09d2 From f53549e4c2668ca268c8e31ef4c7cf3718fe08b5 Mon Sep 17 00:00:00 2001 From: piernov Date: Mon, 2 May 2016 15:50:14 +0200 Subject: Move saveGame()/downGame() to its own JS file --- index.xhtml | 1 + js/craftmine.js | 8 -------- js/savegame.js | 7 +++++++ 3 files changed, 8 insertions(+), 8 deletions(-) create mode 100644 js/savegame.js (limited to 'index.xhtml') diff --git a/index.xhtml b/index.xhtml index d12585f..e879cf1 100644 --- a/index.xhtml +++ b/index.xhtml @@ -15,6 +15,7 @@ +
diff --git a/js/craftmine.js b/js/craftmine.js index 13dd0a2..92fa45a 100644 --- a/js/craftmine.js +++ b/js/craftmine.js @@ -60,14 +60,6 @@ function updateMine() { updateData("mine"); } -function saveGame() { - sendRequest("craftmine.php", "op=saveGame"); -} - -function downGame() { - window.open("craftmine.php?op=downGame", "_blank"); -} - function init() { initCraftMine(); changeTab(); diff --git a/js/savegame.js b/js/savegame.js new file mode 100644 index 0000000..2a83f77 --- /dev/null +++ b/js/savegame.js @@ -0,0 +1,7 @@ +function saveGame() { + sendRequest("craftmine.php", "op=saveGame"); +} + +function downGame() { + window.open("craftmine.php?op=downSave", "_blank"); +} -- cgit v1.2.3-70-g09d2 From c6e05fbec675d1f60e6adb2b29d6fed4f888fb1d Mon Sep 17 00:00:00 2001 From: piernov Date: Mon, 2 May 2016 15:51:43 +0200 Subject: Add Save tab --- index.xhtml | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) (limited to 'index.xhtml') diff --git a/index.xhtml b/index.xhtml index e879cf1..6627ec5 100644 --- a/index.xhtml +++ b/index.xhtml @@ -65,6 +65,7 @@
  • Shop
  • Inventory
  • Dungeon
  • +
    @@ -83,11 +84,18 @@

    Look at how poor you are! You can't access the dungeon, it is only for the elite.

    +
    +

    Saved games:

    +
    +
    +
      +
    • +
    • +
    • +
    +
    - - -
    -- cgit v1.2.3-70-g09d2 From 036d5a2e88232e966cfd0cc82277d5fba13e71ff Mon Sep 17 00:00:00 2001 From: piernov Date: Wed, 4 May 2016 14:25:50 +0200 Subject: Add upload button for save + move save/download button --- index.xhtml | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'index.xhtml') diff --git a/index.xhtml b/index.xhtml index 6627ec5..5e0752a 100644 --- a/index.xhtml +++ b/index.xhtml @@ -33,8 +33,6 @@
    - -
    @@ -90,7 +88,11 @@
    • +
    • +
    • +
    • +
    -- cgit v1.2.3-70-g09d2 From b994c39019ff6a74870dda3b8c78326ef917ded4 Mon Sep 17 00:00:00 2001 From: piernov Date: Wed, 4 May 2016 14:49:09 +0200 Subject: Remove useless data-toggle attribute --- index.xhtml | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'index.xhtml') diff --git a/index.xhtml b/index.xhtml index 9260134..dea1e22 100644 --- a/index.xhtml +++ b/index.xhtml @@ -60,11 +60,11 @@
    -- cgit v1.2.3-70-g09d2 From fcf504d0cb37545d6157f384eccdfd82daaa55e4 Mon Sep 17 00:00:00 2001 From: piernov Date: Wed, 4 May 2016 14:51:09 +0200 Subject: Remove useless role attributeé MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- index.xhtml | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'index.xhtml') diff --git a/index.xhtml b/index.xhtml index dea1e22..bd2cdf3 100644 --- a/index.xhtml +++ b/index.xhtml @@ -60,11 +60,11 @@
    -- cgit v1.2.3-70-g09d2 From 35ec65de0869c77fc66bf3f2702c561efd98f4af Mon Sep 17 00:00:00 2001 From: piernov Date: Wed, 4 May 2016 14:52:35 +0200 Subject: Move onhashchange event hook from XHTML to JavaScript Add some comments --- index.xhtml | 2 +- js/craftmine.js | 7 ++++--- 2 files changed, 5 insertions(+), 4 deletions(-) (limited to 'index.xhtml') diff --git a/index.xhtml b/index.xhtml index bd2cdf3..f242f76 100644 --- a/index.xhtml +++ b/index.xhtml @@ -18,7 +18,7 @@ - +

    CraftMine

    diff --git a/js/craftmine.js b/js/craftmine.js index 61abbf7..0e95aa3 100644 --- a/js/craftmine.js +++ b/js/craftmine.js @@ -70,7 +70,8 @@ function updateMine() { function init() { initCraftMine(); - changeTab(); - listSaves(); - window.setInterval(updateMine, 1000); + changeTab(); // Switch to tab specified in URL + listSaves(); // Update save list on page load + window.setInterval(updateMine, 1000); // Increase mine amount every 1 second + window.onhashchange = changeTab; // Hook changeTab from js/gui.js to hashchange event } -- cgit v1.2.3-70-g09d2 From 2587d9627294ef3324a88aa6d11be48c72e397f3 Mon Sep 17 00:00:00 2001 From: piernov Date: Wed, 4 May 2016 14:57:54 +0200 Subject: Form → list MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- index.xhtml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'index.xhtml') diff --git a/index.xhtml b/index.xhtml index f242f76..77ddf23 100644 --- a/index.xhtml +++ b/index.xhtml @@ -31,10 +31,10 @@ 0

    Miners : 0

    -
    - - -
    +
      +
    • +
    • +