... | ... |
@@ -163,6 +163,37 @@ $(document).ready(function() { |
163 | 163 |
|
164 | 164 |
} |
165 | 165 |
|
166 |
+ |
|
167 |
+ /* |
|
168 |
+ * |
|
169 |
+ * |
|
170 |
+ * WHAT ???? |
|
171 |
+ * |
|
172 |
+ * |
|
173 |
+ * |
|
174 |
+ */ |
|
175 |
+ |
|
176 |
+ if( !dejaJoue ) { |
|
177 |
+ var pioche = decomposerTuile( data['pioche'] ); |
|
178 |
+ if( $('#zoneInfosTuile_tuile').children().attr('src') != "src/tuile_" + pioche[0] + ".png" ) { |
|
179 |
+ console.log('PB REFRESH TUILE ???'); |
|
180 |
+ $('#zoneInfosTuile_tuile').html('<img src="src/tuile_' + pioche[0] + '.png" />'); |
|
181 |
+ if(pioche[1] != "") |
|
182 |
+ $('#zoneInfosTuile_tuile').append('<img src="src/tuile_' + pioche[1] + '.png" />'); |
|
183 |
+ } |
|
184 |
+ } |
|
185 |
+ |
|
186 |
+ /* |
|
187 |
+ * |
|
188 |
+ * |
|
189 |
+ * WHAT ???? |
|
190 |
+ * |
|
191 |
+ * |
|
192 |
+ * |
|
193 |
+ */ |
|
194 |
+ |
|
195 |
+ |
|
196 |
+ |
|
166 | 197 |
lastData = data; |
167 | 198 |
} |
168 | 199 |
|
... | ... |
@@ -145,12 +145,16 @@ $(document).ready(function() { |
145 | 145 |
|
146 | 146 |
|
147 | 147 |
// AFFICHAGE DU NBR DE TUILES RESTANTES |
148 |
- if( !lastData || lastData['nbpioche'] != data['nbpioche'] ) { |
|
148 |
+ if( !lastData || lastData['nbpioche'] != data['nbpioche'] || lastData['statut'] != data['statut'] ) { |
|
149 | 149 |
var listeTuilesRestantes = ['1', '1d', '1o', '2', '2d', '2o', '3', '4', '4d', '5', '6', '7', '8d', '9', '9d', '10', '10d', '11', '11d']; |
150 | 150 |
for(var t = 0 ; t < listeTuilesRestantes.length ; t++) |
151 | 151 |
$( '#TuileRestante_' + listeTuilesRestantes[t] ).html( ( data['tuilesrestantes'][ listeTuilesRestantes[t] ] ? data['tuilesrestantes'][ listeTuilesRestantes[t] ] : '0' ) + 'x' ); |
152 | 152 |
} |
153 | 153 |
|
154 |
+ // SUPPRESION DES FANTOMES |
|
155 |
+ if( !lastData || lastData['nbpioche'] != data['nbpioche'] ) { |
|
156 |
+ $('.meepleFantome').remove(); |
|
157 |
+ } |
|
154 | 158 |
} |
155 | 159 |
// FIN DE PARTIE : statut > 10 |
156 | 160 |
else if(data['statut'] >= 10) { |
... | ... |
@@ -315,7 +319,7 @@ $(document).ready(function() { |
315 | 319 |
requestWriteInProgress = true; |
316 | 320 |
|
317 | 321 |
$('#zoneInfosTuile_tuile').html('<img src="src/ok.png" />'); |
318 |
- $('#PlateauCase_User' + scJoueurId + '_Case' + InfoID).append('<img src="src/meeple' + tempMeepleSelected + '_vide.png" />'); |
|
322 |
+ $('#PlateauCase_User' + scJoueurId + '_Case' + InfoID).append('<img src="src/meeple' + tempMeepleSelected + '_vide.png" class="meepleFantome" />'); |
|
319 | 323 |
dejaJoue = true; |
320 | 324 |
|
321 | 325 |
$.get('jeu.php?j=' + scJoueurId + '&dc=m' + tempMeepleSelected + 'c' + InfoID) |
... | ... |
@@ -343,7 +347,7 @@ $(document).ready(function() { |
343 | 347 |
requestWriteInProgress = true; |
344 | 348 |
|
345 | 349 |
$('#zoneInfosTuile_tuile').html('<img src="src/ok.png" />'); |
346 |
- $('#PlateauCase_User' + scJoueurId + '_Temple' + InfoID).append('<img src="src/meeple' + tempMeepleSelected + '_vide.png" />'); |
|
350 |
+ $('#PlateauCase_User' + scJoueurId + '_Temple' + InfoID).append('<img src="src/meeple' + tempMeepleSelected + '_vide.png" class="meepleFantome" />'); |
|
347 | 351 |
dejaJoue = true; |
348 | 352 |
|
349 | 353 |
$.get('jeu.php?j=' + scJoueurId + '&dc=m' + tempMeepleSelected + 't' + InfoID) |
... | ... |
@@ -144,6 +144,13 @@ $(document).ready(function() { |
144 | 144 |
$('#zoneInfosTemple' + (t + 1)).html( data['tresor'][t] ); |
145 | 145 |
|
146 | 146 |
|
147 |
+ // AFFICHAGE DU NBR DE TUILES RESTANTES |
|
148 |
+ if( !lastData || lastData['nbpioche'] != data['nbpioche'] ) { |
|
149 |
+ var listeTuilesRestantes = ['1', '1d', '1o', '2', '2d', '2o', '3', '4', '4d', '5', '6', '7', '8d', '9', '9d', '10', '10d', '11', '11d']; |
|
150 |
+ for(var t = 0 ; t < listeTuilesRestantes.length ; t++) |
|
151 |
+ $( '#TuileRestante_' + listeTuilesRestantes[t] ).html( ( data['tuilesrestantes'][ listeTuilesRestantes[t] ] ? data['tuilesrestantes'][ listeTuilesRestantes[t] ] : '0' ) + 'x' ); |
|
152 |
+ } |
|
153 |
+ |
|
147 | 154 |
} |
148 | 155 |
// FIN DE PARTIE : statut > 10 |
149 | 156 |
else if(data['statut'] >= 10) { |
... | ... |
@@ -80,11 +80,12 @@ $(document).ready(function() { |
80 | 80 |
$('#Plateau_User' + j + '_TotalNbr').html( total ); |
81 | 81 |
|
82 | 82 |
if(j != scJoueurId) { |
83 |
- if( !lastData || data['joueur'][j]['dernier_coup'] != lastData['joueur'][j]['dernier_coup'] ) { |
|
84 |
- if(data['joueur'][j]['dernier_coup'].length > 0) |
|
83 |
+ if(data['joueur'][j]['dernier_coup'].length == 0) { |
|
84 |
+ $('#Plateau_User' + j + '_Joue').empty(); |
|
85 |
+ } |
|
86 |
+ else { |
|
87 |
+ if( !lastData || lastData['joueur'][j]['dernier_coup'].length == 0 ) |
|
85 | 88 |
$('#Plateau_User' + j + '_Joue').html('<img src="src/ok.png" />'); |
86 |
- else |
|
87 |
- $('#Plateau_User' + j + '_Joue').empty; |
|
88 | 89 |
} |
89 | 90 |
} |
90 | 91 |
|
... | ... |
@@ -155,6 +156,14 @@ $(document).ready(function() { |
155 | 156 |
} |
156 | 157 |
|
157 | 158 |
function refresh() { |
159 |
+ // S'il y a deja une ecriture en cours, attendre le prochain creneau pour le refresh d'affichage |
|
160 |
+ if(requestWriteInProgress) { |
|
161 |
+ refreshTimer = setTimeout(refresh, 1000); |
|
162 |
+ return; |
|
163 |
+ } |
|
164 |
+ |
|
165 |
+ requestReadInProgress = true; |
|
166 |
+ |
|
158 | 167 |
$.get('jeu.php?j=' + scJoueurId) |
159 | 168 |
.done(function(data, text, jqxhr) { |
160 | 169 |
try { |
... | ... |
@@ -172,14 +181,15 @@ $(document).ready(function() { |
172 | 181 |
}) |
173 | 182 |
.always(function(){ |
174 | 183 |
refreshTimer = setTimeout(refresh, 1000); |
184 |
+ requestReadInProgress = false; |
|
175 | 185 |
}); |
176 | 186 |
} |
177 | 187 |
|
178 | 188 |
refresh(); |
179 | 189 |
var refreshTimer; |
180 | 190 |
|
181 |
- |
|
182 |
- |
|
191 |
+ var requestWriteInProgress = false; |
|
192 |
+ var requestReadInProgress = false; |
|
183 | 193 |
|
184 | 194 |
|
185 | 195 |
|
... | ... |
@@ -209,7 +219,9 @@ $(document).ready(function() { |
209 | 219 |
*/ |
210 | 220 |
if(lastData['statut'] > 0 && lastData['statut'] < 9) { |
211 | 221 |
if(lastData['statut'] % 2 == 0) { |
212 |
- if(InfoType == 't') { |
|
222 |
+ if( InfoType == 't' && !caseHasTemple(InfoID) ) { |
|
223 |
+ requestWriteInProgress = true; |
|
224 |
+ |
|
213 | 225 |
$.get('jeu.php?j=' + scJoueurId + '&temple=' + InfoID) |
214 | 226 |
.done(function(data, text, jqxhr) { |
215 | 227 |
|
... | ... |
@@ -217,14 +229,17 @@ $(document).ready(function() { |
217 | 229 |
.fail(function(jqxhr){ |
218 | 230 |
// alert(jqxhr.responseText); |
219 | 231 |
console.log("BACKEND TEMPLE : " + jqxhr.responseText); |
232 |
+ window.location.href = 'index.php?j=' + scJoueurId; |
|
220 | 233 |
}) |
221 | 234 |
.always(function(){ |
222 |
- |
|
235 |
+ requestWriteInProgress = false; |
|
223 | 236 |
}); |
224 | 237 |
} |
225 | 238 |
} |
226 | 239 |
else { |
227 |
- if(InfoType == 'm') { |
|
240 |
+ if( InfoType == 'm' && !caseHasMeeple('m', InfoID) ) { |
|
241 |
+ requestWriteInProgress = true; |
|
242 |
+ |
|
228 | 243 |
$.get('jeu.php?j=' + scJoueurId + '&meeple=' + InfoID) |
229 | 244 |
.done(function(data, text, jqxhr) { |
230 | 245 |
|
... | ... |
@@ -232,9 +247,10 @@ $(document).ready(function() { |
232 | 247 |
.fail(function(jqxhr){ |
233 | 248 |
console.log("BACKEND MEEPLE : " + jqxhr.responseText); |
234 | 249 |
// alert(jqxhr.responseText); |
250 |
+ window.location.href = 'index.php?j=' + scJoueurId; |
|
235 | 251 |
}) |
236 | 252 |
.always(function(){ |
237 |
- |
|
253 |
+ requestWriteInProgress = false; |
|
238 | 254 |
}); |
239 | 255 |
} |
240 | 256 |
} |
... | ... |
@@ -250,21 +266,27 @@ $(document).ready(function() { |
250 | 266 |
if(InfoType == 'c' && lastData['joueur'][scJoueurId]['plateau'][InfoID - 1].length == 0 && !meepleSelectId) { |
251 | 267 |
if(meepleSelected > 0) $('#SelectionMeeple' + meepleSelected).remove(); |
252 | 268 |
meepleSelected = 0; |
269 |
+ |
|
270 |
+ requestWriteInProgress = true; |
|
271 |
+ |
|
272 |
+ var piocheAff = decomposerTuile( lastData['pioche'] ); |
|
273 |
+ $('#zoneInfosTuile_tuile').html('<img src="src/ok.png" />'); |
|
274 |
+ $('#PlateauCase_User' + scJoueurId + '_Case' + InfoID).append('<img src="src/tuile_' + piocheAff[0] + '.png" style="opacity: 0.5" />'); |
|
275 |
+ if(piocheAff[1] != "") |
|
276 |
+ $('#PlateauCase_User' + scJoueurId + '_Case' + InfoID).append('<img src="src/tuile_' + piocheAff[1] + '.png" style="opacity: 0.5" />'); |
|
277 |
+ dejaJoue = true; |
|
278 |
+ |
|
253 | 279 |
$.get('jeu.php?j=' + scJoueurId + '&dc=c' + InfoID) |
254 | 280 |
.done(function(data, text, jqxhr) { |
255 |
- var piocheAff = decomposerTuile( lastData['pioche'] ); |
|
256 |
- $('#zoneInfosTuile_tuile').html('<img src="src/ok.png" />'); |
|
257 |
- $('#PlateauCase_User' + scJoueurId + '_Case' + InfoID).append('<img src="src/tuile_' + piocheAff[0] + '.png" style="opacity: 0.5" />'); |
|
258 |
- if(piocheAff[1] != "") |
|
259 |
- $('#PlateauCase_User' + scJoueurId + '_Case' + InfoID).append('<img src="src/tuile_' + piocheAff[1] + '.png" style="opacity: 0.5" />'); |
|
260 |
- dejaJoue = true; |
|
281 |
+ |
|
261 | 282 |
}) |
262 | 283 |
.fail(function(jqxhr){ |
263 | 284 |
console.log("BACKEND DC=C : " + jqxhr.responseText); |
264 | 285 |
// alert(jqxhr.responseText); |
286 |
+ window.location.href = 'index.php?j=' + scJoueurId; |
|
265 | 287 |
}) |
266 | 288 |
.always(function(){ |
267 |
- |
|
289 |
+ requestWriteInProgress = false; |
|
268 | 290 |
}); |
269 | 291 |
} |
270 | 292 |
|
... | ... |
@@ -282,18 +304,24 @@ $(document).ready(function() { |
282 | 304 |
if(meepleSelected > 0) $('#SelectionMeeple' + meepleSelected).remove(); |
283 | 305 |
tempMeepleSelected = meepleSelected; |
284 | 306 |
meepleSelected = 0; |
307 |
+ |
|
308 |
+ requestWriteInProgress = true; |
|
309 |
+ |
|
310 |
+ $('#zoneInfosTuile_tuile').html('<img src="src/ok.png" />'); |
|
311 |
+ $('#PlateauCase_User' + scJoueurId + '_Case' + InfoID).append('<img src="src/meeple' + tempMeepleSelected + '_vide.png" />'); |
|
312 |
+ dejaJoue = true; |
|
313 |
+ |
|
285 | 314 |
$.get('jeu.php?j=' + scJoueurId + '&dc=m' + tempMeepleSelected + 'c' + InfoID) |
286 | 315 |
.done(function(data, text, jqxhr) { |
287 |
- $('#zoneInfosTuile_tuile').html('<img src="src/ok.png" />'); |
|
288 |
- $('#PlateauCase_User' + scJoueurId + '_Case' + InfoID).append('<img src="src/meeple' + tempMeepleSelected + '_vide.png" />'); |
|
289 |
- dejaJoue = true; |
|
316 |
+ |
|
290 | 317 |
}) |
291 | 318 |
.fail(function(jqxhr){ |
292 | 319 |
console.log("BACKEND DC=C : " + jqxhr.responseText); |
293 | 320 |
// alert(jqxhr.responseText); |
321 |
+ window.location.href = 'index.php?j=' + scJoueurId; |
|
294 | 322 |
}) |
295 | 323 |
.always(function(){ |
296 |
- |
|
324 |
+ requestWriteInProgress = false; |
|
297 | 325 |
}); |
298 | 326 |
|
299 | 327 |
} |
... | ... |
@@ -304,18 +332,24 @@ $(document).ready(function() { |
304 | 332 |
if(meepleSelected > 0) $('#SelectionMeeple' + meepleSelected).remove(); |
305 | 333 |
tempMeepleSelected = meepleSelected; |
306 | 334 |
meepleSelected = 0; |
335 |
+ |
|
336 |
+ requestWriteInProgress = true; |
|
337 |
+ |
|
338 |
+ $('#zoneInfosTuile_tuile').html('<img src="src/ok.png" />'); |
|
339 |
+ $('#PlateauCase_User' + scJoueurId + '_Temple' + InfoID).append('<img src="src/meeple' + tempMeepleSelected + '_vide.png" />'); |
|
340 |
+ dejaJoue = true; |
|
341 |
+ |
|
307 | 342 |
$.get('jeu.php?j=' + scJoueurId + '&dc=m' + tempMeepleSelected + 't' + InfoID) |
308 | 343 |
.done(function(data, text, jqxhr) { |
309 |
- $('#zoneInfosTuile_tuile').html('<img src="src/ok.png" />'); |
|
310 |
- $('#PlateauCase_User' + scJoueurId + '_Temple' + InfoID).append('<img src="src/meeple' + tempMeepleSelected + '_vide.png" />'); |
|
311 |
- dejaJoue = true; |
|
344 |
+ |
|
312 | 345 |
}) |
313 | 346 |
.fail(function(jqxhr){ |
314 | 347 |
console.log("BACKEND DC=C : " + jqxhr.responseText); |
315 | 348 |
// alert(jqxhr.responseText); |
349 |
+ window.location.href = 'index.php?j=' + scJoueurId; |
|
316 | 350 |
}) |
317 | 351 |
.always(function(){ |
318 |
- |
|
352 |
+ requestWriteInProgress = false; |
|
319 | 353 |
}); |
320 | 354 |
|
321 | 355 |
|
... | ... |
@@ -359,17 +393,23 @@ $(document).ready(function() { |
359 | 393 |
$('#zoneInfosTuile_jeter').hide(); |
360 | 394 |
if(meepleSelected > 0) $('#SelectionMeeple' + meepleSelected).remove(); |
361 | 395 |
meepleSelected = 0; |
396 |
+ |
|
397 |
+ requestWriteInProgress = true; |
|
398 |
+ |
|
399 |
+ $('#zoneInfosTuile_tuile').html('<img src="src/ok.png" />'); |
|
400 |
+ dejaJoue = true; |
|
401 |
+ |
|
362 | 402 |
$.get('jeu.php?j=' + scJoueurId + '&dc=p') |
363 | 403 |
.done(function(data, text, jqxhr) { |
364 |
- $('#zoneInfosTuile_tuile').html('<img src="src/ok.png" />'); |
|
365 |
- dejaJoue = true; |
|
404 |
+ |
|
366 | 405 |
}) |
367 | 406 |
.fail(function(jqxhr){ |
368 | 407 |
console.log("BACKEND DC=P : " + jqxhr.responseText); |
369 | 408 |
// alert(jqxhr.responseText); |
409 |
+ window.location.href = 'index.php?j=' + scJoueurId; |
|
370 | 410 |
}) |
371 | 411 |
.always(function(){ |
372 |
- |
|
412 |
+ requestWriteInProgress = false; |
|
373 | 413 |
}); |
374 | 414 |
} |
375 | 415 |
else { |
... | ... |
@@ -398,6 +438,7 @@ $(document).ready(function() { |
398 | 438 |
.fail(function(jqxhr){ |
399 | 439 |
console.log("BACKEND NEW : " + jqxhr.responseText); |
400 | 440 |
// alert(jqxhr.responseText); |
441 |
+ window.location.href = 'index.php?j=' + scJoueurId; |
|
401 | 442 |
}) |
402 | 443 |
.always(function(){ |
403 | 444 |
|
... | ... |
@@ -143,8 +143,6 @@ $(document).ready(function() { |
143 | 143 |
$('#zoneInfosTemple' + (t + 1)).html( data['tresor'][t] ); |
144 | 144 |
|
145 | 145 |
|
146 |
- |
|
147 |
- |
|
148 | 146 |
} |
149 | 147 |
// FIN DE PARTIE : statut > 10 |
150 | 148 |
else if(data['statut'] >= 10) { |
... | ... |
@@ -153,12 +151,6 @@ $(document).ready(function() { |
153 | 151 |
|
154 | 152 |
} |
155 | 153 |
|
156 |
- |
|
157 |
- |
|
158 |
- |
|
159 |
- |
|
160 |
- |
|
161 |
- |
|
162 | 154 |
lastData = data; |
163 | 155 |
} |
164 | 156 |
|
... | ... |
@@ -163,7 +163,7 @@ $(document).ready(function() { |
163 | 163 |
} |
164 | 164 |
|
165 | 165 |
function refresh() { |
166 |
- $.get('backend/jeu.php?j=' + scJoueurId) |
|
166 |
+ $.get('jeu.php?j=' + scJoueurId) |
|
167 | 167 |
.done(function(data, text, jqxhr) { |
168 | 168 |
try { |
169 | 169 |
var JsonResponse = JSON.parse(jqxhr.responseText); |
... | ... |
@@ -218,7 +218,7 @@ $(document).ready(function() { |
218 | 218 |
if(lastData['statut'] > 0 && lastData['statut'] < 9) { |
219 | 219 |
if(lastData['statut'] % 2 == 0) { |
220 | 220 |
if(InfoType == 't') { |
221 |
- $.get('backend/jeu.php?j=' + scJoueurId + '&temple=' + InfoID) |
|
221 |
+ $.get('jeu.php?j=' + scJoueurId + '&temple=' + InfoID) |
|
222 | 222 |
.done(function(data, text, jqxhr) { |
223 | 223 |
|
224 | 224 |
}) |
... | ... |
@@ -233,7 +233,7 @@ $(document).ready(function() { |
233 | 233 |
} |
234 | 234 |
else { |
235 | 235 |
if(InfoType == 'm') { |
236 |
- $.get('backend/jeu.php?j=' + scJoueurId + '&meeple=' + InfoID) |
|
236 |
+ $.get('jeu.php?j=' + scJoueurId + '&meeple=' + InfoID) |
|
237 | 237 |
.done(function(data, text, jqxhr) { |
238 | 238 |
|
239 | 239 |
}) |
... | ... |
@@ -258,7 +258,7 @@ $(document).ready(function() { |
258 | 258 |
if(InfoType == 'c' && lastData['joueur'][scJoueurId]['plateau'][InfoID - 1].length == 0 && !meepleSelectId) { |
259 | 259 |
if(meepleSelected > 0) $('#SelectionMeeple' + meepleSelected).remove(); |
260 | 260 |
meepleSelected = 0; |
261 |
- $.get('backend/jeu.php?j=' + scJoueurId + '&dc=c' + InfoID) |
|
261 |
+ $.get('jeu.php?j=' + scJoueurId + '&dc=c' + InfoID) |
|
262 | 262 |
.done(function(data, text, jqxhr) { |
263 | 263 |
var piocheAff = decomposerTuile( lastData['pioche'] ); |
264 | 264 |
$('#zoneInfosTuile_tuile').html('<img src="src/ok.png" />'); |
... | ... |
@@ -290,7 +290,7 @@ $(document).ready(function() { |
290 | 290 |
if(meepleSelected > 0) $('#SelectionMeeple' + meepleSelected).remove(); |
291 | 291 |
tempMeepleSelected = meepleSelected; |
292 | 292 |
meepleSelected = 0; |
293 |
- $.get('backend/jeu.php?j=' + scJoueurId + '&dc=m' + tempMeepleSelected + 'c' + InfoID) |
|
293 |
+ $.get('jeu.php?j=' + scJoueurId + '&dc=m' + tempMeepleSelected + 'c' + InfoID) |
|
294 | 294 |
.done(function(data, text, jqxhr) { |
295 | 295 |
$('#zoneInfosTuile_tuile').html('<img src="src/ok.png" />'); |
296 | 296 |
$('#PlateauCase_User' + scJoueurId + '_Case' + InfoID).append('<img src="src/meeple' + tempMeepleSelected + '_vide.png" />'); |
... | ... |
@@ -312,7 +312,7 @@ $(document).ready(function() { |
312 | 312 |
if(meepleSelected > 0) $('#SelectionMeeple' + meepleSelected).remove(); |
313 | 313 |
tempMeepleSelected = meepleSelected; |
314 | 314 |
meepleSelected = 0; |
315 |
- $.get('backend/jeu.php?j=' + scJoueurId + '&dc=m' + tempMeepleSelected + 't' + InfoID) |
|
315 |
+ $.get('jeu.php?j=' + scJoueurId + '&dc=m' + tempMeepleSelected + 't' + InfoID) |
|
316 | 316 |
.done(function(data, text, jqxhr) { |
317 | 317 |
$('#zoneInfosTuile_tuile').html('<img src="src/ok.png" />'); |
318 | 318 |
$('#PlateauCase_User' + scJoueurId + '_Temple' + InfoID).append('<img src="src/meeple' + tempMeepleSelected + '_vide.png" />'); |
... | ... |
@@ -367,7 +367,7 @@ $(document).ready(function() { |
367 | 367 |
$('#zoneInfosTuile_jeter').hide(); |
368 | 368 |
if(meepleSelected > 0) $('#SelectionMeeple' + meepleSelected).remove(); |
369 | 369 |
meepleSelected = 0; |
370 |
- $.get('backend/jeu.php?j=' + scJoueurId + '&dc=p') |
|
370 |
+ $.get('jeu.php?j=' + scJoueurId + '&dc=p') |
|
371 | 371 |
.done(function(data, text, jqxhr) { |
372 | 372 |
$('#zoneInfosTuile_tuile').html('<img src="src/ok.png" />'); |
373 | 373 |
dejaJoue = true; |
... | ... |
@@ -399,7 +399,7 @@ $(document).ready(function() { |
399 | 399 |
* BOUTON FIN DE PARTIE / NOUVELLE PARTIE |
400 | 400 |
*/ |
401 | 401 |
function nouvellePartie() { |
402 |
- $.get('backend/jeu.php?j=' + scJoueurId + '&new=1') |
|
402 |
+ $.get('jeu.php?j=' + scJoueurId + '&new=1') |
|
403 | 403 |
.done(function(data, text, jqxhr) { |
404 | 404 |
|
405 | 405 |
}) |
... | ... |
@@ -34,15 +34,10 @@ $(document).ready(function() { |
34 | 34 |
*/ |
35 | 35 |
for(var t = 0 ; t < data['joueur'][j]['plateau'].length ; t++) { |
36 | 36 |
if( ( !lastData || data['joueur'][j]['plateau'][t] != lastData['joueur'][j]['plateau'][t] ) && data['joueur'][j]['plateau'][t] != "" ) { |
37 |
- var caseInfo = data['joueur'][j]['plateau'][t]; |
|
38 |
- var pepite = caseInfo[caseInfo.length - 1]; |
|
39 |
- if(pepite == 'o' ||pepite == 'd') |
|
40 |
- caseInfo = caseInfo.substring(0, caseInfo.length - 1); |
|
41 |
- else |
|
42 |
- pepite = ''; |
|
43 |
- $('#PlateauCase_User' + j + '_Case' + (t + 1)).html('<img src="src/tuile_' + caseInfo + '.png" />'); |
|
44 |
- if(pepite != "") |
|
45 |
- $('#PlateauCase_User' + j + '_Case' + (t + 1)).append('<img src="src/tuile_' + pepite + '.png" />'); |
|
37 |
+ var caseInfo = decomposerTuile( data['joueur'][j]['plateau'][t] ); |
|
38 |
+ $('#PlateauCase_User' + j + '_Case' + (t + 1)).html('<img src="src/tuile_' + caseInfo[0] + '.png" />'); |
|
39 |
+ if(caseInfo[1] != "") |
|
40 |
+ $('#PlateauCase_User' + j + '_Case' + (t + 1)).append('<img src="src/tuile_' + caseInfo[1] + '.png" />'); |
|
46 | 41 |
} |
47 | 42 |
} |
48 | 43 |
|
... | ... |
@@ -137,15 +132,10 @@ $(document).ready(function() { |
137 | 132 |
|
138 | 133 |
if( ( !lastData || lastData['statut'] < 9 || dejaJoue ) && data['joueur'][scJoueurId]['dernier_coup'].length == 0 ) { |
139 | 134 |
dejaJoue = false; |
140 |
- var pioche = data['pioche']; |
|
141 |
- var pepite = pioche[pioche.length - 1]; |
|
142 |
- if(pepite == 'o' ||pepite == 'd') |
|
143 |
- pioche = pioche.substring(0, pioche.length - 1); |
|
144 |
- else |
|
145 |
- pepite = ''; |
|
146 |
- $('#zoneInfosTuile_tuile').html('<img src="src/tuile_' + pioche + '.png" />'); |
|
147 |
- if(pepite != "") |
|
148 |
- $('#zoneInfosTuile_tuile').append('<img src="src/tuile_' + pepite + '.png" />'); |
|
135 |
+ var pioche = decomposerTuile( data['pioche'] ); |
|
136 |
+ $('#zoneInfosTuile_tuile').html('<img src="src/tuile_' + pioche[0] + '.png" />'); |
|
137 |
+ if(pioche[1] != "") |
|
138 |
+ $('#zoneInfosTuile_tuile').append('<img src="src/tuile_' + pioche[1] + '.png" />'); |
|
149 | 139 |
} |
150 | 140 |
|
151 | 141 |
$('#zoneInfosReste').html( 'Reste : ' + data['nbpioche'] ); |
... | ... |
@@ -270,8 +260,11 @@ $(document).ready(function() { |
270 | 260 |
meepleSelected = 0; |
271 | 261 |
$.get('backend/jeu.php?j=' + scJoueurId + '&dc=c' + InfoID) |
272 | 262 |
.done(function(data, text, jqxhr) { |
263 |
+ var piocheAff = decomposerTuile( lastData['pioche'] ); |
|
273 | 264 |
$('#zoneInfosTuile_tuile').html('<img src="src/ok.png" />'); |
274 |
- $('#PlateauCase_User' + scJoueurId + '_Case' + InfoID).append('<img src="src/tuile_' + lastData['pioche'] + '.png" style="opacity: 0.5" />'); |
|
265 |
+ $('#PlateauCase_User' + scJoueurId + '_Case' + InfoID).append('<img src="src/tuile_' + piocheAff[0] + '.png" style="opacity: 0.5" />'); |
|
266 |
+ if(piocheAff[1] != "") |
|
267 |
+ $('#PlateauCase_User' + scJoueurId + '_Case' + InfoID).append('<img src="src/tuile_' + piocheAff[1] + '.png" style="opacity: 0.5" />'); |
|
275 | 268 |
dejaJoue = true; |
276 | 269 |
}) |
277 | 270 |
.fail(function(jqxhr){ |
... | ... |
@@ -430,5 +423,24 @@ $(document).ready(function() { |
430 | 423 |
|
431 | 424 |
|
432 | 425 |
|
426 |
+ |
|
427 |
+ /* |
|
428 |
+ * FONCTIONS ANNEXES |
|
429 |
+ */ |
|
430 |
+ function decomposerTuile(id) { |
|
431 |
+ var newId = id; |
|
432 |
+ var pepite = newId[newId.length - 1]; |
|
433 |
+ if(pepite == 'o' ||pepite == 'd') |
|
434 |
+ newId = newId.substring(0, newId.length - 1); |
|
435 |
+ else |
|
436 |
+ pepite = ''; |
|
437 |
+ |
|
438 |
+ return [newId, pepite]; |
|
439 |
+ } |
|
440 |
+ |
|
441 |
+ |
|
442 |
+ |
|
443 |
+ |
|
444 |
+ |
|
433 | 445 |
}); |
434 | 446 |
})(jQuery); |
... | ... |
@@ -4,6 +4,7 @@ $(document).ready(function() { |
4 | 4 |
var scJoueurId = scInput_JoueurId; |
5 | 5 |
var lastData; |
6 | 6 |
|
7 |
+ var dejaJoue = false; |
|
7 | 8 |
|
8 | 9 |
function refreshScreen(data) { |
9 | 10 |
if(data['statut'] == 0) { |
... | ... |
@@ -115,31 +116,54 @@ $(document).ready(function() { |
115 | 116 |
} |
116 | 117 |
// PENDANT LA PARTIE |
117 | 118 |
else if(data['statut'] == 9) { |
118 |
- |
|
119 |
- } |
|
120 |
- // FIN DE PARTIE : statut > 10 |
|
121 |
- else { |
|
119 |
+ for(var i = 1 ; i <= 11 ; i++) { |
|
120 |
+ $('#PlateauCase_User' + scJoueurId + '_Temple' + i).removeClass('clickable'); |
|
121 |
+ $('#PlateauCase_User' + scJoueurId + '_Meeple' + i).removeClass('clickable'); |
|
122 |
+ } |
|
123 |
+ for(var i = 1 ; i <= 30 ; i++) |
|
124 |
+ $('#PlateauCase_User' + scJoueurId + '_Case' + i).addClass('clickable'); |
|
125 |
+ for(var i = 1 ; i <= 4 ; i++) { |
|
126 |
+ $('#AffMeeple_User' + scJoueurId + '_Meeple' + i).addClass('clickable'); |
|
127 |
+ $('#AffTemple_User' + scJoueurId + '_Temple' + i).addClass('clickable'); |
|
128 |
+ } |
|
122 | 129 |
|
123 |
- } |
|
124 | 130 |
|
125 | 131 |
|
132 |
+ // AFFICHAGE DES INFOS |
|
133 |
+ if(!dejaJoue && data['joueur'][scJoueurId]['dernier_coup'].length > 0) { |
|
134 |
+ $('#zoneInfosTuile_tuile').html('<img src="src/ok.png" />'); |
|
135 |
+ dejaJoue = true; |
|
136 |
+ } |
|
137 |
+ |
|
138 |
+ if( ( !lastData || lastData['statut'] < 9 || dejaJoue ) && data['joueur'][scJoueurId]['dernier_coup'].length == 0 ) { |
|
139 |
+ dejaJoue = false; |
|
140 |
+ var pioche = data['pioche']; |
|
141 |
+ var pepite = pioche[pioche.length - 1]; |
|
142 |
+ if(pepite == 'o' ||pepite == 'd') |
|
143 |
+ pioche = pioche.substring(0, pioche.length - 1); |
|
144 |
+ else |
|
145 |
+ pepite = ''; |
|
146 |
+ $('#zoneInfosTuile_tuile').html('<img src="src/tuile_' + pioche + '.png" />'); |
|
147 |
+ if(pepite != "") |
|
148 |
+ $('#zoneInfosTuile_tuile').append('<img src="src/tuile_' + pepite + '.png" />'); |
|
149 |
+ } |
|
150 |
+ |
|
151 |
+ $('#zoneInfosReste').html( 'Reste : ' + data['nbpioche'] ); |
|
152 |
+ for(var t = 0 ; t < 4 ; t++) |
|
153 |
+ $('#zoneInfosTemple' + (t + 1)).html( data['tresor'][t] ); |
|
154 |
+ |
|
126 | 155 |
|
127 | 156 |
|
128 |
- if( !lastData || data['pioche'] != lastData['pioche'] ) { |
|
129 |
- var pioche = data['pioche']; |
|
130 |
- var pepite = pioche[pioche.length - 1]; |
|
131 |
- if(pepite == 'o' ||pepite == 'd') |
|
132 |
- pioche = pioche.substring(0, pioche.length - 1); |
|
133 |
- else |
|
134 |
- pepite = ''; |
|
135 |
- $('#zoneInfosTuile_tuile').html('<img src="src/tuile_' + pioche + '.png" />'); |
|
136 |
- if(pepite != "") |
|
137 |
- $('#zoneInfosTuile_tuile').append('<img src="src/tuile_' + pepite + '.png" />'); |
|
157 |
+ |
|
158 |
+ } |
|
159 |
+ // FIN DE PARTIE : statut > 10 |
|
160 |
+ else if(data['statut'] >= 10) { |
|
161 |
+ |
|
162 |
+ $('#finPartie').fadeIn(); |
|
163 |
+ |
|
138 | 164 |
} |
139 | 165 |
|
140 |
- $('#zoneInfosReste').html( 'Reste : ' + data['nbpioche'] ); |
|
141 |
- for(var t = 0 ; t < 4 ; t++) |
|
142 |
- $('#zoneInfosTemple' + (t + 1)).html( data['tresor'][t] ); |
|
166 |
+ |
|
143 | 167 |
|
144 | 168 |
|
145 | 169 |
|
... | ... |
@@ -151,9 +175,17 @@ $(document).ready(function() { |
151 | 175 |
function refresh() { |
152 | 176 |
$.get('backend/jeu.php?j=' + scJoueurId) |
153 | 177 |
.done(function(data, text, jqxhr) { |
154 |
- refreshScreen( JSON.parse(jqxhr.responseText) ); |
|
178 |
+ try { |
|
179 |
+ var JsonResponse = JSON.parse(jqxhr.responseText); |
|
180 |
+ refreshScreen( JsonResponse ); |
|
181 |
+ } |
|
182 |
+ catch(error) { |
|
183 |
+// alert(jqxhr.responseText); |
|
184 |
+ console.log("TRY JSON PARSE : --- " + jqxhr.responseText + " --- " + error); |
|
185 |
+ } |
|
155 | 186 |
}) |
156 | 187 |
.fail(function(jqxhr){ |
188 |
+ console.log("BACKEND REFRESH : " + jqxhr.responseText); |
|
157 | 189 |
// alert(jqxhr.responseText); |
158 | 190 |
}) |
159 | 191 |
.always(function(){ |
... | ... |
@@ -174,7 +206,12 @@ $(document).ready(function() { |
174 | 206 |
* CLICKS |
175 | 207 |
*/ |
176 | 208 |
|
209 |
+ var meepleSelected = 0; |
|
210 |
+ |
|
177 | 211 |
$('.zone-moi-plateau table tr td').on('click', function(e) { |
212 |
+ if(dejaJoue) return; |
|
213 |
+ if(lastData['statut'] > 9) return; |
|
214 |
+ |
|
178 | 215 |
var ReadID = $(this).attr('id'); |
179 | 216 |
if(!ReadID) return; |
180 | 217 |
ReadID = ReadID.substring('PlateauCase_User'.length); |
... | ... |
@@ -197,6 +234,7 @@ $(document).ready(function() { |
197 | 234 |
}) |
198 | 235 |
.fail(function(jqxhr){ |
199 | 236 |
// alert(jqxhr.responseText); |
237 |
+ console.log("BACKEND TEMPLE : " + jqxhr.responseText); |
|
200 | 238 |
}) |
201 | 239 |
.always(function(){ |
202 | 240 |
|
... | ... |
@@ -210,6 +248,7 @@ $(document).ready(function() { |
210 | 248 |
|
211 | 249 |
}) |
212 | 250 |
.fail(function(jqxhr){ |
251 |
+ console.log("BACKEND MEEPLE : " + jqxhr.responseText); |
|
213 | 252 |
// alert(jqxhr.responseText); |
214 | 253 |
}) |
215 | 254 |
.always(function(){ |
... | ... |
@@ -222,10 +261,174 @@ $(document).ready(function() { |
222 | 261 |
* PENDANT LA PARTIE : JOUER UN COUP |
223 | 262 |
*/ |
224 | 263 |
else if(lastData['statut'] == 9) { |
264 |
+ |
|
265 |
+ meepleSelectId = caseHasMeeple(InfoType, InfoID); |
|
266 |
+ |
|
267 |
+ // => CASE VIDE : DEPOSER LA TUILER |
|
268 |
+ if(InfoType == 'c' && lastData['joueur'][scJoueurId]['plateau'][InfoID - 1].length == 0 && !meepleSelectId) { |
|
269 |
+ if(meepleSelected > 0) $('#SelectionMeeple' + meepleSelected).remove(); |
|
270 |
+ meepleSelected = 0; |
|
271 |
+ $.get('backend/jeu.php?j=' + scJoueurId + '&dc=c' + InfoID) |
|
272 |
+ .done(function(data, text, jqxhr) { |
|
273 |
+ $('#zoneInfosTuile_tuile').html('<img src="src/ok.png" />'); |
|
274 |
+ $('#PlateauCase_User' + scJoueurId + '_Case' + InfoID).append('<img src="src/tuile_' + lastData['pioche'] + '.png" style="opacity: 0.5" />'); |
|
275 |
+ dejaJoue = true; |
|
276 |
+ }) |
|
277 |
+ .fail(function(jqxhr){ |
|
278 |
+ console.log("BACKEND DC=C : " + jqxhr.responseText); |
|
279 |
+ // alert(jqxhr.responseText); |
|
280 |
+ }) |
|
281 |
+ .always(function(){ |
|
282 |
+ |
|
283 |
+ }); |
|
284 |
+ } |
|
285 |
+ |
|
286 |
+ // => CASE AVEC MEEPLE : LE SELECTIONNER |
|
287 |
+ else if(meepleSelectId) { |
|
288 |
+ if(meepleSelected > 0) $('#SelectionMeeple' + meepleSelected).remove(); |
|
289 |
+ $('#AffMeeple_User' + scJoueurId + '_Meeple' + meepleSelectId).parent().append('<img src="src/selection.png" id="SelectionMeeple' + meepleSelectId + '" />'); |
|
290 |
+ meepleSelected = meepleSelectId; |
|
291 |
+ } |
|
292 |
+ |
|
293 |
+ // => MEEPLE SELECTED vers CASE VIDE OU TEMPLE : BOUGER LE MEEPLE |
|
294 |
+ else if(meepleSelected) { |
|
295 |
+ if(InfoType == 'c' && lastData['joueur'][scJoueurId]['plateau'][InfoID - 1].length > 0) { |
|
296 |
+ |
|
297 |
+ if(meepleSelected > 0) $('#SelectionMeeple' + meepleSelected).remove(); |
|
298 |
+ tempMeepleSelected = meepleSelected; |
|
299 |
+ meepleSelected = 0; |
|
300 |
+ $.get('backend/jeu.php?j=' + scJoueurId + '&dc=m' + tempMeepleSelected + 'c' + InfoID) |
|
301 |
+ .done(function(data, text, jqxhr) { |
|
302 |
+ $('#zoneInfosTuile_tuile').html('<img src="src/ok.png" />'); |
|
303 |
+ $('#PlateauCase_User' + scJoueurId + '_Case' + InfoID).append('<img src="src/meeple' + tempMeepleSelected + '_vide.png" />'); |
|
304 |
+ dejaJoue = true; |
|
305 |
+ }) |
|
306 |
+ .fail(function(jqxhr){ |
|
307 |
+ console.log("BACKEND DC=C : " + jqxhr.responseText); |
|
308 |
+ // alert(jqxhr.responseText); |
|
309 |
+ }) |
|
310 |
+ .always(function(){ |
|
311 |
+ |
|
312 |
+ }); |
|
313 |
+ |
|
314 |
+ } |
|
315 |
+ else if(InfoType == 't') { |
|
316 |
+ templeSelectId = caseHasTemple(InfoID); |
|
317 |
+ if(templeSelectId == meepleSelected) { |
|
318 |
+ |
|
319 |
+ if(meepleSelected > 0) $('#SelectionMeeple' + meepleSelected).remove(); |
|
320 |
+ tempMeepleSelected = meepleSelected; |
|
321 |
+ meepleSelected = 0; |
|
322 |
+ $.get('backend/jeu.php?j=' + scJoueurId + '&dc=m' + tempMeepleSelected + 't' + InfoID) |
|
323 |
+ .done(function(data, text, jqxhr) { |
|
324 |
+ $('#zoneInfosTuile_tuile').html('<img src="src/ok.png" />'); |
|
325 |
+ $('#PlateauCase_User' + scJoueurId + '_Temple' + InfoID).append('<img src="src/meeple' + tempMeepleSelected + '_vide.png" />'); |
|
326 |
+ dejaJoue = true; |
|
327 |
+ }) |
|
328 |
+ .fail(function(jqxhr){ |
|
329 |
+ console.log("BACKEND DC=C : " + jqxhr.responseText); |
|
330 |
+ // alert(jqxhr.responseText); |
|
331 |
+ }) |
|
332 |
+ .always(function(){ |
|
333 |
+ |
|
334 |
+ }); |
|
335 |
+ |
|
336 |
+ |
|
337 |
+ } |
|
338 |
+ } |
|
339 |
+ } |
|
340 |
+ |
|
341 |
+ } |
|
342 |
+ }); |
|
343 |
+ |
|
344 |
+ function caseHasMeeple(type, id) { |
|
345 |
+ if(type == 't') return false; |
|
346 |
+ |
|
347 |
+ var position = parseInt(id); |
|
348 |
+ if(type == 'm') position += 100; |
|
349 |
+ |
|
350 |
+ for(var i = 0 ; i < lastData['joueur'][scJoueurId]['meeple'].length ; i++) |
|
351 |
+ if( lastData['joueur'][scJoueurId]['meeple'][i] == position ) return (i + 1); |
|
352 |
+ |
|
353 |
+ return false; |
|
354 |
+ } |
|
355 |
+ |
|
356 |
+ function caseHasTemple(id) { |
|
357 |
+ for(var i = 0 ; i < lastData['joueur'][scJoueurId]['temple'].length ; i++) |
|
358 |
+ if( lastData['joueur'][scJoueurId]['temple'][i] == id ) return (i + 1); |
|
359 |
+ |
|
360 |
+ return false; |
|
361 |
+ } |
|
362 |
+ |
|
363 |
+ |
|
364 |
+ |
|
365 |
+ |
|
366 |
+ var actionJeter = false; |
|
367 |
+ |
|
368 |
+ // Click sur la pioche : Action jeter |
|
369 |
+ $('#zoneInfosTuile').on('click', function(e) { |
|
370 |
+ if(dejaJoue) return; |
|
371 |
+ |
|
372 |
+ if(actionJeter) { |
|
373 |
+ actionJeter = false; |
|
374 |
+ $('#zoneInfosTuile_jeter').hide(); |
|
375 |
+ if(meepleSelected > 0) $('#SelectionMeeple' + meepleSelected).remove(); |
|
376 |
+ meepleSelected = 0; |
|
377 |
+ $.get('backend/jeu.php?j=' + scJoueurId + '&dc=p') |
|
378 |
+ .done(function(data, text, jqxhr) { |
|
379 |
+ $('#zoneInfosTuile_tuile').html('<img src="src/ok.png" />'); |
|
380 |
+ dejaJoue = true; |
|
381 |
+ }) |
|
382 |
+ .fail(function(jqxhr){ |
|
383 |
+ console.log("BACKEND DC=P : " + jqxhr.responseText); |
|
384 |
+ // alert(jqxhr.responseText); |
|
385 |
+ }) |
|
386 |
+ .always(function(){ |
|
387 |
+ |
|
388 |
+ }); |
|
225 | 389 |
} |
390 |
+ else { |
|
391 |
+ $('#zoneInfosTuile_jeter').fadeIn(); |
|
392 |
+ actionJeter = true; |
|
393 |
+ } |
|
394 |
+ }); |
|
395 |
+ |
|
396 |
+ $('#zoneInfosTuile').on('mouseleave', function(e) { |
|
397 |
+ $('#zoneInfosTuile_jeter').fadeOut(); |
|
398 |
+ actionJeter = false; |
|
399 |
+ }); |
|
226 | 400 |
|
227 | 401 |
|
402 |
+ |
|
403 |
+ |
|
404 |
+ |
|
405 |
+ /* |
|
406 |
+ * BOUTON FIN DE PARTIE / NOUVELLE PARTIE |
|
407 |
+ */ |
|
408 |
+ function nouvellePartie() { |
|
409 |
+ $.get('backend/jeu.php?j=' + scJoueurId + '&new=1') |
|
410 |
+ .done(function(data, text, jqxhr) { |
|
411 |
+ |
|
412 |
+ }) |
|
413 |
+ .fail(function(jqxhr){ |
|
414 |
+ console.log("BACKEND NEW : " + jqxhr.responseText); |
|
415 |
+// alert(jqxhr.responseText); |
|
416 |
+ }) |
|
417 |
+ .always(function(){ |
|
418 |
+ |
|
419 |
+ }); |
|
420 |
+ |
|
421 |
+ } |
|
422 |
+ |
|
423 |
+ $('#finPartieBtn').on('click', function(e) { |
|
424 |
+ nouvellePartie(); |
|
425 |
+ }); |
|
426 |
+ |
|
427 |
+ $('#basBoutonTerminer').on('click', function(e) { |
|
428 |
+ nouvellePartie(); |
|
228 | 429 |
}); |
229 | 430 |
|
431 |
+ |
|
432 |
+ |
|
230 | 433 |
}); |
231 | 434 |
})(jQuery); |
... | ... |
@@ -2,6 +2,7 @@ |
2 | 2 |
$(document).ready(function() { |
3 | 3 |
|
4 | 4 |
var scJoueurId = scInput_JoueurId; |
5 |
+ var lastData; |
|
5 | 6 |
|
6 | 7 |
|
7 | 8 |
function refreshScreen(data) { |
... | ... |
@@ -10,6 +11,141 @@ $(document).ready(function() { |
10 | 11 |
} |
11 | 12 |
|
12 | 13 |
|
14 |
+ for(var j in data['joueur']) { |
|
15 |
+ |
|
16 |
+ |
|
17 |
+ /* |
|
18 |
+ * AFFICHAGE DES TEMPLES |
|
19 |
+ */ |
|
20 |
+ for(var t = 0 ; t < data['joueur'][j]['temple'].length ; t++) { |
|
21 |
+ if( ( !lastData || data['joueur'][j]['temple'][t] != lastData['joueur'][j]['temple'][t] ) && data['joueur'][j]['temple'][t] > 0 ) { |
|
22 |
+ // Supprime l'ancien Temple |
|
23 |
+ $('#AffTemple_User' + j + '_Temple' + (t + 1)).remove(); |
|
24 |
+ // Affiche le Temple a la nouvelle position |
|
25 |
+ mInfo = data['joueur'][j]['temple'][t]; |
|
26 |
+ $('#PlateauCase_User' + j + '_Temple' + mInfo).append('<img src="src/temple' + (t + 1) + '.png" id="AffTemple_User' + j + '_Temple' + (t + 1) + '" />'); |
|
27 |
+ } |
|
28 |
+ } |
|
29 |
+ |
|
30 |
+ |
|
31 |
+ /* |
|
32 |
+ * AFFICHAGE DES TUILES |
|
33 |
+ */ |
|
34 |
+ for(var t = 0 ; t < data['joueur'][j]['plateau'].length ; t++) { |
|
35 |
+ if( ( !lastData || data['joueur'][j]['plateau'][t] != lastData['joueur'][j]['plateau'][t] ) && data['joueur'][j]['plateau'][t] != "" ) { |
|
36 |
+ var caseInfo = data['joueur'][j]['plateau'][t]; |
|
37 |
+ var pepite = caseInfo[caseInfo.length - 1]; |
|
38 |
+ if(pepite == 'o' ||pepite == 'd') |
|
39 |
+ caseInfo = caseInfo.substring(0, caseInfo.length - 1); |
|
40 |
+ else |
|
41 |
+ pepite = ''; |
|
42 |
+ $('#PlateauCase_User' + j + '_Case' + (t + 1)).html('<img src="src/tuile_' + caseInfo + '.png" />'); |
|
43 |
+ if(pepite != "") |
|
44 |
+ $('#PlateauCase_User' + j + '_Case' + (t + 1)).append('<img src="src/tuile_' + pepite + '.png" />'); |
|
45 |
+ } |
|
46 |
+ } |
|
47 |
+ |
|
48 |
+ |
|
49 |
+ /* |
|
50 |
+ * AFFICHAGE DES MEEPLES |
|
51 |
+ */ |
|
52 |
+ for(var m = 0 ; m < data['joueur'][j]['meeple'].length ; m++) { |
|
53 |
+ if( ( !lastData || data['joueur'][j]['meeple'][m] != lastData['joueur'][j]['meeple'][m] ) && data['joueur'][j]['meeple'][m] > 0 ) { |
|
54 |
+ // Supprime l'ancien Meeple |
|
55 |
+ $('#AffMeeple_User' + j + '_Meeple' + (m + 1)).remove(); |
|
56 |
+ // Affiche le Meeple a la nouvelle position |
|
57 |
+ mInfo = data['joueur'][j]['meeple'][m]; |
|
58 |
+ if(mInfo >= 200) |
|
59 |
+ $('#PlateauCase_User' + j + '_Temple' + (mInfo - 200)).append('<img src="src/meeple' + (m + 1) + '.png" id="AffMeeple_User' + j + '_Meeple' + (m + 1) + '" />'); |
|
60 |
+ else if(mInfo >= 100) |
|
61 |
+ $('#PlateauCase_User' + j + '_Meeple' + (mInfo - 100)).append('<img src="src/meeple' + (m + 1) + '.png" id="AffMeeple_User' + j + '_Meeple' + (m + 1) + '" />'); |
|
62 |
+ else |
|
63 |
+ $('#PlateauCase_User' + j + '_Case' + mInfo).append('<img src="src/meeple' + (m + 1) + '.png" id="AffMeeple_User' + j + '_Meeple' + (m + 1) + '" />'); |
|
64 |
+ } |
|
65 |
+ } |
|
66 |
+ |
|
67 |
+ |
|
68 |
+ /* |
|
69 |
+ * AFFICHAGE DES INFOS |
|
70 |
+ */ |
|
71 |
+ var total = 0; |
|
72 |
+ |
|
73 |
+ for(var i = 0 ; i < data['joueur'][j]['tresor'].length ; i++) { |
|
74 |
+ $('#Plateau_User' + j + '_Temple' + (i + 1) + 'Nbr').html( data['joueur'][j]['tresor'][i] ); |
|
75 |
+ total += parseInt( data['joueur'][j]['tresor'][i] ); |
|
76 |
+ } |
|
77 |
+ |
|
78 |
+ $('#Plateau_User' + j + '_OrNbr').html( data['joueur'][j]['or'] ); |
|
79 |
+ total += parseInt( data['joueur'][j]['or'] * 2 ); |
|
80 |
+ |
|
81 |
+ $('#Plateau_User' + j + '_DiamantNbr').html( data['joueur'][j]['diamant'] ); |
|
82 |
+ total += parseInt( data['joueur'][j]['diamant'] ); |
|
83 |
+ |
|
84 |
+ $('#Plateau_User' + j + '_TotalNbr').html( total ); |
|
85 |
+ |
|
86 |
+ if(j != scJoueurId) { |
|
87 |
+ if( !lastData || data['joueur'][j]['dernier_coup'] != lastData['joueur'][j]['dernier_coup'] ) { |
|
88 |
+ if(data['joueur'][j]['dernier_coup'].length > 0) |
|
89 |
+ $('#Plateau_User' + j + '_Joue').html('<img src="src/ok.png" />'); |
|
90 |
+ else |
|
91 |
+ $('#Plateau_User' + j + '_Joue').empty; |
|
92 |
+ } |
|
93 |
+ } |
|
94 |
+ |
|
95 |
+ |
|
96 |
+ } // FIN BOUCLE : REFRESH DES ECRANS DE CHAQUE JOUEUR |
|
97 |
+ |
|
98 |
+ |
|
99 |
+ // ETAPES INITIALES DE POSITIONNEMENT DES MEEPLES & TEMPLES |
|
100 |
+ if(data['statut'] > 0 && data['statut'] < 9 && (!lastData || data['statut'] != lastData['statut']) ) { |
|
101 |
+ if(data['statut'] % 2 == 0) { |
|
102 |
+ $('#zoneInfosTuile_tuile').html('<img src="src/temple' + (data['statut'] / 2) + '.png" />'); |
|
103 |
+ for(var i = 1 ; i <= 11 ; i++) { |
|
104 |
+ $('#PlateauCase_User' + scJoueurId + '_Temple' + i).addClass('clickable'); |
|
105 |
+ $('#PlateauCase_User' + scJoueurId + '_Meeple' + i).removeClass('clickable'); |
|
106 |
+ } |
|
107 |
+ } |
|
108 |
+ else { |
|
109 |
+ $('#zoneInfosTuile_tuile').html('<img src="src/meeple' + (Math.floor(data['statut'] / 2) + 1) + '.png" />'); |
|
110 |
+ for(var i = 1 ; i <= 11 ; i++) { |
|
111 |
+ $('#PlateauCase_User' + scJoueurId + '_Meeple' + i).addClass('clickable'); |
|
112 |
+ $('#PlateauCase_User' + scJoueurId + '_Temple' + i).removeClass('clickable'); |
|
113 |
+ } |
|
114 |
+ } |
|
115 |
+ } |
|
116 |
+ // PENDANT LA PARTIE |
|
117 |
+ else if(data['statut'] == 9) { |
|
118 |
+ |
|
119 |
+ } |
|
120 |
+ // FIN DE PARTIE : statut > 10 |
|
121 |
+ else { |
|
122 |
+ |
|
123 |
+ } |
|
124 |
+ |
|
125 |
+ |
|
126 |
+ |
|
127 |
+ |
|
128 |
+ if( !lastData || data['pioche'] != lastData['pioche'] ) { |
|
129 |
+ var pioche = data['pioche']; |
|
130 |
+ var pepite = pioche[pioche.length - 1]; |
|
131 |
+ if(pepite == 'o' ||pepite == 'd') |
|
132 |
+ pioche = pioche.substring(0, pioche.length - 1); |
|
133 |
+ else |
|
134 |
+ pepite = ''; |
|
135 |
+ $('#zoneInfosTuile_tuile').html('<img src="src/tuile_' + pioche + '.png" />'); |
|
136 |
+ if(pepite != "") |
|
137 |
+ $('#zoneInfosTuile_tuile').append('<img src="src/tuile_' + pepite + '.png" />'); |
|
138 |
+ } |
|
139 |
+ |
|
140 |
+ $('#zoneInfosReste').html( 'Reste : ' + data['nbpioche'] ); |
|
141 |
+ for(var t = 0 ; t < 4 ; t++) |
|
142 |
+ $('#zoneInfosTemple' + (t + 1)).html( data['tresor'][t] ); |
|
143 |
+ |
|
144 |
+ |
|
145 |
+ |
|
146 |
+ |
|
147 |
+ |
|
148 |
+ lastData = data; |
|
13 | 149 |
} |
14 | 150 |
|
15 | 151 |
function refresh() { |
... | ... |
@@ -33,5 +169,63 @@ $(document).ready(function() { |
33 | 169 |
|
34 | 170 |
|
35 | 171 |
|
172 |
+ |
|
173 |
+ /* |
|
174 |
+ * CLICKS |
|
175 |
+ */ |
|
176 |
+ |
|
177 |
+ $('.zone-moi-plateau table tr td').on('click', function(e) { |
|
178 |
+ var ReadID = $(this).attr('id'); |
|
179 |
+ if(!ReadID) return; |
|
180 |
+ ReadID = ReadID.substring('PlateauCase_User'.length); |
|
181 |
+ var UserID = ReadID.substring(0, ReadID.indexOf('_')); |
|
182 |
+ var InfoType = ReadID.substring(ReadID.indexOf('_') + 1); |
|
183 |
+ var InfoID = 0; |
|
184 |
+ if(InfoType.substring(0, 'Case'.length) == 'Case') { InfoID = InfoType.substring('Case'.length); InfoType = 'c'; } |
|
185 |
+ else if(InfoType.substring(0, 'Temple'.length) == 'Temple') { InfoID = InfoType.substring('Temple'.length); InfoType = 't'; } |
|
186 |
+ else if(InfoType.substring(0, 'Meeple'.length) == 'Meeple') { InfoID = InfoType.substring('Meeple'.length); InfoType = 'm'; } |
|
187 |
+ |
|
188 |
+ /* |
|
189 |
+ * DEBUT DE PARTIE : CHOIX DES POSITIONS DES TEMPLES ET MEEPLES |
|
190 |
+ */ |
|
191 |
+ if(lastData['statut'] > 0 && lastData['statut'] < 9) { |
|
192 |
+ if(lastData['statut'] % 2 == 0) { |
|
193 |
+ if(InfoType == 't') { |
|
194 |
+ $.get('backend/jeu.php?j=' + scJoueurId + '&temple=' + InfoID) |
|
195 |
+ .done(function(data, text, jqxhr) { |
|
196 |
+ |
|
197 |
+ }) |
|
198 |
+ .fail(function(jqxhr){ |
|
199 |
+ // alert(jqxhr.responseText); |
|
200 |
+ }) |
|
201 |
+ .always(function(){ |
|
202 |
+ |
|
203 |
+ }); |
|
204 |
+ } |
|
205 |
+ } |
|
206 |
+ else { |
|
207 |
+ if(InfoType == 'm') { |
|
208 |
+ $.get('backend/jeu.php?j=' + scJoueurId + '&meeple=' + InfoID) |
|
209 |
+ .done(function(data, text, jqxhr) { |
|
210 |
+ |
|
211 |
+ }) |
|
212 |
+ .fail(function(jqxhr){ |
|
213 |
+ // alert(jqxhr.responseText); |
|
214 |
+ }) |
|
215 |
+ .always(function(){ |
|
216 |
+ |
|
217 |
+ }); |
|
218 |
+ } |
|
219 |
+ } |
|
220 |
+ } |
|
221 |
+ /* |
|
222 |
+ * PENDANT LA PARTIE : JOUER UN COUP |
|
223 |
+ */ |
|
224 |
+ else if(lastData['statut'] == 9) { |
|
225 |
+ } |
|
226 |
+ |
|
227 |
+ |
|
228 |
+ }); |
|
229 |
+ |
|
36 | 230 |
}); |
37 | 231 |
})(jQuery); |
... | ... |
@@ -1,6 +1,37 @@ |
1 | 1 |
(function($) { |
2 |
+$(document).ready(function() { |
|
2 | 3 |
|
4 |
+ var scJoueurId = scInput_JoueurId; |
|
3 | 5 |
|
4 | 6 |
|
7 |
+ function refreshScreen(data) { |
|
8 |
+ if(data['statut'] == 0) { |
|
9 |
+ window.location.href = 'index.php?j=' + scJoueurId; |
|
10 |
+ } |
|
5 | 11 |
|
12 |
+ |
|
13 |
+ } |
|
14 |
+ |
|
15 |
+ function refresh() { |
|
16 |
+ $.get('backend/jeu.php?j=' + scJoueurId) |
|
17 |
+ .done(function(data, text, jqxhr) { |
|
18 |
+ refreshScreen( JSON.parse(jqxhr.responseText) ); |
|
19 |
+ }) |
|
20 |
+ .fail(function(jqxhr){ |
|
21 |
+// alert(jqxhr.responseText); |
|
22 |
+ }) |
|
23 |
+ .always(function(){ |
|
24 |
+ refreshTimer = setTimeout(refresh, 1000); |
|
25 |
+ }); |
|
26 |
+ } |
|
27 |
+ |
|
28 |
+ refresh(); |
|
29 |
+ var refreshTimer; |
|
30 |
+ |
|
31 |
+ |
|
32 |
+ |
|
33 |
+ |
|
34 |
+ |
|
35 |
+ |
|
36 |
+}); |
|
6 | 37 |
})(jQuery); |