|
|
@ -83,7 +83,7 @@ class UtilisateurGateway
|
|
|
|
return $estAdmin;
|
|
|
|
return $estAdmin;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public function resoudreEnigmeMulti(string $emailUtilisateur)
|
|
|
|
/*public function resoudreEnigmeMulti(string $emailUtilisateur)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
$query="SELECT c.partie FROM Contenir
|
|
|
|
$query="SELECT c.partie FROM Contenir
|
|
|
|
WHERE c.joueur = :emailUtilisateur
|
|
|
|
WHERE c.joueur = :emailUtilisateur
|
|
|
@ -91,9 +91,9 @@ class UtilisateurGateway
|
|
|
|
$this->con->executeQuery($query, array(
|
|
|
|
$this->con->executeQuery($query, array(
|
|
|
|
':emailUtilisateur' => array($emailUtilisateur,SQLITE3_TEXT)
|
|
|
|
':emailUtilisateur' => array($emailUtilisateur,SQLITE3_TEXT)
|
|
|
|
));
|
|
|
|
));
|
|
|
|
$idPartie=$this->con->getResults()[0];
|
|
|
|
$idPartie=$this->con->getResults()[0]["partie"];
|
|
|
|
|
|
|
|
|
|
|
|
$query="SELECT e.id FROM Resoudre r, Contenir c1,Contenir c2, Enigme e WHERE
|
|
|
|
$query="SELECT e.id, c2.indexEnigme FROM Resoudre r, Contenir c1,Contenir c2, Enigme e WHERE
|
|
|
|
r.id = :idPartie
|
|
|
|
r.id = :idPartie
|
|
|
|
AND r.joueur=:idJoueur
|
|
|
|
AND r.joueur=:idJoueur
|
|
|
|
AND r.partie=:idPartie
|
|
|
|
AND r.partie=:idPartie
|
|
|
@ -104,35 +104,175 @@ class UtilisateurGateway
|
|
|
|
AND r.temps = (SELECT max(r.temps))";
|
|
|
|
AND r.temps = (SELECT max(r.temps))";
|
|
|
|
$results=$this->con->getResults();
|
|
|
|
$results=$this->con->getResults();
|
|
|
|
if(empty($results))
|
|
|
|
if(empty($results))
|
|
|
|
$query="SELECT enigme FROM Contenir WHERE
|
|
|
|
{
|
|
|
|
|
|
|
|
$query="SELECT c.enigme, c.indexEnigme FROM Contenir c WHERE
|
|
|
|
c.partie = :idPartie
|
|
|
|
c.partie = :idPartie
|
|
|
|
AND c.indexEnigme = 0";
|
|
|
|
AND c.indexEnigme = 0";
|
|
|
|
$results=$this->con->getResults();
|
|
|
|
$results=$this->con->getResults();
|
|
|
|
$idEnigme=$results[0];
|
|
|
|
}
|
|
|
|
|
|
|
|
$idEnigme=$results[0]["enigme"];
|
|
|
|
|
|
|
|
$index=$results[0]["indexEnigme"];
|
|
|
|
|
|
|
|
|
|
|
|
$query="SELECT max(classement) FROM Enigme e,Partie p, Resoudre r
|
|
|
|
$query="SELECT max(classement) FROM Enigme e,Partie p, Resoudre r
|
|
|
|
WHERE p.id=r.partie;
|
|
|
|
WHERE p.id=r.partie
|
|
|
|
AND e.id=r.enigme";
|
|
|
|
AND e.id=r.enigme";
|
|
|
|
$this->con->executeQuery($query);
|
|
|
|
$this->con->executeQuery($query);
|
|
|
|
$results=$this->con->getResults();
|
|
|
|
$results=$this->con->getResults();
|
|
|
|
if(empty($results))
|
|
|
|
if(empty($results))
|
|
|
|
$classement=1;
|
|
|
|
$classement=1;
|
|
|
|
else
|
|
|
|
else
|
|
|
|
$classement=$results[0]+1;
|
|
|
|
$classement=$results[0]["max"]+1;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$query="SELECT * FROM Resoudre
|
|
|
|
|
|
|
|
WHERE r.joueur=:joueur
|
|
|
|
|
|
|
|
AND r.enigme=:idEnigme
|
|
|
|
|
|
|
|
AND r.partie=:idPartie";
|
|
|
|
|
|
|
|
$this->con->executeQuery($query, array(
|
|
|
|
|
|
|
|
"joueur" => array($emailUtilisateur, SQLITE3_TEXT),
|
|
|
|
|
|
|
|
"enigme" => array($idEnigme, SQLITE3_INTEGER),
|
|
|
|
|
|
|
|
"partie" => array($idPartie, SQLITE3_INTEGER)));
|
|
|
|
|
|
|
|
$results=$this->con->getResults();
|
|
|
|
|
|
|
|
if(empty($results))
|
|
|
|
|
|
|
|
{
|
|
|
|
$query="INSERT INTO Resoudre VALUES (:joueur, :enigme,:partie,:classement,:index,:temps,TRUE)";
|
|
|
|
$query="INSERT INTO Resoudre VALUES (:joueur, :enigme,:partie,:classement,:index,:temps,TRUE)";
|
|
|
|
$this->con->executeQuery($query, array(
|
|
|
|
$this->con->executeQuery($query, array(
|
|
|
|
"joueur" => array($emailUtilisateur, SQLITE3_TEXT),
|
|
|
|
"joueur" => array($emailUtilisateur, SQLITE3_TEXT),
|
|
|
|
"enigme" => array($idEnigme, SQLITE3_TEXT),
|
|
|
|
"enigme" => array($idEnigme, SQLITE3_INTEGER),
|
|
|
|
"partie" => array($idPartie, SQLITE3_TEXT),
|
|
|
|
"partie" => array($idPartie, SQLITE3_INTEGER),
|
|
|
|
"classement" => array($classement, SQLITE3_INTEGER),
|
|
|
|
"classement" => array($classement, SQLITE3_INTEGER),
|
|
|
|
"index" => array(, SQLITE3_INTEGER),
|
|
|
|
"index" => array($index, SQLITE3_INTEGER),
|
|
|
|
|
|
|
|
"temps" => array($temps, SQLITE3_FLOAT)));
|
|
|
|
|
|
|
|
return array($emailUtilisateur => array($points,$temps))
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
else
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
$query="UPDATE Resoudre
|
|
|
|
|
|
|
|
SET classement=:classement;
|
|
|
|
|
|
|
|
WHERE joueur=:joueur
|
|
|
|
|
|
|
|
AND enigme=:idEnigme
|
|
|
|
|
|
|
|
AND partie=:idPartie";
|
|
|
|
|
|
|
|
$this->con->executeQuery($query, array(
|
|
|
|
|
|
|
|
"joueur" => array($emailUtilisateur, SQLITE3_TEXT),
|
|
|
|
|
|
|
|
"enigme" => array($idEnigme, SQLITE3_INTEGER),
|
|
|
|
|
|
|
|
"partie" => array($idPartie, SQLITE3_INTEGER),
|
|
|
|
|
|
|
|
"classement" => array($classement, SQLITE3_INTEGER)));
|
|
|
|
|
|
|
|
return array();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}*/
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public function passerEnigmeMulti(string $emailUtilisateur){
|
|
|
|
|
|
|
|
$query="SELECT p.partie FROM Participer
|
|
|
|
|
|
|
|
WHERE p.joueur = :emailUtilisateur
|
|
|
|
|
|
|
|
and p.enCours = TRUE";
|
|
|
|
|
|
|
|
$this->con->executeQuery($query, array(
|
|
|
|
|
|
|
|
':emailUtilisateur' => array($emailUtilisateur,SQLITE3_TEXT)
|
|
|
|
|
|
|
|
));
|
|
|
|
|
|
|
|
$idPartie=$this->con->getResults()[0]["partie"];
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$query="SELECT e.id, c2.indexEnigme FROM Resoudre r, Contenir c1,Contenir c2, Enigme e WHERE
|
|
|
|
|
|
|
|
r.id = :idPartie
|
|
|
|
|
|
|
|
AND r.joueur=:idJoueur
|
|
|
|
|
|
|
|
AND r.partie=:idPartie
|
|
|
|
|
|
|
|
AND r.temps IS NOT NULL
|
|
|
|
|
|
|
|
AND r.enigme=c1.enigme
|
|
|
|
|
|
|
|
AND r.partie = c1.partie
|
|
|
|
|
|
|
|
AND r.partie = c2.partie
|
|
|
|
|
|
|
|
AND c2.index=c1.index + 1
|
|
|
|
|
|
|
|
AND e.id = c1.enigme
|
|
|
|
|
|
|
|
AND r.temps = (SELECT max(r.temps))";
|
|
|
|
|
|
|
|
$results=$this->con->getResults();
|
|
|
|
|
|
|
|
if(empty($results))
|
|
|
|
|
|
|
|
$query="SELECT c.enigme, c.indexEnigme FROM Contenir c WHERE
|
|
|
|
|
|
|
|
c.partie = :idPartie
|
|
|
|
|
|
|
|
AND c.indexEnigme = 0";
|
|
|
|
|
|
|
|
$results=$this->con->getResults();
|
|
|
|
|
|
|
|
$idEnigme=$results[0]["enigme"];
|
|
|
|
|
|
|
|
$index=$results[0]["indexEnigme"];
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$query="INSERT INTO Resoudre VALUES (:joueur, :enigme,:partie,:classement,:index,:temps,TRUE)";
|
|
|
|
|
|
|
|
$this->con->executeQuery($query, array(
|
|
|
|
|
|
|
|
"joueur" => array($emailUtilisateur, SQLITE3_TEXT),
|
|
|
|
|
|
|
|
"enigme" => array($idEnigme, SQLITE3_INTEGER),
|
|
|
|
|
|
|
|
"partie" => array($idPartie, SQLITE3_INTEGER),
|
|
|
|
|
|
|
|
"classement" => array(NULL, SQLITE3_NULL),
|
|
|
|
|
|
|
|
"index" => array($index, SQLITE3_INTEGER),
|
|
|
|
"temps" => array($emailUtilisateur, SQLITE3_FLOAT)));
|
|
|
|
"temps" => array($emailUtilisateur, SQLITE3_FLOAT)));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public function resoudreEnigmeSolo(string $emailUtilisateur, int $idEnigme, int $idPartie)
|
|
|
|
public function resoudreEnigmeSolo(string $emailUtilisateur)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
$query="SELECT c.partie FROM Contenir
|
|
|
|
|
|
|
|
WHERE c.joueur = :emailUtilisateur
|
|
|
|
|
|
|
|
and c.enCours = TRUE";
|
|
|
|
|
|
|
|
$this->con->executeQuery($query, array(
|
|
|
|
|
|
|
|
':emailUtilisateur' => array($emailUtilisateur,SQLITE3_TEXT)
|
|
|
|
|
|
|
|
));
|
|
|
|
|
|
|
|
$idPartie=$this->con->getResults()[0]["partie"];
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$query="SELECT e.id, c2.indexEnigme FROM Resoudre r, Contenir c1,Contenir c2, Enigme e WHERE
|
|
|
|
|
|
|
|
r.id = :idPartie
|
|
|
|
|
|
|
|
AND r.joueur=:idJoueur
|
|
|
|
|
|
|
|
AND r.partie=:idPartie
|
|
|
|
|
|
|
|
AND r.enigme = c1.enigme
|
|
|
|
|
|
|
|
AND c1.partie = r.partie
|
|
|
|
|
|
|
|
AND c2.partie = r.partie
|
|
|
|
|
|
|
|
AND c2.index=c1.index + 1
|
|
|
|
|
|
|
|
AND e.id = c2.enigme
|
|
|
|
|
|
|
|
AND r.indexEnigme = (SELECT max(r.indexEnigme))";
|
|
|
|
|
|
|
|
$results=$this->con->getResults();
|
|
|
|
|
|
|
|
if(empty($results))
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
$query="SELECT c.enigme, c.indexEnigme FROM Contenir c WHERE
|
|
|
|
|
|
|
|
c.partie = :idPartie
|
|
|
|
|
|
|
|
AND c.indexEnigme = 0";
|
|
|
|
|
|
|
|
$results=$this->con->getResults();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
$idEnigme=$results[0]["enigme"];
|
|
|
|
|
|
|
|
$index=$results[0]["indexEnigme"];
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$query="SELECT max(classement) FROM Enigme e,Partie p, Resoudre r
|
|
|
|
|
|
|
|
WHERE p.id=r.partie
|
|
|
|
|
|
|
|
AND e.id=r.enigme";
|
|
|
|
|
|
|
|
$this->con->executeQuery($query);
|
|
|
|
|
|
|
|
$results=$this->con->getResults();
|
|
|
|
|
|
|
|
if(empty($results))
|
|
|
|
|
|
|
|
$classement=1;
|
|
|
|
|
|
|
|
else
|
|
|
|
|
|
|
|
$classement=$results[0]["max"]+1;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$query="SELECT * FROM Resoudre
|
|
|
|
|
|
|
|
WHERE r.joueur=:joueur
|
|
|
|
|
|
|
|
AND r.enigme=:idEnigme
|
|
|
|
|
|
|
|
AND r.partie=:idPartie";
|
|
|
|
|
|
|
|
$this->con->executeQuery($query, array(
|
|
|
|
|
|
|
|
"joueur" => array($emailUtilisateur, SQLITE3_TEXT),
|
|
|
|
|
|
|
|
"enigme" => array($idEnigme, SQLITE3_INTEGER),
|
|
|
|
|
|
|
|
"partie" => array($idPartie, SQLITE3_INTEGER)));
|
|
|
|
|
|
|
|
$results=$this->con->getResults();
|
|
|
|
|
|
|
|
if(empty($results))
|
|
|
|
{
|
|
|
|
{
|
|
|
|
$query="INSERT INTO Resoudre VALUES (:joueur, :enigme,:partie,NULL,:index,:temps,False)";
|
|
|
|
$query="INSERT INTO Resoudre VALUES (:joueur, :enigme,:partie,:classement,:index,:temps,TRUE)";
|
|
|
|
|
|
|
|
$this->con->executeQuery($query, array(
|
|
|
|
|
|
|
|
"joueur" => array($emailUtilisateur, SQLITE3_TEXT),
|
|
|
|
|
|
|
|
"enigme" => array($idEnigme, SQLITE3_INTEGER),
|
|
|
|
|
|
|
|
"partie" => array($idPartie, SQLITE3_INTEGER),
|
|
|
|
|
|
|
|
"classement" => array($classement, SQLITE3_INTEGER),
|
|
|
|
|
|
|
|
"index" => array($index, SQLITE3_INTEGER),
|
|
|
|
|
|
|
|
"temps" => array($emailUtilisateur, SQLITE3_FLOAT)));
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
else
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
$query="UPDATE Resoudre
|
|
|
|
|
|
|
|
SET classement=:classement;
|
|
|
|
|
|
|
|
WHERE joueur=:joueur
|
|
|
|
|
|
|
|
AND enigme=:idEnigme
|
|
|
|
|
|
|
|
AND partie=:idPartie";
|
|
|
|
|
|
|
|
$this->con->executeQuery($query, array(
|
|
|
|
|
|
|
|
"joueur" => array($emailUtilisateur, SQLITE3_TEXT),
|
|
|
|
|
|
|
|
"enigme" => array($idEnigme, SQLITE3_INTEGER),
|
|
|
|
|
|
|
|
"partie" => array($idPartie, SQLITE3_INTEGER),
|
|
|
|
|
|
|
|
"classement" => array($classement, SQLITE3_INTEGER)));
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public function showAll() : void{
|
|
|
|
public function showAll() : void{
|
|
|
|