From 3a93ebcfbe59e944a480665745eb0617e1fe8419 Mon Sep 17 00:00:00 2001 From: adplantade Date: Thu, 23 Jul 2020 18:42:53 +0200 Subject: [PATCH] =?UTF-8?q?re-r=C3=A9paration=20de=20score.php,=20d=C3=A9b?= =?UTF-8?q?ut=20de=20highscores.php?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- code/button_displayer.js | 7 ++ code/data.db | Bin 61440 -> 61440 bytes code/highscore_button_displayer.js | 46 ++++++++++ code/highscores.css | 94 ++++++++++++++++++++ code/highscores.php | 134 +++++++++++++++++++++++++++++ code/index.php | 22 +++++ code/score.php | 7 +- code/vitraux.js | 4 + 8 files changed, 310 insertions(+), 4 deletions(-) create mode 100644 code/highscore_button_displayer.js create mode 100644 code/highscores.css create mode 100644 code/highscores.php diff --git a/code/button_displayer.js b/code/button_displayer.js index 3414852..2fd11c0 100644 --- a/code/button_displayer.js +++ b/code/button_displayer.js @@ -30,10 +30,12 @@ modes.forEach(element => { document.getElementById(e.currentTarget.id).classList.add("selected"); modeSelected= e.currentTarget.id; + setCookie("modeSelected",modeSelected,30); if(modeSelected!=null && diffSelected!=null) { document.getElementById("btn_play").disabled = false; } + dispHighscores(); }); } }); @@ -44,6 +46,7 @@ diffs.forEach(element => { eval("btn_"+element).addEventListener("mousedown",function(e) { diffSelected= e.currentTarget.id.substring(4); + //setCookie("diffSelected",diffSelected,30); var tab=document.getElementById("diff").children; for(var cpt=0;cpt { { document.getElementById("btn_play").disabled = false; } + dispHighscores(); }); }) @@ -65,6 +69,9 @@ function disp(what) }) } + + + function hideAll() { document.getElementById("temps").style.display="none"; diff --git a/code/data.db b/code/data.db index 7e9cb2723bfe0af04cce69a5ebea56153e9c3fb3..2c39e5304aec761e34d7e5984955a7eab38c77f3 100644 GIT binary patch delta 278 zcmZp8z})bFd4e=!^h6nF#^{X+OY#NS_?;Q}AMhXGU%=nMpTzIHSy4fszh0J&Ls(Rh zkwcL&u_`emu_(o~fW^qb$UxV?T-V5$MTV6_5GtLDA4teZ)W z87`lgh$+t|$29p+y%W%7Jq-Lu`RDU*x diff --git a/code/highscore_button_displayer.js b/code/highscore_button_displayer.js new file mode 100644 index 0000000..2b5742a --- /dev/null +++ b/code/highscore_button_displayer.js @@ -0,0 +1,46 @@ +var modes=["points","temps","survie"]; +var diffs=["easy","med","hard"]; +size=screen.height/6; +hideAll(); + +modes.forEach(element => { + + eval("var img_"+element+"= document.getElementById('img_"+element+"')"); + eval("img_"+element+".width=size"); + eval("img_"+element).addEventListener("mousedown",function(e){disp(e);}); + var tab=document.getElementById(element).children; + for(var i=1;i { + document.getElementById(element).style.display=what==element ? "flex":"none"; + }) +} + +function hideAll() +{ + document.getElementById("temps").style.display="none"; + document.getElementById("points").style.display="none"; + document.getElementById("survie").style.display="none"; +} \ No newline at end of file diff --git a/code/highscores.css b/code/highscores.css new file mode 100644 index 0000000..a46f7e0 --- /dev/null +++ b/code/highscores.css @@ -0,0 +1,94 @@ +.all-container { + display : flex; + + align-items: baseline; + width : min-content; + + margin: 5px; + + +} + +.button { + padding: 2px; +} + +[type="radio"] { + display: none; +} + +.selected { + -webkit-box-shadow:inset 0px 0px 0px 5px black; + -moz-box-shadow:inset 0px 0px 0px 5px black; + box-shadow:inset 0px 0px 0px 5px black; +} + +.slider { + -webkit-appearance: none; + width: 100%; + height: 15px; + border-radius: 5px; + background: #d3d3d3; + outline: none; + opacity: 0.7; + -webkit-transition: .2s; + transition: opacity .2s; + } + + .slider::-webkit-slider-thumb { + -webkit-appearance: none; + appearance: none; + width: 25px; + height: 25px; + border-radius: 50%; + background: #4CAF50; + cursor: pointer; + } + + .slider::-moz-range-thumb { + width: 25px; + height: 25px; + border-radius: 50%; + background: #4CAF50; + cursor: pointer; + } + + + /* The Modal (background) */ +.modal { + display: none; /* Hidden by default */ + position: fixed; /* Stay in place */ + z-index: 1; /* Sit on top */ + padding-top: 100px; /* Location of the box */ + left: 0; + top: 0; + width: 100%; /* Full width */ + height: 100%; /* Full height */ + overflow: auto; /* Enable scroll if needed */ + background-color: rgb(0,0,0); /* Fallback color */ + background-color: rgba(0,0,0,0.4); /* Black w/ opacity */ + } + + /* Modal Content */ + .modal-content { + background-color: #fefefe; + margin: auto; + padding: 20px; + border: 1px solid #888; + width: 80%; + } + + /* The Close Button */ + .close { + color: #aaaaaa; + float: right; + font-size: 28px; + font-weight: bold; + } + + .close:hover, + .close:focus { + color: #000; + text-decoration: none; + cursor: pointer; + } \ No newline at end of file diff --git a/code/highscores.php b/code/highscores.php new file mode 100644 index 0000000..812776d --- /dev/null +++ b/code/highscores.php @@ -0,0 +1,134 @@ + + + + +
+

difficulty :

+

dotsAmount :

+

pause :

+
+
    + + + + + +
+
    + + + + + + + + + + + + +
+
    + + + + + + +
+
    + + + + + + + + + +
+
+ +
+ + +query($sql); + $a=$result->fetchArray(); + + echo "

".print_r($a)."

"; + echo "

".var_dump($_POST)."

"; +} \ No newline at end of file diff --git a/code/index.php b/code/index.php index f924a83..6fdfb83 100644 --- a/code/index.php +++ b/code/index.php @@ -41,6 +41,11 @@ Jouer la partie en :
+
+ Meilleur score dans ce mode (avec vos préférences) : +

+ +
Entrez votre pseudo (optionnel, mais nécessaire si vous voulez sauvegarder votre score): @@ -92,6 +97,23 @@ Jouer la partie en :
+ + diff --git a/code/score.php b/code/score.php index 0819a44..67306bc 100644 --- a/code/score.php +++ b/code/score.php @@ -11,18 +11,17 @@ Votre score est :

$database = new SQLite3("data.db"); if(stristr($_GET['mode'], "p") === FALSE) { - $sql='select score, player from score where game_mode="'.$_GET['mode'].'" and difficulty="'.$_GET['diff'].'" and dots_amount='.$_COOKIE["dotsAmount"].' and pause='.$_COOKIE["pause"].' and score=(select min(score) from score)'; + $sql='select score, player from score where game_mode="'.$_GET['mode'].'" and difficulty="'.$_GET['diff'].'" and dots_amount='.$_COOKIE["dotsAmount"].' and pause='.$_COOKIE["pause"].' and score=(select min(score) from score where game_mode="'.$_GET['mode'].'" and difficulty="'.$_GET['diff'].'" and dots_amount='.$_COOKIE["dotsAmount"].' and pause='.$_COOKIE["pause"].')'; } else { - $sql='select score, player from score where game_mode="'.$_GET['mode'].'" and difficulty="'.$_GET['diff'].'" and dots_amount='.$_COOKIE["dotsAmount"].' and pause='.$_COOKIE["pause"].' and score=(select max(score) from score)'; + $sql='select score, player from score where game_mode="'.$_GET['mode'].'" and difficulty="'.$_GET['diff'].'" and dots_amount='.$_COOKIE["dotsAmount"].' and pause='.$_COOKIE["pause"].' and score=(select max(score) from score where game_mode="'.$_GET['mode'].'" and difficulty="'.$_GET['diff'].'" and dots_amount='.$_COOKIE["dotsAmount"].' and pause='.$_COOKIE["pause"].')'; } $result = $database->query($sql); $a=$result->fetchArray(); - -if($a[0]==null) +if($a==false) { echo "Vous avez le premier score de ce mode de jeu."; } diff --git a/code/vitraux.js b/code/vitraux.js index 8e66503..f898ceb 100644 --- a/code/vitraux.js +++ b/code/vitraux.js @@ -24,6 +24,8 @@ tabTotal=[]; tabObjCmp=[]; mousePos=[]; +var pause=getCookie("pause"); + var displayType = getCookie("displayMode")=="" ? "gems" : getCookie("displayMode"); var dotsAmount= getCookie("dotsAmount")=="" ? 4 : getCookie("dotsAmount"); @@ -502,6 +504,8 @@ function checkAllOK(){ { var audio = new Audio('ress/Jewel4.mp3'); audio.play(); + if(pause) + chronoStop(); handleScore(1); generate(); }