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

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

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

@ -129,19 +129,19 @@ function run() {
}
}
// function saveCode() {
// var xhr = new XMLHttpRequest();
// // 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.responseType = 'text';
// xhr.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
// xhr.onload = function () {
// // console.log('saveCode'+xhr.responseText);
// };
// var searchParams = new URLSearchParams(window.location.search);
// var ordre = searchParams.get('ordre');
// xhr.send("code=" + editor.getValue() + "&ordre=" + ordre);
// }
function saveCode() {
var xhr = new XMLHttpRequest();
// 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.responseType = 'text';
xhr.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
xhr.onload = function () {
// console.log('saveCode'+xhr.responseText);
};
var searchParams = new URLSearchParams(window.location.search);
var ordre = searchParams.get('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">
<h2 class="text-left py-3" style="color: #44fff6; font-weight: 500">
<?php
echo $enigme->getNom();
echo $index;
?>
</h2>
<p>

Loading…
Cancel
Save