|
|
|
@ -12,7 +12,12 @@ class PartieGateway
|
|
|
|
|
{
|
|
|
|
|
$this->con = $con;
|
|
|
|
|
}
|
|
|
|
|
public function creerPartie(){
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @param array $listeJoueur
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
public function creerPartie(array $listeJoueur){
|
|
|
|
|
$query = "SELECT * FROM Enigme";
|
|
|
|
|
$this->con->executeQuery($query);
|
|
|
|
|
$results = $this->con->getResults();
|
|
|
|
@ -22,20 +27,27 @@ class PartieGateway
|
|
|
|
|
$max=$this->con->getResults()[0];
|
|
|
|
|
$partie=PartieFactory::createPartie($max,$results);
|
|
|
|
|
$query= "INSERT INTO Partie VALUES (:idPartie,:idEnigme)";
|
|
|
|
|
$this->con->executeQuery($query, array(':idPartie' => array($partie->getIdPartie(), PDO::PARAM_STR)));
|
|
|
|
|
$this->con->executeQuery($query, array(':idPartie' => array($partie->getIdPartie(), SQLITE3_INTEGER)));
|
|
|
|
|
foreach($partie->getListeEnigme() as $Enigme){
|
|
|
|
|
$query= "INSERT INTO Contenir VALUES (:idPartie, :idEnigme)";
|
|
|
|
|
$this->con->executeQuery($query, array(
|
|
|
|
|
':idPartie' => array($partie->getIdPartie(), PDO::PARAM_STR),
|
|
|
|
|
':idEnigme' => array($Enigme->getIdEnigme(), PDO::PARAM_STR)));
|
|
|
|
|
':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)));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function delete(string $idPartie){
|
|
|
|
|
$query= "DELETE FROM Partie WHERE id = :idPartie";
|
|
|
|
|
$this->con->executeQuery($query, array(':idPartie' => array($idPartie, PDO::PARAM_STR)));
|
|
|
|
|
$this->con->executeQuery($query, array(':idPartie' => array($idPartie, SQLITE3_INTEGER)));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function findOldListePartie() : array{
|
|
|
|
|
public function findPartieHistory() : array{
|
|
|
|
|
$query="SELECT * FROM Partie";
|
|
|
|
|
$this->con->executeQuery($query);
|
|
|
|
|
$results = $this->con->getResults();
|
|
|
|
@ -43,50 +55,21 @@ class PartieGateway
|
|
|
|
|
FROM PARTIE p;";
|
|
|
|
|
$this->con->executeQuery($query);
|
|
|
|
|
$max=$this->con->getResults()[0];
|
|
|
|
|
$listePartie=array();
|
|
|
|
|
$listePartieHistory=array();
|
|
|
|
|
foreach($results as $row)
|
|
|
|
|
{
|
|
|
|
|
$query = "SELECT e.* FROM Enigme e,Contenir c,Partie p
|
|
|
|
|
WHERE p.id = c.partie
|
|
|
|
|
AND c.enigme = e.id";
|
|
|
|
|
$this->con->executeQuery($query);
|
|
|
|
|
$listeEnigme=$this->con->getResults();
|
|
|
|
|
$listePartie[]=PartieFactory::createPartie($max,$listeEnigme);
|
|
|
|
|
}
|
|
|
|
|
return $listePartie;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function getDashBoardData(Partie $partie) : array{
|
|
|
|
|
$query="SELECT joueur
|
|
|
|
|
FROM Participer p
|
|
|
|
|
WHERE p.partie=:idPartie";
|
|
|
|
|
AND c.enigme = e.id
|
|
|
|
|
AND c.enCours = false;
|
|
|
|
|
AND p.partie = :idPartie";
|
|
|
|
|
$this->con->executeQuery($query,array(
|
|
|
|
|
'idPartie' => array($partie->getIdPartie(),PDO::PARAM_INT)));
|
|
|
|
|
$listeIdJoueur=$this->con->getResults();
|
|
|
|
|
$DashboardData=array();
|
|
|
|
|
foreach($listeIdJoueur as $joueur){
|
|
|
|
|
$points=0;
|
|
|
|
|
$query="SELECT pe.utilisateur,pe.points,pe.temps,u.pseudo
|
|
|
|
|
FROM Utilisateur u,PasserEnigme pe,Partie p
|
|
|
|
|
WHERE points IS NOT NULL
|
|
|
|
|
AND u.email=pe.utilisateur
|
|
|
|
|
AND pe.partie=:idPartie
|
|
|
|
|
AND pe.utilisateur=:joueur
|
|
|
|
|
GROUP BY pe.utilisateur,pe.points,pe.temps,u.pseudo
|
|
|
|
|
ORDER BY u.pseudo,pe.temps ASC";
|
|
|
|
|
$this->con->executequery($query,array(
|
|
|
|
|
'idPartie' => array($partie->getIdPartie(),PDO::PARAM_INT),
|
|
|
|
|
'joueur' => array($joueur,PDO::PARAM_STR)));
|
|
|
|
|
$results=$this->con->getResults();
|
|
|
|
|
$joueurDashboardData=array();
|
|
|
|
|
foreach($results as $row)
|
|
|
|
|
{
|
|
|
|
|
$points+=$row['pe.points'];
|
|
|
|
|
$joueurDashboardData[]=array($points,$row['pe.temps']);
|
|
|
|
|
}
|
|
|
|
|
$DashboardData[]=array($results[0]['u.pseudo'] => $joueurDashboardData);
|
|
|
|
|
"idPartie" => array($row["idPartie"],SQLITE3_INTEGER)
|
|
|
|
|
));
|
|
|
|
|
$historiquePartie=$this->con->getResults();
|
|
|
|
|
$listePartieHistory[]=PartieFactory::createPartieHistory($row["idPartie"],$historiquePartie);
|
|
|
|
|
}
|
|
|
|
|
return $DashboardData;
|
|
|
|
|
return $listePartieHistory;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function showAll() : void{
|
|
|
|
|