Test
continuous-integration/drone/push Build is passing Details

signalement de fin de parttie a tous les jouur en lobby de fin de partie
ServeurDeTest
Noé GARNIER 2 years ago
parent 1644ef598b
commit da0c360475

@ -266,6 +266,9 @@ class PartieGateway
); );
$results = $this->con->getResults(); $results = $this->con->getResults();
foreach ($results as $row){ foreach ($results as $row){
if($row['etat'] == 2){
return 2;
}
if($row['etat'] == 1){ if($row['etat'] == 1){
return 1; return 1;
} }

@ -46,9 +46,6 @@ class UserController
case "logout": case "logout":
$this->logout(); $this->logout();
break; break;
case "launchGame":
$this->launchGame();
break;
case "saveCode": case "saveCode":
$this->saveCode(); $this->saveCode();
break; break;
@ -58,6 +55,9 @@ class UserController
case "saveCodeInCookie": case "saveCodeInCookie":
$this->saveCodeInCookie(); $this->saveCodeInCookie();
break; break;
case "getGameEtat":
$this->getGameEtat();
break;
default: default:
$error = "Action non valide"; $error = "Action non valide";
require($rep . $vues['erreur']); require($rep . $vues['erreur']);
@ -331,6 +331,20 @@ class UserController
} }
} }
public function getGameEtat(){
try {
global $rep, $vues, $error;
$model = new UserModel();
$idPartie = $_SESSION['idPartie'];
$etat = $model->getEtatPartie($idPartie);
echo $etat;
}
catch (Exception $e) {
$error = $e->getMessage();
require($rep . $vues['erreur']);
}
}
// A appeler après avoir vérifié que la partie est finie // A appeler après avoir vérifié que la partie est finie
public function endGame(){ public function endGame(){
try { try {

@ -23,7 +23,7 @@
<th scope="col">Classement</th> <th scope="col">Classement</th>
<th scope="col">Nom</th> <th scope="col">Nom</th>
<th scope="col">Point</th> <th scope="col">Point</th>
<th scope="col">Temps</th> <th scope="col">Temps (en secondes)</th>
</tr> </tr>
</thead> </thead>
<tbody> <tbody>

@ -52,6 +52,24 @@
} }
} }
var countdownTimer = setInterval('countdown()', 1000); var countdownTimer = setInterval('countdown()', 1000);
function checkIsEnd() {
var xhr = new XMLHttpRequest();
xhr.open('POST', 'http://82.165.180.114/Scripted/WEB/index.php?action=endGame', true);
xhr.responseType = 'text';
xhr.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
xhr.onload = function () {
if (xhr.status === 200) {
if (xhr.responseText == "2") {
window.location.href = 'http://82.165.180.114/Scripted/WEB/index.php?action=getGameEtat'
}
};
xhr.send(null);
}
}
while (1){
checkIsEnd();
}
</script> </script>
<!-- Bootstrap JavaScript Libraries --> <!-- Bootstrap JavaScript Libraries -->
<script src="https://cdn.jsdelivr.net/npm/@popperjs/core@2.11.6/dist/umd/popper.min.js" <script src="https://cdn.jsdelivr.net/npm/@popperjs/core@2.11.6/dist/umd/popper.min.js"

Loading…
Cancel
Save