Test de passage de l'index en Multi
continuous-integration/drone/push Build is passing Details

ServeurDeTest
Noé GARNIER 2 years ago
parent 9601459e0b
commit 956fbd611d

@ -1,4 +1,5 @@
<?php <?php
use Random\Engine;
class PartieGateway class PartieGateway
{ {
private Connection $con; private Connection $con;
@ -303,18 +304,17 @@ class PartieGateway
return $lesJoueurs; return $lesJoueurs;
} }
public function findAllEnigmeIdInPartie($idPartie){ public function findEnigmeIdInPartieWithIndex($idPartie, $index) : int{
$query = "SELECT * FROM Contenir WHERE partie = :idPartie"; $query = "SELECT * FROM Contenir WHERE partie = :idPartie AND index = :index";
$this->con->executeQuery($query, array( $this->con->executeQuery($query, array(
"idPartie" => array($idPartie, SQLITE3_INTEGER) "idPartie" => array($idPartie, SQLITE3_INTEGER),
"index" => array($index, SQLITE3_INTEGER)
) )
); );
$results = $this->con->getResults(); $results = $this->con->getResults();
$lesEnigmes = array(); $row = $results[0];
foreach ($results as $row){ return $row['enigme'];
$lesEnigmes[] = $row['enigme'];
}
return $lesEnigmes;
} }
public function getIndex(int $idPartie, int $idEnigme){ public function getIndex(int $idPartie, int $idEnigme){
$query = "SELECT * FROM Contenir WHERE partie = :idPartie AND enigme = :idEnigme"; $query = "SELECT * FROM Contenir WHERE partie = :idPartie AND enigme = :idEnigme";

@ -190,14 +190,14 @@ class UserController
$lesJoueurs = $model->getLesJoueurs($idPartie); $lesJoueurs = $model->getLesJoueurs($idPartie);
if($etat == 1){ if($etat == 1){
// header("Location: index.php?action=launchGame"); // header("Location: index.php?action=launchGame");
$this->goToGame($idPartie); $this->goToGame($idPartie,1);
} }
else{ else{
while ($etat == 0){ while ($etat == 0){
sleep(5); sleep(5);
$etat = $model->getEtatPartie($idPartie); $etat = $model->getEtatPartie($idPartie);
} }
$this->goToGame($idPartie); $this->goToGame($idPartie,1);
} }
} catch (Exception $e) { } catch (Exception $e) {
$error = $e->getMessage(); $error = $e->getMessage();
@ -205,12 +205,12 @@ class UserController
} }
} }
public function goToGame($idPartie){ public function goToGame(int $idPartie, int $index){
try { try {
global $rep, $vues, $error; global $rep, $vues, $error;
$model = new UserModel(); $model = new UserModel();
$utilisateur = $_SESSION['utilisateur']; $utilisateur = $_SESSION['utilisateur'];
$enigme = $model->getEnigmebyPartieId($idPartie)[0]; $enigme = $model->getEnigmebyPartieIdAndIndex($idPartie, $index);
$model->resoudreEnigmeMulti($utilisateur, $enigme->getIdEnigme(), $idPartie,); $model->resoudreEnigmeMulti($utilisateur, $enigme->getIdEnigme(), $idPartie,);
$code = $model->getCode($utilisateur->getEmail(), $enigme->getIdEnigme()); $code = $model->getCode($utilisateur->getEmail(), $enigme->getIdEnigme());
require($rep . $vues['partie']); require($rep . $vues['partie']);

@ -127,12 +127,12 @@ class UserModel
return $lesJoueurs; return $lesJoueurs;
} }
public function getEnigmebyPartieId($idPartie){ public function getEnigmebyPartieIdAndIndex($idPartie, $index) : Enigme{
$lesIdEnigmes = $this->partie_gateway->findAllEnigmeIdInPartie($idPartie); $idEnigme = $this->partie_gateway->findEnigmeIdInPartieWithIndex($idPartie, $index);
$lesEnigmes = array(); return $this->enigme_gateway->findById($idEnigme)[0];
foreach ($lesIdEnigmes as $id){
$lesEnigmes[] = $this->enigme_gateway->findById($id)[0];
} }
return $lesEnigmes;
public function getIndex($mailUtilisateur, $idPartie){
return $this->partie_gateway->getIndex($idPartie, $mailUtilisateur);
} }
} }

@ -129,19 +129,19 @@ function run() {
} }
} }
// function saveCode() { function saveCode() {
// var xhr = new XMLHttpRequest(); var xhr = new XMLHttpRequest();
// // xhr.open('POST', 'http://localhost/Scripted/WEB/index.php?action=saveCode', true); // xhr.open('POST', 'http://localhost/Scripted/WEB/index.php?action=saveCode', true);
// xhr.open('POST', 'http://82.165.180.114/Scripted/WEB/index.php?action=saveCode', true); xhr.open('POST', 'http://82.165.180.114/Scripted/WEB/index.php?action=saveCode', true);
// xhr.responseType = 'text'; xhr.responseType = 'text';
// xhr.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded'); xhr.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
// xhr.onload = function () { xhr.onload = function () {
// // console.log('saveCode'+xhr.responseText); // console.log('saveCode'+xhr.responseText);
// }; };
// var searchParams = new URLSearchParams(window.location.search); var searchParams = new URLSearchParams(window.location.search);
// var ordre = searchParams.get('ordre'); var ordre = searchParams.get('ordre');
// xhr.send("code=" + editor.getValue() + "&ordre=" + ordre); xhr.send("code=" + editor.getValue() + "&ordre=" + ordre);
// } }
// document.getElementById ('editor').addEventListener('input', saveCode); document.getElementById ('editor').addEventListener('input', saveCode);

@ -66,7 +66,7 @@
<div class="col-3 rounded p-3" style="background-color: #222831; min-height: 80vh; height: auto"> <div class="col-3 rounded p-3" style="background-color: #222831; min-height: 80vh; height: auto">
<h2 class="text-left py-3" style="color: #44fff6; font-weight: 500"> <h2 class="text-left py-3" style="color: #44fff6; font-weight: 500">
<?php <?php
echo $enigme->getNom(); echo $index;
?> ?>
</h2> </h2>
<p> <p>

Loading…
Cancel
Save