Déléguations du calcul du temps max par partie
continuous-integration/drone/push Build is passing Details

ServeurDeTest
Noé GARNIER 2 years ago
parent 7f9ace9e83
commit d402bddb81

@ -161,7 +161,6 @@ class PartieGateway
)
);
$partie = $this->findLastPartie();
$tpsMaxPartie = 0;
$query = "INSERT INTO Contenir VALUES (:partie,:idEnigme,1)";
foreach ($lesEnigmes as $enigme) {
$this->con->executeQuery($query, array(
@ -169,9 +168,7 @@ class PartieGateway
"idEnigme" => array($enigme->getIdEnigme(), SQLITE3_INTEGER)
)
);
$tpsMaxPartie += $enigme->getTempsDeResolution();
}
$_SESSION['tpsMaxPartie'] = $tpsMaxPartie;
$query = "INSERT INTO Participer VALUES (:partie,:utilisateur,0)";
$this->con->executeQuery($query, array(
"partie" => array($partie->getIdPartie(), SQLITE3_INTEGER),
@ -320,6 +317,20 @@ class PartieGateway
$row = $results[0];
return $row['enigme'];
}
public function findAllEnigmeIdInPartie ($idPartie) : array{
$query = "SELECT * FROM Contenir WHERE partie = :idPartie";
$this->con->executeQuery($query, array(
"idPartie" => array($idPartie, SQLITE3_INTEGER)
)
);
$results = $this->con->getResults();
$lesEnigmes = array();
foreach ($results as $row){
$lesEnigmes[] = $row['enigme'];
}
return $lesEnigmes;
}
public function getDateDebut($idPartie) : DateTime{
$query = "SELECT dateDebut FROM Partie WHERE id = :idPartie";
$this->con->executeQuery($query, array(

@ -33,13 +33,23 @@ class UserModel
$this->partie_gateway->createPartieMulti($lesEnigmes, $mailUtilisateur);
$idPartie=$this->partie_gateway->findPartieInQueue();
$etat=$this->partie_gateway->getEtat($idPartie);
return array($idPartie, $etat);
}
else{
$this->partie_gateway->addToPartie($mailUtilisateur, $idPartie);
$etat=$this->partie_gateway->getEtat($idPartie);
}
$tpsMaxPartie = $this->calculTpsMaXPartie($idPartie);
$_SESSION['tpsMaxPartie'] = $tpsMaxPartie;
return array($idPartie, $etat);
}
public function calculTpsMaXPartie( int $idPartie) : int {
$lesIdEnigmes = $this->partie_gateway->findAllEnigmeIdInPartie($idPartie);
foreach ($lesIdEnigmes as $idEnigme){
$enigme = $this->enigme_gateway->findById($idEnigme->getIdEnigme())[0];
$tpsMaxPartie += $enigme->getTempsMax();
}
return $tpsMaxPartie;
}
public function findUserGroup() : int {

Loading…
Cancel
Save