Annualtion de changement
continuous-integration/drone/push Build is passing Details

ServeurDeTest
Noé GARNIER 2 years ago
parent bfd7171a55
commit 61929cfd65

@ -53,6 +53,6 @@ $error = "";
// Server // Server
$serverAdress = "82.165.180.114"; $serverAdress = "82.165.180.114";
$playerNumberPerGame = 2; $playerNumberPerGame = 2;
$nbEnigmePerGame = 1; $nbEnigmePerGame = 2;

@ -291,22 +291,19 @@ class ResoudreGateway
} }
return $results[0]['max(indexEnigme)']; return $results[0]['max(indexEnigme)'];
} }
public function getClassement($enigmeId, $idPartie) : array{ public function getMaxClassement($enigmeId, $idPartie) : int{
$query="SELECT classement FROM Resoudre $query="SELECT classement FROM Resoudre
WHERE enigme=:enigme WHERE enigme=:enigme
AND partie=:partie AND partie=:partie
ORDER BY classement"; ORDER BY classement DESC LIMIT 1";
$this->con->executeQuery($query, array( $this->con->executeQuery($query, array(
"enigme" => array($enigmeId, SQLITE3_INTEGER), "enigme" => array($enigmeId, SQLITE3_INTEGER),
"partie" => array($idPartie, SQLITE3_INTEGER))); "partie" => array($idPartie, SQLITE3_INTEGER)));
$results=$this->con->getResults(); $results=$this->con->getResults();
if (empty($results) || $results[0]['classement'] == null) { if (empty($results) || $results[0]['classement'] == null) {
return array(0); return 0;
}
foreach ($results as $row){
$classment[] = $row['classement'];
} }
return $classment; return $results[0]['classement'];
} }
public function getAllByPartieAndUtilisateur(string $mailUtilisateur, int $idPartie) : array{ public function getAllByPartieAndUtilisateur(string $mailUtilisateur, int $idPartie) : array{

@ -118,44 +118,18 @@ class UserModel
public function enigmeEnded(string $mailUtilisateur, int $enigmeId){ public function enigmeEnded(string $mailUtilisateur, int $enigmeId){
$this->resoudre_gateway->enigmeEnded($mailUtilisateur,$enigmeId); $this->resoudre_gateway->enigmeEnded($mailUtilisateur,$enigmeId);
} }
public function largest_consecutive_number($list) {
sort($list);
$largest = 0;
$missing = 0;
for ($i = 0; $i < count($list) - 1; $i++) {
if ($list[$i] + 1 != $list[$i + 1]) {
if ($list[$i] > $largest) {
$largest = $list[$i];
}
if ($missing == 0) {
$missing = $list[$i] + 1;
}
} else {
if ($list[$i] > $largest) {
$largest = $list[$i];
}
}
}
if ($missing != 0) {
return $missing;
} else {
return $largest + 1;
}
}
public function enigmeMultiEnded(string $mailUtilisateur, int $enigmeId){ public function enigmeMultiEnded(string $mailUtilisateur, int $enigmeId){
$idPartie = $_SESSION['idPartie']; $idPartie = $_SESSION['idPartie'];
$dateDebut = $this->partie_gateway->getDateDebut($idPartie); $dateDebut = $this->partie_gateway->getDateDebut($idPartie);
$now = new DateTime(); $now = new DateTime();
$interval = $now->diff($dateDebut); $interval = $now->diff($dateDebut);
$tempDeResolution = $interval->days * 24 * 60 * 60 + $interval->h * 60 * 60 + $interval->i * 60 + $interval->s; $tempDeResolution = $interval->days * 24 * 60 * 60 + $interval->h * 60 * 60 + $interval->i * 60 + $interval->s;
$leClassement = $this->resoudre_gateway->getClassement($enigmeId, $idPartie); $result = $this->resoudre_gateway->getMaxClassement($enigmeId, $idPartie);
if ($leClassement[0] == 0){ if ($result == 0){
$classement = 3; $classement = 1;
} }
else{ else{
$classement = 2; $classement = $result + 1;
} }
$this->resoudre_gateway->enigmeMultiEnded($mailUtilisateur,$enigmeId, $tempDeResolution, $classement); $this->resoudre_gateway->enigmeMultiEnded($mailUtilisateur,$enigmeId, $tempDeResolution, $classement);
} }

Loading…
Cancel
Save