|
|
|
@ -47,7 +47,7 @@ class PartieGateway
|
|
|
|
|
return $partie;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function findPartieInQueue()
|
|
|
|
|
public function findPartieInQueue() : int
|
|
|
|
|
{
|
|
|
|
|
$query = "SELECT partie
|
|
|
|
|
FROM Participer
|
|
|
|
@ -61,7 +61,7 @@ class PartieGateway
|
|
|
|
|
return $results[0]['partie'];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function creerPartieSolo(Utilisateur $utilisateur)
|
|
|
|
|
public function creerPartieSolo(Utilisateur $utilisateur)
|
|
|
|
|
{
|
|
|
|
|
$query = "SELECT * FROM Enigme
|
|
|
|
|
WHERE points IS NULL OR points = 0";
|
|
|
|
@ -269,7 +269,7 @@ class PartieGateway
|
|
|
|
|
$row = $results[0];
|
|
|
|
|
return $row['count(*)'];
|
|
|
|
|
}
|
|
|
|
|
public function getEtat($idPartie){
|
|
|
|
|
public function getEtat($idPartie) : int{
|
|
|
|
|
$query = "SELECT etat FROM Participer WHERE partie = :idPartie";
|
|
|
|
|
$this->con->executeQuery($query, array(
|
|
|
|
|
"idPartie" => array($idPartie, SQLITE3_INTEGER)
|
|
|
|
@ -287,7 +287,7 @@ class PartieGateway
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function getLesMailJoueurs($idPartie){
|
|
|
|
|
public function getLesMailJoueurs($idPartie) : array{
|
|
|
|
|
$query = "SELECT utilisateur FROM Participer WHERE partie = :idPartie";
|
|
|
|
|
$this->con->executeQuery($query, array(
|
|
|
|
|
"idPartie" => array($idPartie, SQLITE3_INTEGER)
|
|
|
|
@ -300,7 +300,7 @@ class PartieGateway
|
|
|
|
|
}
|
|
|
|
|
return $lesJoueurs;
|
|
|
|
|
}
|
|
|
|
|
public function getLesIdEnigmes($idPartie){
|
|
|
|
|
public function getLesIdEnigmes($idPartie) : array{
|
|
|
|
|
$query = "SELECT enigme FROM Contenir WHERE partie = :idPartie";
|
|
|
|
|
$this->con->executeQuery($query, array(
|
|
|
|
|
"idPartie" => array($idPartie, SQLITE3_INTEGER)
|
|
|
|
@ -349,6 +349,11 @@ class PartieGateway
|
|
|
|
|
$date = new DateTime ($results[0]['dateDebut']);
|
|
|
|
|
return $date;
|
|
|
|
|
}
|
|
|
|
|
/**
|
|
|
|
|
* It updates the state of a game to 2 (ended) in the database
|
|
|
|
|
*
|
|
|
|
|
* @param int idPartie the id of the game
|
|
|
|
|
*/
|
|
|
|
|
public function endGame(int $idPartie){
|
|
|
|
|
$query = "UPDATE Participer SET etat = 2 WHERE partie = :idPartie";
|
|
|
|
|
$this->con->executeQuery($query, array(
|
|
|
|
@ -356,6 +361,11 @@ class PartieGateway
|
|
|
|
|
)
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
/**
|
|
|
|
|
* It updates the state of a game from 0 to 1.
|
|
|
|
|
*
|
|
|
|
|
* @param int idPartie the id of the game
|
|
|
|
|
*/
|
|
|
|
|
public function launchGame(int $idPartie){
|
|
|
|
|
$query = "UPDATE Participer SET etat=1 WHERE etat=0 AND partie=:partie";
|
|
|
|
|
$this->con->executeQuery($query,array(
|
|
|
|
@ -373,6 +383,11 @@ class PartieGateway
|
|
|
|
|
}
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
/**
|
|
|
|
|
* It updates the dateDebut column of the Partie table with the current date and time.
|
|
|
|
|
*
|
|
|
|
|
* @param int idPartie
|
|
|
|
|
*/
|
|
|
|
|
public function majDateDebut(int $idPartie){
|
|
|
|
|
$query = "UPDATE Partie SET dateDebut = :dateDebut WHERE id = :idPartie";
|
|
|
|
|
$this->con->executeQuery($query, array(
|
|
|
|
@ -381,6 +396,7 @@ class PartieGateway
|
|
|
|
|
)
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function quitQueue(string $mailUtilisateur,int $idPartie){
|
|
|
|
|
$query = "DELETE FROM Participer
|
|
|
|
|
WHERE utilisateur = :mailUtilisateur
|
|
|
|
|