diff --git a/Controller/ResoudreGateway.php b/Controller/ResoudreGateway.php index b3f29468..261e2a16 100644 --- a/Controller/ResoudreGateway.php +++ b/Controller/ResoudreGateway.php @@ -189,32 +189,38 @@ class ResoudreGateway "enigme" => array($enigmeId, SQLITE3_INTEGER), "ended" => array(1, SQLITE3_INTEGER))); } - public function enigmeMultiEnded(string $mailUtilisateur, int $enigmeId, int $tempDeResolution, $classement){ + public function enigmeMultiEnded(string $mailUtilisateur, int $enigmeId, int $idPartie ,int $tempDeResolution, $classement){ $query="UPDATE Resoudre SET ended=:ended WHERE utilisateur=:utilisateur - AND enigme=:enigme"; + AND enigme=:enigme + AND partie=:partie"; $this->con->executeQuery($query, array( "utilisateur" => array($mailUtilisateur, SQLITE3_TEXT), "enigme" => array($enigmeId, SQLITE3_INTEGER), + "partie" => array($idPartie, SQLITE3_INTEGER), "ended" => array(1, SQLITE3_INTEGER))); $query="UPDATE Resoudre SET temps=:temps WHERE utilisateur=:utilisateur - AND enigme=:enigme"; + AND enigme=:enigme + AND partie=:partie"; $this->con->executeQuery($query, array( "utilisateur" => array($mailUtilisateur, SQLITE3_TEXT), "enigme" => array($enigmeId, SQLITE3_INTEGER), + "partie" => array($idPartie, SQLITE3_INTEGER), "temps" => array($tempDeResolution, SQLITE3_INTEGER))); $query="UPDATE Resoudre SET classement=:classement WHERE utilisateur=:utilisateur - AND enigme=:enigme"; + AND enigme=:enigme + AND partie=:partie"; $this->con->executeQuery($query, array( "utilisateur" => array($mailUtilisateur, SQLITE3_TEXT), "enigme" => array($enigmeId, SQLITE3_INTEGER), + "partie" => array($idPartie, SQLITE3_INTEGER), "classement" => array($classement, SQLITE3_INTEGER))); } diff --git a/Model/UserModel.php b/Model/UserModel.php index 50eb15d6..7f75da8b 100644 --- a/Model/UserModel.php +++ b/Model/UserModel.php @@ -125,21 +125,21 @@ class UserModel $now = new DateTime(); $interval = $now->diff($dateDebut); $tempDeResolution = $interval->days * 24 * 60 * 60 + $interval->h * 60 * 60 + $interval->i * 60 + $interval->s; - $result = $this->resoudre_gateway->getMaxClassement($enigmeId, $idPartie); - // $leClassement = $this->resoudre_gateway->getClassement($enigmeId, $idPartie); - // for ($i = 0; $i < $playerNumberPerGame; $i++){ - // if ($leClassement[$i] == null || $leClassement[$i] != $i + 1){ - // $classement = $i + 1; - // break; - // } - // } - if ($result == 0){ - $classement = 1; - } - else{ - $classement = $result + 1; + // $result = $this->resoudre_gateway->getMaxClassement($enigmeId, $idPartie); + $leClassement = $this->resoudre_gateway->getClassement($enigmeId, $idPartie); + for ($i = 0; $i < $playerNumberPerGame; $i++){ + if ($leClassement[$i] == null || $leClassement[$i] != $i + 1){ + $classement = $i + 1; + break; + } } - $this->resoudre_gateway->enigmeMultiEnded($mailUtilisateur,$enigmeId, $tempDeResolution, $classement); + // if ($result == 0){ + // $classement = 1; + // } + // else{ + // $classement = $result + 1; + // } + $this->resoudre_gateway->enigmeMultiEnded($mailUtilisateur,$enigmeId, $idPartie ,$tempDeResolution, $classement); } public function saveCode(string $mailUtilisateur, int $enigmeId,string $code ){