diff --git a/WEB/Controller/PartieGateway.php b/WEB/Controller/PartieGateway.php index d51fe7f0..ebda73e4 100644 --- a/WEB/Controller/PartieGateway.php +++ b/WEB/Controller/PartieGateway.php @@ -12,7 +12,7 @@ class PartieGateway { $this->con = $con; } - public function creerPartie(){ + public function creerPartie($listeEmailJoueur){ $query = "SELECT * FROM Enigme"; $this->con->executeQuery($query); $results = $this->con->getResults(); @@ -20,7 +20,7 @@ class PartieGateway FROM PARTIE p;"; $this->con->executeQuery($query); $max=$this->con->getResults()[0]; - $partie=PartieFactory::createPartie($max,$results); + $partie=PartieFactory::createPartie($max,$results,$listeEmailJoueur); $query= "INSERT INTO Partie VALUES (:idPartie,:idEnigme)"; $this->con->executeQuery($query, array(':idPartie' => array($partie->getIdPartie(), PDO::PARAM_STR))); foreach($partie->getListeEnigme() as $Enigme){ @@ -46,13 +46,6 @@ class PartieGateway $tabEnigme=EnigmeFactory::create($results); return $tabEnigme; } - public function findIdMax(){ - $query= "SELECT max(p.id) - FROM PARTIE p;"; - $this->con->executeQuery($query); - $results=$this->con->getResults(); - return $results[0]->max; - } public function showAll() : void{ $query= "SELECT * FROM Partie"; $this->con->executeQuery($query); diff --git a/WEB/Factory/PartieFactory.php b/WEB/Factory/PartieFactory.php index 64f7774b..7db30e91 100644 --- a/WEB/Factory/PartieFactory.php +++ b/WEB/Factory/PartieFactory.php @@ -2,7 +2,7 @@ include_once "EnigmeFactory.php"; include_once "../Model/Partie.php"; class PartieFactory{ - public static function createPartie($idMax,$resultsEnigme) : Partie + public static function createPartie($idMax,$resultsEnigme,$listeEmailJoueur) : Partie { $tempsResolutionPartie=0; $tabEnigme=array(); @@ -15,7 +15,7 @@ class PartieFactory{ $TempsResolutionPartie+=$resultsEnigme[$randomNumber]['tempsDeResolution']; unset($tabIndex[$randomNumber]); } - $partie=new Partie($idMax,$resultsEnigme); + $partie=new Partie($idMax,$resultsEnigme,$listeEmailJoueur); return $partie; } //public static function createListePartie() diff --git a/WEB/Model/Partie.php b/WEB/Model/Partie.php index 860f4cf5..74354ea7 100644 --- a/WEB/Model/Partie.php +++ b/WEB/Model/Partie.php @@ -7,16 +7,18 @@ class Partie private string $idPartie; private $datePartie; private array $listeEnigme; + private array $listeEmailJoueur; /** * @param string $idPartie * @param array $datePartie */ - public function __construct(string $idPartie, array $listeEnigme) + public function __construct(string $idPartie, array $listeEnigme, array $listeEmailJoueur) { $this->idPartie = $idPartie; $this->datePartie = getdate(); $this->$listeEnigme = $listeEnigme; + $this->$listeEmailJoueur= $listeEmailJoueur; } /** @@ -63,4 +65,12 @@ class Partie { $this->listeEnigme = $listeEnigme; } + public function getListeEmailJoueur(): array + { + return $this->listeEmailJoueur; + } + public function setListeEmailJoueur(array $listeEmailJoueur) + { + $this->listeEmailJoueur=$listeEmailJoueur; + } } \ No newline at end of file