... | ... |
@@ -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 |
|