Browse Source

Merge remote-tracking branch 'origin/master'

PCYoshi 9 years ago
parent
commit
31f373cad7
13 changed files with 513 additions and 158 deletions
  1. 2
    0
      .gitignore
  2. 17
    16
      web/api/model/class.categorie.php
  3. 105
    0
      web/css/game.css
  4. 34
    12
      web/css/main.css
  5. 13
    10
      web/index.htm
  6. 70
    36
      web/js/game.js
  7. 37
    27
      web/js/multi.js
  8. 57
    28
      web/multi.php
  9. 47
    0
      web/palmares.htm
  10. 46
    19
      web/play.htm
  11. 41
    0
      web/rules.htm
  12. 44
    0
      web/solo.htm
  13. 0
    10
      web/test.php

+ 2
- 0
.gitignore View File

1
 # VIM temp files
1
 # VIM temp files
2
 .*.swp
2
 .*.swp
3
+
4
+test*

+ 17
- 16
web/api/model/class.categorie.php View File

43
 
43
 
44
 	public static function randSelect() {
44
 	public static function randSelect() {
45
 		$bdd = new Connector();
45
 		$bdd = new Connector();
46
-		$arrayCat = $bdd->Select("*", "categorie");
46
+		$options = array(
47
+			"order by" => array("rand()"),
48
+		);
49
+		$arrayCat = $bdd->Select("*", "categorie", $options);
47
 		$return = array();
50
 		$return = array();
48
 		$catIndex = -1;
51
 		$catIndex = -1;
49
 		$previousIndex = -1;
52
 		$previousIndex = -1;
50
-		for($i = 0; $i < 2; $i++) {
51
-			do {
52
-				$filled = true;
53
-				$previousIndex = $catIndex;
54
-				$catIndex = rand(0, sizeof($arrayCat)-1);
55
-				$category = new Categorie($arrayCat[$catIndex]['nom_cat']);
56
-				if(sizeof($category->getArray()['themes']) >=2) {
57
-					foreach($category->getArray()['themes'] as $theme) {
58
-						if(sizeof($theme['questions']) < 3) {
59
-							$filled = false;
60
-						}
53
+		for($i = 0; $i < sizeof($arrayCat); $i++) {
54
+			$category = new Categorie($arrayCat[$i]['nom_cat']);
55
+			if(sizeof($category->getArray()['themes']) >=2) {
56
+				foreach($category->getArray()['themes'] as $theme) {
57
+					if(sizeof($theme['questions']) < 3) {
58
+						array_splice($arrayCat, $i, 1);
61
 					}
59
 					}
62
-				} else {
63
-					$filled = false;
64
 				}
60
 				}
65
-			} while(($catIndex == $previousIndex) || !$filled);
66
-			array_push($return, new Categorie($arrayCat[$catIndex]['nom_cat']));
61
+			} else {
62
+				array_splice($arrayCat, $i, 1);
63
+			}
67
 		}
64
 		}
65
+		for($i = 0; $i < 2; $i++) {
66
+			array_push($return, new Categorie($arrayCat[$i]['nom_cat']));
67
+		}
68
+
68
 		return $return;
69
 		return $return;
69
 	}
70
 	}
70
 
71
 

+ 105
- 0
web/css/game.css View File

1
+section#navbar li.current:last-child #score {
2
+  display:inline;
3
+  padding-top:17px;
4
+  padding-left:30px;
5
+  padding-right:30px;
6
+  padding-bottom:18px;
7
+  background: #ffab19;
8
+}
9
+
10
+section#game input[type="submit"]#play {
11
+  border:none;
12
+  background-color:#09b22b;
13
+  color:white;
14
+  padding:20px;
15
+  font-size:170%;
16
+  cursor:pointer;
17
+}
18
+
19
+section#game {
20
+  text-align:center;
21
+}
22
+
23
+div#category {
24
+  font-size:170%;
25
+  font-family:'Lato';
26
+  font-weight:300;
27
+  margin-top:20px;
28
+}
29
+
30
+p#question {
31
+  font-size:120%;
32
+}
33
+
34
+ul#answers {
35
+  padding-left:0px;
36
+}
37
+
38
+ul#answers li {
39
+  display:inline-block;
40
+  background: #b087ff;
41
+  width:16%;
42
+  padding:20px;
43
+  padding-top:38px;
44
+  height:42px;
45
+  font-size:110%;
46
+  color:white;
47
+  font-weight:bold;
48
+  margin-right:20px;
49
+  line-height: 20px;
50
+  vertical-align: middle;
51
+  cursor: pointer;
52
+}
53
+
54
+ul#answers li.good-answer {
55
+  background: #57cc6b;
56
+}
57
+
58
+ul#answers li.wrong-answer {
59
+  background: #cc5757;
60
+}
61
+
62
+h2#score {
63
+  margin-top: 100px;
64
+  font-size:220%;
65
+  margin-bottom:10px;
66
+}
67
+
68
+p#registerScore, p#conDenied {
69
+  width: 40%;
70
+  margin: auto;
71
+}
72
+
73
+p.success {
74
+  padding-top: 30px;
75
+  background:#57cc6b;
76
+  padding-bottom: 30px;
77
+}
78
+
79
+p.error {
80
+  padding-top: 30px;
81
+  background:#cc5757;
82
+  padding-bottom: 30px;
83
+  color:white;
84
+}
85
+
86
+p#conDenied {
87
+  margin-top:70px;
88
+}
89
+
90
+@media all and (max-width: 799px) {
91
+  ul#answers li {
92
+    display:block;
93
+    margin:auto;
94
+    margin-bottom:10px;
95
+    width:80%;
96
+    padding-top:15px;
97
+    height: 20px;
98
+  }
99
+}
100
+
101
+@media all and (min-width: 800px) {
102
+  ul#answers li:last-child {
103
+    margin-right:0px;
104
+  }
105
+}

+ 34
- 12
web/css/main.css View File

5
   background: #fffdc6;
5
   background: #fffdc6;
6
 }
6
 }
7
 
7
 
8
+p a, #game a, p a:visited, p a:visited {
9
+  text-decoration: underline;
10
+  color:black;
11
+}
12
+
8
 a, a:visited {
13
 a, a:visited {
9
   color: white;
14
   color: white;
10
   text-decoration: none;
15
   text-decoration: none;
11
 }
16
 }
12
 
17
 
18
+a:active{
19
+  background:transparent
20
+}
21
+
13
 section#navbar a:hover {
22
 section#navbar a:hover {
14
   text-decoration:none;
23
   text-decoration:none;
15
 }
24
 }
24
   padding-bottom: 10px;
33
   padding-bottom: 10px;
25
 }
34
 }
26
 
35
 
27
-section#responsive-navbar img {
28
-  margin-right:10px;
29
-  margin-top:8px;
30
-  float:right;
31
-  height: 1.3em;
32
-}
33
-
34
 section#responsive-navbar {
36
 section#responsive-navbar {
35
   display: none;
37
   display: none;
36
   margin-top:0px;
38
   margin-top:0px;
43
   margin-top:0px;
45
   margin-top:0px;
44
   list-style-type:none;
46
   list-style-type:none;
45
   padding-left:0px;
47
   padding-left:0px;
48
+  width:100%;
49
+  margin-bottom:0px;
46
 }
50
 }
47
 
51
 
48
 section#responsive-navbar ul li {
52
 section#responsive-navbar ul li {
54
 }
58
 }
55
 
59
 
56
 section#responsive-navbar ul li a {
60
 section#responsive-navbar ul li a {
61
+  display:block;
57
   width:100%;
62
   width:100%;
58
 }
63
 }
59
 
64
 
60
-section#responsive-navbar ul li.play {
65
+section#responsive-navbar ul li:last-child {
61
   background: #ff9619;
66
   background: #ff9619;
62
 }
67
 }
63
 
68
 
64
-section#responsive-navbar ul li.play:hover {
69
+section#responsive-navbar ul li:last-child.current {
70
+  background: #ffab19;
71
+}
72
+
73
+section#responsive-navbar ul li:last-child:hover {
65
   background: #ffab19;
74
   background: #ffab19;
66
 }
75
 }
67
 
76
 
69
   background: #9556f9;
78
   background: #9556f9;
70
 }
79
 }
71
 
80
 
72
-section#responsive-navbar ul li:first-child, section#responsive-navbar ul li:first-child:hover {
81
+section#responsive-navbar ul li:first-child, section#responsive-navbar ul li:first-child:hover, section#responsive-navbar ul li:first-child:active {
73
   background-color: #7e19ff;
82
   background-color: #7e19ff;
74
   background-image: url('../assets/burger-menu.png');
83
   background-image: url('../assets/burger-menu.png');
75
   background-size: 25px;
84
   background-size: 25px;
126
   background: #ff9619;
135
   background: #ff9619;
127
 }
136
 }
128
 
137
 
129
-section#navbar li:last-child:hover a {
138
+section#navbar li:last-child:hover a, section#navbar li.current:last-child a {
130
   background: #ffab19;
139
   background: #ffab19;
131
 }
140
 }
132
 
141
 
135
   margin: auto;
144
   margin: auto;
136
 }
145
 }
137
 
146
 
138
-section#page h2 {
147
+h1 {
148
+  text-align: center;
149
+  font-size: 400%;
150
+}
151
+
152
+h2 {
139
   text-align: center;
153
   text-align: center;
140
   font-size: 200%;
154
   font-size: 200%;
141
 }
155
 }
166
   margin:auto;
180
   margin:auto;
167
 }
181
 }
168
 
182
 
183
+section#page ol {
184
+  text-align:center;
185
+  font-size: 120%;
186
+}
187
+
169
 @media all and (max-width: 799px) {
188
 @media all and (max-width: 799px) {
189
+  header {
190
+    background-size: 68%;
191
+  }
170
   section#responsive-navbar {
192
   section#responsive-navbar {
171
     display: block;
193
     display: block;
172
   }
194
   }

+ 13
- 10
web/index.htm View File

7
     <link href='http://fonts.googleapis.com/css?family=Open+Sans' rel='stylesheet' type='text/css'>
7
     <link href='http://fonts.googleapis.com/css?family=Open+Sans' rel='stylesheet' type='text/css'>
8
     <script src="js/jquery-2.1.4.min.js"></script>
8
     <script src="js/jquery-2.1.4.min.js"></script>
9
     <script src="js/responsive.js"></script>
9
     <script src="js/responsive.js"></script>
10
+    <meta name=viewport content="width=device-width, initial-scale=1"/>
10
   </head>
11
   </head>
11
   <body>
12
   <body>
12
     <header>
13
     <header>
13
     </header>
14
     </header>
14
     <section id="navbar">
15
     <section id="navbar">
15
       <ul>
16
       <ul>
16
-        <li class="current"><a href="#">Accueil</a></li>
17
-        <li><a href="#">Règles</a></li>
18
-        <li><a href="#">Meilleurs scores</a></li>
19
-        <li><a href="#">Jouer</a></li>
17
+        <li class="current"><a href="index.htm">Accueil</a></li>
18
+        <li><a href="rules.htm">Règles</a></li>
19
+        <li><a href="palmares.htm">Meilleurs scores</a></li>
20
+        <li><a href="play.htm">Jouer</a></li>
20
       </ul>
21
       </ul>
21
     </section>
22
     </section>
22
     <section id="responsive-navbar">
23
     <section id="responsive-navbar">
23
       <ul>
24
       <ul>
24
         <li class="name"><a href="#">Menu</a></li>
25
         <li class="name"><a href="#">Menu</a></li>
25
-        <li class="current"><a href="#">Accueil</a></li>
26
-        <li><a href="#">Règles</a></li>
27
-        <li><a href="#">Meilleurs scores</a></li>
28
-        <li class="play"><a href="#">Jouer</a></li>
26
+        <li class="current"><a href="index.htm">Accueil</a></li>
27
+        <li><a href="rules.htm">Règles</a></li>
28
+        <li><a href="palmares.htm">Meilleurs scores</a></li>
29
+        <li><a href="play.htm">Jouer</a></li>
29
       </ul>
30
       </ul>
30
     </section>
31
     </section>
31
     <section id="page">
32
     <section id="page">
32
       <article>
33
       <article>
33
         <h2>Accueil</h2>
34
         <h2>Accueil</h2>
34
-        <p>Skevent dleout danvez biz-yod rumm goz gar tabut bazh mil skrijañ, Menez Du dec'h ehan kreisteiz neud tad eil huanadiñ bed lizherenn. Lies gwinegr c'hoar-gaer. Houlenn Menez Mikael anv koumoul, broust brumenn daoust ha. Ret ki lazhañ dianav gwenn hor beg-douar arabat skubañ ken truez tre kar hon leue droug-mor, chom hennezh hag Bro-saoz. Ma fazi geot kein gwechall, rak mil c'hwezhañ e fri hor kae diwar-benn mousc'hoarzhin mat bloaz plijadur hol kant eost noz dre mae nerzh kaeraat, kenwerzh nec'h hir diriaou c'hoar-gaer, a-benn diwar ar maez derc'hel digor pesketaer dir pri start karrezek. Pegement kontañ giz kluchañ n'eus forzh.</p>
35
+        <p>Créé dans le cadre du projet de fin d'année de la promo 2018 de CIR2 de l'ISEN Brest/Rennes, le Burger Quizz est une adaptation numérique du jeu télévisé éponyme, plus précisément d'une épreuve spécifique de ce jeu : le "Sel ou Poivre".</p>
36
+        <p>Dans cette épreuve de rapidité, les joueurs sont confrontés à des jeux de questions correspondant à plusieurs thèmes sur différentes catégories. Pour plus d'informations, consulter la rubrique <a href="rules.htm">"Règles"</a> du site.</p>
35
       </article>
37
       </article>
36
       <article id="jouer">
38
       <article id="jouer">
37
         <h2>Jouer</h2>
39
         <h2>Jouer</h2>
38
         <div class="button">
40
         <div class="button">
39
-          <a href="play.htm">
41
+          <a href="solo.htm">
40
             <div class="firstword">
42
             <div class="firstword">
41
               Solo
43
               Solo
42
             </div>
44
             </div>
51
             2 joueurs
53
             2 joueurs
52
           </a>
54
           </a>
53
         </div>
55
         </div>
56
+      </article>
54
     </section>
57
     </section>
55
   </body>
58
   </body>
56
 </html>
59
 </html>

+ 70
- 36
web/js/game.js View File

4
 var json, category, theme;
4
 var json, category, theme;
5
 // Timer
5
 // Timer
6
 var timing = 5, secRestantes, timer;
6
 var timing = 5, secRestantes, timer;
7
+var questions = 0, currentQuestion = 1;
7
 var baseWidth;
8
 var baseWidth;
8
 
9
 
9
 var score = 0;
10
 var score = 0;
11
 var canClick = true;
12
 var canClick = true;
12
 
13
 
13
 function play() {
14
 function play() {
14
-  $("#play").remove();
15
-  $("#multi").remove();
16
   apiReq();
15
   apiReq();
16
+  $("#play").remove();
17
   if(json.status != 1) {
17
   if(json.status != 1) {
18
     var message;
18
     var message;
19
     switch(json.source) {
19
     switch(json.source) {
64
     dataType: 'json',
64
     dataType: 'json',
65
     success: function(data) {
65
     success: function(data) {
66
       json = data;
66
       json = data;
67
+      json.cat1.themes.forEach(function(theme) {
68
+        questions += theme.questions.length;
69
+      });
70
+      json.cat2.themes.forEach(function(theme) {
71
+        questions += theme.questions.length;
72
+      });
67
     }
73
     }
68
   });
74
   });
69
 }
75
 }
72
   if(id === 0) category = json.cat1;
78
   if(id === 0) category = json.cat1;
73
   if(id === 1) category = json.cat2;
79
   if(id === 1) category = json.cat2;
74
   console.log(category);
80
   console.log(category);
75
-  $("#game").html("<p id=\"category\">Catégorie : "+category.nom_cat+"</p>");
81
+  $("#game").html("<div id=\"timer\" style=\"width:100%;height:20px;background:green\"></div>");
82
+  $("#game").append("<div id=\"category\">Catégorie : "+category.nom_cat+"</div>");
76
   $("#game").append("<div id=\"theme\"></div>");
83
   $("#game").append("<div id=\"theme\"></div>");
77
-  $("#game").append("<div id=\"timer\" style=\"width:100%;height:20px;background:green\"></div>");
78
-  $("#game").append("<div id=\"score\">Score : "+score+"</div>");
84
+  $(".current").html("<div id=\"score\">Score : "+score+" miam</div>");
79
   loadTheme(id_theme);
85
   loadTheme(id_theme);
80
 }
86
 }
81
 
87
 
83
   theme = category.themes[id];
89
   theme = category.themes[id];
84
   $("#theme").html("<p id=\"question\"></p>");
90
   $("#theme").html("<p id=\"question\"></p>");
85
   $("#theme").append("<ul id=\"answers\"><li id=\"rep1\">"+theme.reponse1+"</li>"
91
   $("#theme").append("<ul id=\"answers\"><li id=\"rep1\">"+theme.reponse1+"</li>"
86
-    +"<li id=\"rep2\">"+theme.reponse2+"</li><li id=\"both\">Les deux</li></ul>");
92
+    +"<li id=\"rep2\">"+theme.reponse2+"</li><li id=\"both\">Les deux</li></ul>"
93
+    +"<p id=\"question-count\">Question 0/0</p>");
87
   quest(id_quest);
94
   quest(id_quest);
88
 }
95
 }
89
 
96
 
91
   $("#question").html(theme.questions[id].intitule);
98
   $("#question").html(theme.questions[id].intitule);
92
   startTimer();
99
   startTimer();
93
   bonneReponse = parseInt(theme.questions[id].bonneReponse);
100
   bonneReponse = parseInt(theme.questions[id].bonneReponse);
94
-  console.info('Question ' + (id_quest + 1) + '/' + theme.questions.length + ' : '
101
+  console.info('Question ' + currentQuestion + '/' + theme.questions.length + ' : '
95
     +theme.questions[id].intitule);
102
     +theme.questions[id].intitule);
103
+  $("#question-count").html("Question "+currentQuestion+"/"+questions);
96
   if(canClick) {
104
   if(canClick) {
97
     $("#rep1").off('click');
105
     $("#rep1").off('click');
98
     $("#rep1").one("click", function() { reponseUser = 1; checkAnswer(); });
106
     $("#rep1").one("click", function() { reponseUser = 1; checkAnswer(); });
112
   if(reponseUser == bonneReponse) {
120
   if(reponseUser == bonneReponse) {
113
     score += secRestantes+1;
121
     score += secRestantes+1;
114
   }
122
   }
115
-  $("#score").html("Score : "+score);
123
+  if(score > 1) {
124
+    $("#score").html("Score : "+score+" miams");
125
+  } else {
126
+    $("#score").html("Score : "+score+" miam");
127
+  }
116
   switch(bonneReponse) {
128
   switch(bonneReponse) {
117
     case 0:   $("#rep1").addClass("wrong-answer");
129
     case 0:   $("#rep1").addClass("wrong-answer");
118
               $("#rep2").addClass("wrong-answer");
130
               $("#rep2").addClass("wrong-answer");
135
   $("#rep2").removeClass();
147
   $("#rep2").removeClass();
136
   $("#both").removeClass();
148
   $("#both").removeClass();
137
   canClick = true;
149
   canClick = true;
150
+  currentQuestion++;
138
   // Dernière question du thème en cours
151
   // Dernière question du thème en cours
139
   if((id_quest+1) == theme.questions.length)  {
152
   if((id_quest+1) == theme.questions.length)  {
140
     // Dernier thème de la catégorie en cours
153
     // Dernier thème de la catégorie en cours
185
 }
198
 }
186
 
199
 
187
 function scoreConfirm() {
200
 function scoreConfirm() {
188
-  console.log("qsfd");
189
-  addScore($("#login").val(), score);
190
-  var message = json.message;
191
   $("#registerScore").fadeOut();
201
   $("#registerScore").fadeOut();
192
-  console.log(message);
193
-  if(message == "score_add_success") {
194
-    window.setTimeout(function() {
195
-      $("#registerScore").addClass("success");
196
-      $("#registerScore").html("Votre score a bien été enregistré<br />"+
197
-      "<a href=\"palmares.htm\">Voir les meilleurs scores</a>");
198
-    }, 400);
199
-  } else {
200
-    if(message === "higher_score_present") {
202
+  if($("#login").val() != "") {
203
+    addScore($("#login").val(), score);
204
+    var message = json.message;
205
+    if(message == "score_add_success") {
201
       window.setTimeout(function() {
206
       window.setTimeout(function() {
202
-        $("#registerScore").addClass("error");
203
-        $("#registerScore").html("Un score supérieur ou égal existe déjà avec ce pseudonyme<br />"
204
-        +"Essayez avec un autre pseudonyme : <input type=\"text\" id=\"login\" placeholder=\"Nom ou pseudonyme\" />"
205
-        +"<input type=\"submit\" id=\"sendScore\" value=\"Valider\" /><br />"
206
-        +"<a href=\"palmares.htm\">Voir les meilleurs scores</a>");
207
-        $("#sendScore").on('click', scoreConfirm);
208
-        $("#login").on('keypress', function(event) {
209
-          if(event.which == 13) {
210
-            scoreConfirm();
211
-          }
212
-        });
213
-      }, 400);
214
-    } else {
215
-      window.setTimeout(function() {
216
-        $("#registerScore").addClass("error");
217
-        $("#registerScore").html("Une erreur est survenue ("+status.message+")<br />"+
207
+        $("#registerScore").removeClass();
208
+        $("#registerScore").addClass("success");
209
+        $("#registerScore").html("Votre score a bien été enregistré.<br />"+
218
         "<a href=\"palmares.htm\">Voir les meilleurs scores</a>");
210
         "<a href=\"palmares.htm\">Voir les meilleurs scores</a>");
219
       }, 400);
211
       }, 400);
212
+    } else {
213
+      if(message === "higher_score_present") {
214
+        window.setTimeout(function() {
215
+          $("#registerScore").removeClass();
216
+          $("#registerScore").addClass("error");
217
+          $("#registerScore").html("Un score supérieur ou égal existe déjà avec ce pseudonyme.<br />"
218
+          +"Essayez avec un autre pseudonyme :<br />"
219
+          +"<input type=\"text\" id=\"login\" placeholder=\"Nom ou pseudonyme\" />"
220
+          +"<input type=\"submit\" id=\"sendScore\" value=\"Valider\" /><br />"
221
+          +"<a href=\"palmares.htm\">Voir les meilleurs scores</a>");
222
+          $("#sendScore").on('click', scoreConfirm);
223
+          $("#login").on('keypress', function(event) {
224
+            if(event.which == 13) {
225
+              scoreConfirm();
226
+            }
227
+          });
228
+        }, 400);
229
+      } else {
230
+        window.setTimeout(function() {
231
+          $("#registerScore").removeClass();
232
+          $("#registerScore").addClass("error");
233
+          $("#registerScore").html("Une erreur est survenue ("+status.message+")<br /> Réessayer :"
234
+          +"<input type=\"text\" id=\"login\" placeholder=\"Nom ou pseudonyme\" />"
235
+          +"<input type=\"submit\" id=\"sendScore\" value=\"Valider\" /><br />"
236
+          +"<a href=\"palmares.htm\">Voir les meilleurs scores</a>");
237
+        }, 400);
238
+      }
220
     }
239
     }
240
+  } else {
241
+    window.setTimeout(function() {
242
+      $("#registerScore").removeClass();
243
+      $("#registerScore").addClass("error");
244
+      $("#registerScore").html("Merci de renseigner un pseudonyme : <br />"
245
+      +"<input type=\"text\" id=\"login\" placeholder=\"Nom ou pseudonyme\" />"
246
+      +"<input type=\"submit\" id=\"sendScore\" value=\"Valider\" /><br />"
247
+      +"<a href=\"palmares.htm\">Voir les meilleurs scores</a>");
248
+      $("#sendScore").on('click', scoreConfirm);
249
+      $("#login").on('keypress', function(event) {
250
+        if(event.which == 13) {
251
+          scoreConfirm();
252
+        }
253
+      });
254
+    }, 400);
221
   }
255
   }
222
   $("#registerScore").fadeIn();
256
   $("#registerScore").fadeIn();
223
 }
257
 }

+ 37
- 27
web/js/multi.js View File

15
 
15
 
16
 function init() {
16
 function init() {
17
 
17
 
18
-    var hostname = $('script')[1]['src'].match(/http:\/\/(.+)\:/)[1];
18
+    var hostname = $('script')[$('script').length-3]['src'].match(/http:\/\/(.+)\:/)[1];
19
 
19
 
20
     // Connexion à socket.io
20
     // Connexion à socket.io
21
     socket = io.connect('http://'+hostname+':8000');
21
     socket = io.connect('http://'+hostname+':8000');
23
     // Gestion des evenements
23
     // Gestion des evenements
24
     setEventHandlers();
24
     setEventHandlers();
25
 
25
 
26
+    window.clearTimeout(refresh);
27
+
26
     // On demande le pseudo a l'utilisateur, on l'envoie au serveur et on l'affiche dans le titre
28
     // On demande le pseudo a l'utilisateur, on l'envoie au serveur et on l'affiche dans le titre
27
-    $("#game").html("<input type=\"text\" id=\"pseudo\" placeholder=\"Nom ou pseudonyme\" /><input type=\"submit\" id=\"start\" value=\"Valider\" />");
29
+    $("#game").html("<h2>Jeu multijoueur</h2>"
30
+    +"<p>Merci de rentrer un nom ou pseudonyme :</p>"
31
+    +"<input type=\"text\" id=\"pseudo\" placeholder=\"Nom ou pseudonyme\" /><input type=\"submit\" id=\"start\" value=\"Valider\" />");
28
     $("#start").on("click", function() {
32
     $("#start").on("click", function() {
29
       pseudo = $("#pseudo").val();
33
       pseudo = $("#pseudo").val();
30
       socket.emit('nouveau', pseudo);
34
       socket.emit('nouveau', pseudo);
89
 var json, category, theme;
93
 var json, category, theme;
90
 // Timer
94
 // Timer
91
 var timing = 5, secRestantes, timer;
95
 var timing = 5, secRestantes, timer;
96
+var nbQuestions = 0, currentQuestion = 1;
92
 var baseWidth;
97
 var baseWidth;
93
 
98
 
94
 var score = 0;
99
 var score = 0;
95
 var canClick = true;
100
 var canClick = true;
96
 
101
 
97
-function apiReq() {
98
-  $.ajax({
99
-    async: false,
100
-    url: "../../api/",
101
-    dataType: 'json',
102
-    success: function(data) {
103
-      json = data;
104
-    }
105
-  });
106
-}
107
-
108
 function loadCat(id) {
102
 function loadCat(id) {
109
   if(id === 0) category = json.cat1;
103
   if(id === 0) category = json.cat1;
110
   if(id === 1) category = json.cat2;
104
   if(id === 1) category = json.cat2;
111
   console.log(category);
105
   console.log(category);
112
-  $("#game").html("<p id=\"category\">Catégorie : "+category.nom_cat+"</p>");
106
+  $("#game").html("<div id=\"timer\" style=\"width:100%;height:20px;background:green\"></div>");
107
+  $("#game").append("<div id=\"category\">Catégorie : "+category.nom_cat+"</div>");
113
   $("#game").append("<div id=\"theme\"></div>");
108
   $("#game").append("<div id=\"theme\"></div>");
114
-  $("#game").append("<div id=\"timer\" style=\"width:100%;height:20px;background:green\"></div>");
115
-  $("#game").append("<div id=\"score\"></div>");
109
+  $(".current").html("<div id=\"score\">Score : "+score+" miam</div>");
116
   loadTheme(id_theme);
110
   loadTheme(id_theme);
117
 }
111
 }
118
 
112
 
120
   theme = category.themes[id];
114
   theme = category.themes[id];
121
   $("#theme").html("<p id=\"question\"></p>");
115
   $("#theme").html("<p id=\"question\"></p>");
122
   $("#theme").append("<ul id=\"answers\"><li id=\"rep1\">"+theme.reponse1+"</li>"
116
   $("#theme").append("<ul id=\"answers\"><li id=\"rep1\">"+theme.reponse1+"</li>"
123
-    +"<li id=\"rep2\">"+theme.reponse2+"</li><li id=\"both\">Les deux</li></ul>");
117
+    +"<li id=\"rep2\">"+theme.reponse2+"</li><li id=\"both\">Les deux</li></ul>"
118
+    +"<p id=\"question-count\">Question 0/0</p>");
124
   quest(id_quest);
119
   quest(id_quest);
125
 }
120
 }
126
 
121
 
128
   $("#question").html(theme.questions[id].intitule);
123
   $("#question").html(theme.questions[id].intitule);
129
   startTimer();
124
   startTimer();
130
   bonneReponse = parseInt(theme.questions[id].bonneReponse);
125
   bonneReponse = parseInt(theme.questions[id].bonneReponse);
131
-  console.info('Question ' + (id_quest + 1) + '/' + theme.questions.length + ' : '
126
+  console.info('Question ' + currentQuestion + '/' + theme.questions.length + ' : '
132
     +theme.questions[id].intitule);
127
     +theme.questions[id].intitule);
128
+  $("#question-count").html("Question "+currentQuestion+"/"+nbQuestions);
133
   if(canClick) {
129
   if(canClick) {
134
     $("#rep1").off('click');
130
     $("#rep1").off('click');
135
     $("#rep1").one("click", function() { reponseUser = 1; checkAnswer(); socket.emit('nextQuestion'); });
131
     $("#rep1").one("click", function() { reponseUser = 1; checkAnswer(); socket.emit('nextQuestion'); });
149
   if(reponseUser == bonneReponse) {
145
   if(reponseUser == bonneReponse) {
150
     score += secRestantes+1;
146
     score += secRestantes+1;
151
   }
147
   }
152
-  $("#score").html("Score : "+score);
148
+  if(score > 1) {
149
+    $("#score").html("Score : "+score+" miams");
150
+  } else {
151
+    $("#score").html("Score : "+score+" miam");
152
+  }
153
   switch(bonneReponse) {
153
   switch(bonneReponse) {
154
     case 0:   $("#rep1").addClass("wrong-answer");
154
     case 0:   $("#rep1").addClass("wrong-answer");
155
               $("#rep2").addClass("wrong-answer");
155
               $("#rep2").addClass("wrong-answer");
172
   $("#rep2").removeClass();
172
   $("#rep2").removeClass();
173
   $("#both").removeClass();
173
   $("#both").removeClass();
174
   canClick = true;
174
   canClick = true;
175
+  currentQuestion++;
175
   // Dernière question du thème en cours
176
   // Dernière question du thème en cours
176
   if((id_quest+1) == theme.questions.length)  {
177
   if((id_quest+1) == theme.questions.length)  {
177
     // Dernier thème de la catégorie en cours
178
     // Dernier thème de la catégorie en cours
198
 
199
 
199
 function play(questions) {
200
 function play(questions) {
200
   json = questions;
201
   json = questions;
202
+
203
+  json.cat1.themes.forEach(function(theme) {
204
+    nbQuestions += theme.questions.length;
205
+  });
206
+  json.cat2.themes.forEach(function(theme) {
207
+    nbQuestions += theme.questions.length;
208
+  });
209
+
201
   loadCat(id_cat);
210
   loadCat(id_cat);
202
 }
211
 }
203
 
212
 
224
 
233
 
225
 function endGame() {
234
 function endGame() {
226
   stopTimer();
235
   stopTimer();
227
-  $("#game").html("<h2 id=\"score\">Vous avez marqué "+score+" miams</h2>"
228
-  +"<p id=\"registerScore\">");
236
+  var str = "<h2 id=\"score\">Vous avez marqué "+score+" miams</h2>"
237
+    +"<p id=\"registerScore\">";
229
   if(disconnect) {
238
   if(disconnect) {
230
-    $("#game").append(gameInfos[0]+" s'est déconnecté.");
239
+    str += gameInfos[0]+" s'est déconnecté.";
240
+    stopTimer();
231
   } else {
241
   } else {
232
-    $("#game").append("Votre adversaire a marqué "+scoreAdversaire+" miams.<br />Le gagnant est... ");
242
+    str += "Votre adversaire a marqué "+scoreAdversaire+" miams.<br />Le gagnant est... ";
233
     if(score > scoreAdversaire) {
243
     if(score > scoreAdversaire) {
234
-      $("#game").append(pseudo+" (vous).");
244
+      str += pseudo+" (vous).";
235
     } else if(score < scoreAdversaire) {
245
     } else if(score < scoreAdversaire) {
236
-      $("#game").append(gameInfos[0]+".");
246
+      str += gameInfos[0]+".";
237
     } else {
247
     } else {
238
-      $("#game").append("personne (égalité).");
248
+      str += "personne (égalité).";
239
     }
249
     }
240
   }
250
   }
241
-  $("#game").append("</p>");
251
+  $("#game").html(str+"</p>");
242
 }
252
 }
243
 
253
 
244
 function addScore(userLogin, userScore) {
254
 function addScore(userLogin, userScore) {

+ 57
- 28
web/multi.php View File

1
-<!DOCTYPE html>
1
+<!doctype html>
2
 <html>
2
 <html>
3
-    <head>
4
-        <meta charset="utf-8" />
5
-        <title>Burger</title>
6
-        <style type="text/css">
7
-          .good-answer {
8
-            color:green;
9
-          }
10
-          .wrong-answer {
11
-            color:red;
12
-          }
13
-        </style>
14
-    </head>
15
-    <body>
16
-        <div id="game">
17
-          Connexion au serveur...
18
-        </div>
19
-        <script src="http://code.jquery.com/jquery-1.10.1.min.js"></script>
20
-        <?php
21
-          $params = file_get_contents("./params.cfg");
22
-    		  preg_match_all('/node_host\: (.+)/', $params, $matches);
23
-          echo '<script src="http://'.$matches[1][0].':8000/socket.io/socket.io.js"></script>';
24
-         ?>
25
-         <script src="js/multi.js"></script>
26
-         <script>
27
-          init();
28
-          </script>
29
-    </body>
3
+  <head>
4
+    <meta charset="utf-8">
5
+    <title>Burger Quizz - Jeu solo</title>
6
+    <link rel="stylesheet" href="css/game.css">
7
+    <link rel="stylesheet" href="css/main.css">
8
+    <link href='http://fonts.googleapis.com/css?family=Open+Sans' rel='stylesheet' type='text/css'>
9
+    <link href='http://fonts.googleapis.com/css?family=Lato:100,400,300,700' rel='stylesheet' type='text/css'>
10
+    <script src="js/jquery-2.1.4.min.js"></script>
11
+    <script src="js/responsive.js"></script>
12
+    <meta name=viewport content="width=device-width, initial-scale=1"/>
13
+    <script>
14
+      var refresh;
15
+    </script>
16
+  </head>
17
+  <body>
18
+    <header>
19
+    </header>
20
+    <section id="navbar">
21
+      <ul>
22
+        <li><a href="index.htm">Accueil</a></li>
23
+        <li><a href="rules.htm">Règles</a></li>
24
+        <li><a href="palmares.htm">Meilleurs scores</a></li>
25
+        <li class="current"><a href="play.htm">Jouer</a></li>
26
+      </ul>
27
+    </section>
28
+    <section id="responsive-navbar">
29
+      <ul>
30
+        <li class="name"><a href="#">Menu</a></li>
31
+        <li><a href="index.htm">Accueil</a></li>
32
+        <li><a href="rules.htm">Règles</a></li>
33
+        <li><a href="palmares.htm">Meilleurs scores</a></li>
34
+        <li class="current"><a href="play.htm">Jouer</a></li>
35
+      </ul>
36
+    </section>
37
+    <section id="game">
38
+      <p id="conDenied" class="error">
39
+        Erreur :<br />
40
+        Connexion au serveur multijoueur impossible
41
+        <script>
42
+          refresh = window.setTimeout(function() {
43
+            window.location = "";
44
+          }, 5000);
45
+        </script>
46
+      </p>
47
+    </section>
48
+    <script src="http://code.jquery.com/jquery-1.10.1.min.js"></script>
49
+      <?php
50
+        $params = file_get_contents("./params.cfg");
51
+    	   preg_match_all('/node_host\: (.+)/', $params, $matches);
52
+         echo '<script src="http://'.$matches[1][0].':8000/socket.io/socket.io.js"></script>';
53
+      ?>
54
+    <script src="js/multi.js"></script>
55
+    <script>
56
+      init();
57
+    </script>
58
+  </body>
30
 </html>
59
 </html>

+ 47
- 0
web/palmares.htm View File

1
+<!doctype html>
2
+<html>
3
+  <head>
4
+    <meta charset="utf-8">
5
+    <title>Burger Quizz - Palmares</title>
6
+    <link rel="stylesheet" href="css/main.css">
7
+    <link href='http://fonts.googleapis.com/css?family=Open+Sans' rel='stylesheet' type='text/css'>
8
+    <script src="js/jquery-2.1.4.min.js"></script>
9
+    <script src="js/responsive.js"></script>
10
+    <meta name=viewport content="width=device-width, initial-scale=1"/>
11
+  </head>
12
+  <body>
13
+    <header>
14
+    </header>
15
+    <section id="navbar">
16
+      <ul>
17
+        <li><a href="index.htm">Accueil</a></li>
18
+        <li><a href="rules.htm">Règles</a></li>
19
+        <li class="current"><a href="palmares.htm">Meilleurs scores</a></li>
20
+        <li><a href="play.htm">Jouer</a></li>
21
+      </ul>
22
+    </section>
23
+    <section id="responsive-navbar">
24
+      <ul>
25
+        <li class="name"><a href="#">Menu</a></li>
26
+        <li><a href="index.htm">Accueil</a></li>
27
+        <li><a href="rules.htm">Règles</a></li>
28
+        <li class="current"><a href="palmares.htm">Meilleurs scores</a></li>
29
+        <li><a href="play.htm">Jouer</a></li>
30
+      </ul>
31
+    </section>
32
+    <section id="page">
33
+      <article>
34
+        <h2>Meilleurs scores</h2>
35
+        <ol></ol>
36
+      </article>
37
+    </section>
38
+
39
+    <script type="text/javascript">
40
+      $.get("./api/?page=palmares", function(data) {
41
+        for(var i = 0; i < 10; i++) {
42
+          $("ol").append("<li>"+data[i].login+" - "+data[i].score+"</li>");
43
+        }
44
+      });
45
+    </script>
46
+  </body>
47
+</html>

+ 46
- 19
web/play.htm View File

1
 <!doctype html>
1
 <!doctype html>
2
 <html>
2
 <html>
3
   <head>
3
   <head>
4
-    <title>Burger Quizz - Jouer</title>
5
-    <meta charset="utf-8" />
4
+    <meta charset="utf-8">
5
+    <title>Burger Quizz - Accueil</title>
6
+    <link rel="stylesheet" href="css/main.css">
7
+    <link href='http://fonts.googleapis.com/css?family=Open+Sans' rel='stylesheet' type='text/css'>
6
     <script src="js/jquery-2.1.4.min.js"></script>
8
     <script src="js/jquery-2.1.4.min.js"></script>
7
-    <script src="js/game.js"></script>
8
-    <style type="text/css">
9
-      .good-answer {
10
-        color:green;
11
-      }
12
-      .wrong-answer {
13
-        color:red;
14
-      }
15
-    </style>
9
+    <script src="js/responsive.js"></script>
10
+    <meta name=viewport content="width=device-width, initial-scale=1"/>
16
   </head>
11
   </head>
17
   <body>
12
   <body>
18
-    <div id="game"></div>
19
-    <input type="submit" id="play" value="Solo (un joueur)" /><br />
20
-    <form action="multi.php"><input type="submit" id="multi" value="Multi (deux joueurs)" /></form>
21
-    <script type="text/javascript">
22
-      $("#play").click(function() {
23
-        play();
24
-      });
25
-    </script>
13
+    <header>
14
+    </header>
15
+    <section id="navbar">
16
+      <ul>
17
+        <li><a href="index.htm">Accueil</a></li>
18
+        <li><a href="rules.htm">Règles</a></li>
19
+        <li><a href="palmares.htm">Meilleurs scores</a></li>
20
+        <li class="current"><a href="play.htm">Jouer</a></li>
21
+      </ul>
22
+    </section>
23
+    <section id="responsive-navbar">
24
+      <ul>
25
+        <li class="name"><a href="#">Menu</a></li>
26
+        <li><a href="index.htm">Accueil</a></li>
27
+        <li><a href="rules.htm">Règles</a></li>
28
+        <li><a href="palmares.htm">Meilleurs scores</a></li>
29
+        <li class="current"><a href="play.htm">Jouer</a></li>
30
+      </ul>
31
+    </section>
32
+    <section id="page">
33
+      <article id="jouer">
34
+        <h1>Jouer</h1>
35
+        <div class="button">
36
+          <a href="solo.htm">
37
+            <div class="firstword">
38
+              Solo
39
+            </div>
40
+            1 joueur
41
+          </a>
42
+        </div>
43
+        <div class="button">
44
+          <a href="multi.php">
45
+            <div class="firstword">
46
+              Multi
47
+            </div>
48
+            2 joueurs
49
+          </a>
50
+        </div>
51
+      </article>
52
+    </section>
26
   </body>
53
   </body>
27
 </html>
54
 </html>

+ 41
- 0
web/rules.htm View File

1
+<!doctype html>
2
+<html>
3
+  <head>
4
+    <meta charset="utf-8">
5
+    <title>Burger Quizz - Règles</title>
6
+    <link rel="stylesheet" href="css/main.css">
7
+    <link href='http://fonts.googleapis.com/css?family=Open+Sans' rel='stylesheet' type='text/css'>
8
+    <script src="js/jquery-2.1.4.min.js"></script>
9
+    <script src="js/responsive.js"></script>
10
+    <meta name=viewport content="width=device-width, initial-scale=1"/>
11
+  </head>
12
+  <body>
13
+    <header>
14
+    </header>
15
+    <section id="navbar">
16
+      <ul>
17
+        <li><a href="index.htm">Accueil</a></li>
18
+        <li class="current"><a href="rules.htm">Règles</a></li>
19
+        <li><a href="palmares.htm">Meilleurs scores</a></li>
20
+        <li><a href="play.htm">Jouer</a></li>
21
+      </ul>
22
+    </section>
23
+    <section id="responsive-navbar">
24
+      <ul>
25
+        <li class="name"><a href="#">Menu</a></li>
26
+        <li><a href="index.htm">Accueil</a></li>
27
+        <li class="current"><a href="rules.htm">Règles</a></li>
28
+        <li><a href="palmares.htm">Meilleurs scores</a></li>
29
+        <li><a href="play.htm">Jouer</a></li>
30
+      </ul>
31
+    </section>
32
+    <section id="page">
33
+      <article>
34
+        <h2>Règles</h2>
35
+        <p>Skevent dleout danvez biz-yod rumm goz gar tabut bazh mil skrijañ, Menez Du dec'h ehan kreisteiz neud tad eil huanadiñ bed lizherenn. Lies gwinegr c'hoar-gaer. Houlenn Menez Mikael anv koumoul, broust brumenn daoust ha. Ret ki lazhañ dianav gwenn hor beg-douar arabat skubañ ken truez tre kar hon leue droug-mor, chom hennezh hag Bro-saoz. Ma fazi geot kein gwechall, rak mil c'hwezhañ e fri hor kae diwar-benn mousc'hoarzhin mat bloaz plijadur hol kant eost noz dre mae nerzh kaeraat, kenwerzh nec'h hir diriaou c'hoar-gaer, a-benn diwar ar maez derc'hel digor pesketaer dir pri start karrezek. Pegement kontañ giz kluchañ n'eus forzh.</p>
36
+        <p>Hep patatez nav kroc'hen. Hon tre karrez talvoudus. Ruz aozañ e-lec'h mel va Doue mat mall kelenner. Mat eil doñjer chaseour rak koumanant a-hed kloued rev pignat yod bras gwrierez tal prizius, e-mesk kemener c'hoarvezout. Gwerenn saout pleg-mor aet poan dor merc'hed giz sukr mat he gervel poultrenn kontadenn, chaseal ti-hent-houarn aer soudard kêr giz gwelloc'h dreist-holl kig tremen gouelañ rev huchal nemet war aes re tro-c'houzoug he goulenn jod beuziñ siminal. Aotrou ar muiañ spi gourc'hemenn, beuziñ fiziañs rev tamm-ha-tamm, mignonez ni distreiñ, kasoni adaozañ degouezhout. Stlakañ loa anzav da gentañ, per kegin kontadenn gwiskamant me ki a-us da noz e-lec'h mat a-hed seizhvet spi kerkoulz ha ker kann distreiñ eus distreiñ te enebour kein gouelañ, a-wechoù c'hoar-gaer eñ huanadiñ aes gwerenn liv gwer. Merc'hed pevar-ugent niz kempenn aon sell kluchañ kemener he prizius moereb abardaez, ober goap eured Krouer respont skouer Sun tre du laezh merc'her kêr goz regiñ kae neuze, da ken na penn-araok kalonek bod dienn Mor Breizh den ar re gouel.</p>
37
+        <p>Leziregezh diskar park dra Krouer, tal pomper miz bale, kibell ler kennebeut mab kaout tog digor tud plijout Baz taol. Kotoñs mab-bihan ober war-dro. Fuzuilh koulz-amzer ki beajour pe ali reiñ kreskiñ eil kardeur ti fresk, logod kav kar leskiñ keniterv. Gwazh hi gar poull patatez. Giz sachañ tachenn-c'hoari, pegen kêr Nedeleg den dale, anv treuziñ ober e venoz kêr echuiñ klevout enebour. Met doñv gavr ruz ober goap. Eus ezhomm sevel eor butuniñ sul hep dre kelc'h talvoudus. Chase mor gwelloc'h e kezeg, pevarzek bleud homañ kempenn azezañ.</p>
38
+      </article>
39
+    </section>
40
+  </body>
41
+</html>

+ 44
- 0
web/solo.htm View File

1
+<!doctype html>
2
+<html>
3
+  <head>
4
+    <meta charset="utf-8">
5
+    <title>Burger Quizz - Jeu solo</title>
6
+    <link rel="stylesheet" href="css/game.css">
7
+    <link rel="stylesheet" href="css/main.css">
8
+    <link href='http://fonts.googleapis.com/css?family=Open+Sans' rel='stylesheet' type='text/css'>
9
+    <link href='http://fonts.googleapis.com/css?family=Lato:100,400,300,700' rel='stylesheet' type='text/css'>
10
+    <script src="js/jquery-2.1.4.min.js"></script>
11
+    <script src="js/responsive.js"></script>
12
+    <script src="js/game.js"></script>
13
+    <meta name=viewport content="width=device-width, initial-scale=1"/>
14
+  </head>
15
+  <body>
16
+    <header>
17
+    </header>
18
+    <section id="navbar">
19
+      <ul>
20
+        <li><a href="index.htm">Accueil</a></li>
21
+        <li><a href="rules.htm">Règles</a></li>
22
+        <li><a href="palmares.htm">Meilleurs scores</a></li>
23
+        <li class="current"><a href="play.htm">Jouer</a></li>
24
+      </ul>
25
+    </section>
26
+    <section id="responsive-navbar">
27
+      <ul>
28
+        <li class="name"><a href="#">Menu</a></li>
29
+        <li><a href="index.htm">Accueil</a></li>
30
+        <li><a href="rules.htm">Règles</a></li>
31
+        <li><a href="palmares.htm">Meilleurs scores</a></li>
32
+        <li class="current"><a href="play.htm">Jouer</a></li>
33
+      </ul>
34
+    </section>
35
+    <section id="game">
36
+      <h2>Jeu solo</h2>
37
+      <input type="submit" id="play" value="Lancer la partie !" />
38
+    </section>
39
+
40
+    <script type="text/javascript">
41
+      $("#play").on("click", play);
42
+    </script>
43
+  </body>
44
+</html>

+ 0
- 10
web/test.php View File

1
-<?php
2
-header("Content-Type:application/json");
3
-
4
-$array = array(
5
-  "numéro" => 2,
6
-  "lettre" => "a",
7
-  "string" => "qqfssdfq"
8
-);
9
-
10
-echo json_encode($array);