|
|
|
@ -21,17 +21,27 @@ class PartieGateway
|
|
|
|
|
/**
|
|
|
|
|
* @param array $listeJoueur
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
public function creerPartieMulti(array $listeJoueur){
|
|
|
|
|
$query = "SELECT * FROM Enigme
|
|
|
|
|
WHERE points IS NOT NULL OR points != 0";
|
|
|
|
|
public function partieInQueueExists() : bool{
|
|
|
|
|
$query = "SELECT count(*) FROM PARTICIPER WHERE etat = 0";
|
|
|
|
|
$this->con->executeQuery($query);
|
|
|
|
|
$results = $this->con->getResults();
|
|
|
|
|
$query= "SELECT max(p.id)
|
|
|
|
|
FROM PARTIE p;";
|
|
|
|
|
if ($results[0]['count'] == 0)
|
|
|
|
|
return false;
|
|
|
|
|
else
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function findPartieMaxId() : int{
|
|
|
|
|
$query = "SELECT max(id) FROM Partie";
|
|
|
|
|
$this->con->executeQuery($query);
|
|
|
|
|
$max=$this->con->getResults()[0]["max"];
|
|
|
|
|
$partie=PartieFactory::createPartieMulti($max,$results);
|
|
|
|
|
$results=$this->con->getResults();
|
|
|
|
|
if (empty($results))
|
|
|
|
|
return 0;
|
|
|
|
|
else
|
|
|
|
|
return $results[0]['max'];
|
|
|
|
|
}
|
|
|
|
|
public function creerPartieMulti(int $max, array $tabEnigme) : Partie{
|
|
|
|
|
$partie=PartieFactory::createPartieMulti($max+1,$tabEnigme);
|
|
|
|
|
$query= "INSERT INTO Partie VALUES (:idPartie,:idEnigme)";
|
|
|
|
|
$this->con->executeQuery($query, array(':idPartie' => array($partie->getIdPartie(), SQLITE3_INTEGER)));
|
|
|
|
|
foreach($partie->getListeEnigme() as $Enigme){
|
|
|
|
@ -40,12 +50,17 @@ class PartieGateway
|
|
|
|
|
':idPartie' => array($partie->getIdPartie(), SQLITE3_INTEGER),
|
|
|
|
|
':idEnigme' => array($Enigme->getIdEnigme(), SQLITE3_INTEGER)));
|
|
|
|
|
}
|
|
|
|
|
foreach($listeJoueur as $Joueur){
|
|
|
|
|
$query= "INSERT INTO Participer VALUES (:idPartie, :idJoueur, TRUE)";
|
|
|
|
|
$this->con->executeQuery($query, array(
|
|
|
|
|
':idPartie' => array($partie->getIdPartie(), SQLITE3_INTEGER),
|
|
|
|
|
':idEnigme' => array($Enigme->getIdEnigme(), SQLITE3_INTEGER)));
|
|
|
|
|
}
|
|
|
|
|
return $partie;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function findPartieInQueue(){
|
|
|
|
|
$query = "SELECT id
|
|
|
|
|
FROM Partie p, Participer pa
|
|
|
|
|
WHERE pa.etat=0
|
|
|
|
|
AND pa.partie=p.id";
|
|
|
|
|
$this->con->executeQuery($query);
|
|
|
|
|
$results = $this->con->getResults();
|
|
|
|
|
return $results[0]['id'];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function creerPartieSolo(Utilisateur $utilisateur){
|
|
|
|
|