aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authoralexichi <alexbankai96@gmail.com>2016-05-07 10:13:20 +0200
committeralexichi <alexbankai96@gmail.com>2016-05-07 10:13:20 +0200
commitee02581b7fabd087fc4056bda739c88656fbca14 (patch)
tree576b71b4f9d80a6a38d68d4754de9c63c44e9b3f
parentf171811a44364f605712aff1ca0808bfe570ef6e (diff)
downloadcandybox-ee02581b7fabd087fc4056bda739c88656fbca14.tar.gz
candybox-ee02581b7fabd087fc4056bda739c88656fbca14.tar.bz2
candybox-ee02581b7fabd087fc4056bda739c88656fbca14.tar.xz
candybox-ee02581b7fabd087fc4056bda739c88656fbca14.zip
add the display of the perso characteristics below the title
-rw-r--r--inc/perso.inc12
-rw-r--r--js/craftmine.js2
-rw-r--r--js/dungeon.js18
3 files changed, 23 insertions, 9 deletions
diff --git a/inc/perso.inc b/inc/perso.inc
index 075f8ae..4fb05ef 100644
--- a/inc/perso.inc
+++ b/inc/perso.inc
@@ -1,8 +1,8 @@
<?php
function sendPerso() {
- if(!empty($_SESSION["perso"]))
- return $_SESSION["perso"];
- else return false;
+ if(empty($_SESSION["perso"]))
+ initPerso();
+ return $_SESSION["perso"];
}
function updatePerso(){
@@ -14,4 +14,10 @@ function updatePerso(){
$_SESSION["perso"]["lv"] = $lv;
}
+function initPerso(){
+ $_SESSION["perso"]["hp"] = 5;
+ $_SESSION["perso"]["xp"] = 0;
+ $_SESSION["perso"]["lv"] = 3;
+}
+
?>
diff --git a/js/craftmine.js b/js/craftmine.js
index c7a396f..a8619df 100644
--- a/js/craftmine.js
+++ b/js/craftmine.js
@@ -3,7 +3,7 @@ data = {
gold: 0,
mine: 0,
miners: 0,
- level: 4,
+ level: 3,
hp: 5,
xp: 0,
icon : "H"
diff --git a/js/dungeon.js b/js/dungeon.js
index 65d1081..30808ff 100644
--- a/js/dungeon.js
+++ b/js/dungeon.js
@@ -71,11 +71,11 @@ function strike(ret,nb, f){
function endBattle(v,nb, f, ret){
window.clearTimeout(timeout);
- if(v=="mob")exitDungeon();//if you die in the dungeon, you are immediately sent out of the dungeon
+ if(v=="mob")exitDungeon(false);//if you die in the dungeon, you are immediately sent out of the dungeon
//To level up you have to obtain 2 xp to go to lv 3, 3 to go to lv 4, etc
//A mob level 2 , if defeated gives you 2 xp, ...etc
else{
- data.xp += ret[nb].xp;
+ data.xp += parseInt(ret[nb].xp);
if(data.xp>=data.level){
data.xp-=data.level;
data.level++;
@@ -88,6 +88,10 @@ function endBattle(v,nb, f, ret){
if(nb>=3){//floor changing
nb=0;//reset the number of the mob
f++;//increment the number of the floor
+ if(f>=4){
+ exitDungeon(true);//true means that you have completed the dungeon and not just die or exit by yourself
+ return;
+ }
}
var tmphtml = "Le " + v + " a gagné.";
tmphtml += "<button type=\"button\" class=\"btn btn-primary\" onclick=\"launchDungeon("+nb+","+ f +",false)\">Next Battle</button>"
@@ -95,18 +99,22 @@ function endBattle(v,nb, f, ret){
displayExit();
sendRequest("craftmine.php", "op=sendDungeonProgress&floor="+f+"&mob="+nb);
}
+ sendRequest("craftmine.php", "op=updatePerso&hp="+data.hp+"&xp="+data.xp+"&lv="+data.level, function(){
+ displayPerso(data.hp,data.xp,data.level);
+ });
}
function displayExit(){
var tmphtml = "<br/><br/>";
- tmphtml += "<button type=\"button\" class=\"btn btn-primary\" onclick=\"exitDungeon()\">Exit</button>";
+ tmphtml += "<button type=\"button\" class=\"btn btn-primary\" onclick=\"exitDungeon(false)\">Exit</button>";
document.getElementById("tab4").innerHTML += tmphtml;
}
-function exitDungeon(){
+function exitDungeon(boss){
sendRequest("craftmine.php", "op=exitDungeon", function() {
window.clearTimeout(timeout);
- document.getElementById("tab4").innerHTML = "<h4>Look at how poor you are! You can't access the dungeon, it is only for the elite.</h4>";
+ document.getElementById("tab4").innerHTML = "<h4>Not available, you have to buy a ticket in the build section.</h4>";
+ if(boss) showInfo("You have beaten the final boss! CONGRATULATIONS!");
showInfo("You have left the dungeon");
});
}