Skip eningme en partie +
continuous-integration/drone/push Build is passing Details

corections du calcul des points
ServeurDeTest
Noé GARNIER 2 years ago
parent 56f555696c
commit 029f474f21

@ -383,6 +383,8 @@ class PartieGateway
)
);
}
// public function quitGame(string $mailUtilisateur,int $idPartie){
// }
public function showAll(): void
{
$query = "SELECT * FROM Partie";

@ -316,4 +316,35 @@ class ResoudreGateway
$results=$this->con->getResults();
return $results;
}
public function skipEnigme(string $mailUtilisateur, int $idPartie, int $idEnigme) {
global $playerNumberPerGame;
$query = "UPDATE Resoudre
SET ended=:ended
WHERE utilisateur=:utilisateur
AND partie=:partie";
$this->con->executeQuery($query, array(
"utilisateur" => array($mailUtilisateur, SQLITE3_TEXT),
"partie" => array($idPartie, SQLITE3_INTEGER),
"ended" => array(1, SQLITE3_INTEGER)));
$query = "UPDATE Resoudre
SET temps=:temps
WHERE utilisateur=:utilisateur
AND partie=:partie";
$this->con->executeQuery($query, array(
"utilisateur" => array($mailUtilisateur, SQLITE3_TEXT),
"partie" => array($idPartie, SQLITE3_INTEGER),
"temps" => array(0, SQLITE3_INTEGER)));
$query = "UPDATE Resoudre
SET classement=:classement
WHERE utilisateur=:utilisateur
AND partie=:partie";
$this->con->executeQuery($query, array(
"utilisateur" => array($mailUtilisateur, SQLITE3_TEXT),
"partie" => array($idPartie, SQLITE3_INTEGER),
"classement" => array($playerNumberPerGame, SQLITE3_INTEGER)));
}
}

@ -67,6 +67,12 @@ class UserController
case "quitQueue":
$this->quitQueue();
break;
case "quitGame":
$this->quitGame();
break;
case "skipEnigme":
$this->skipEnigme();
break;
default:
$error = "Action non valide";
require($rep . $vues['erreur']);
@ -389,4 +395,36 @@ class UserController
require($rep . $vues['erreur']);
}
}
public function quitGame(){
try {
global $rep, $vues, $error;
$model = new UserModel();
$idPartie = $_SESSION['idPartie'];
$utilisateur = $_SESSION['utilisateur'];
// $model->quitGame($utilisateur->getEmail(), $idPartie);
// echo '<script>alert("Vous avez quitté la partie.");</script>';
// require ($rep . $vues['lobby']);
}
catch (Exception $e) {
$error = $e->getMessage();
require($rep . $vues['erreur']);
}
}
public function skipEnigme(){
try {
global $rep, $vues, $error;
$model = new UserModel();
$idPartie = $_SESSION['idPartie'];
$utilisateur = $_SESSION['utilisateur'];
$idEnigme = $_GET['idEnigme'];
$index = $_GET['index'];
$model->skipEnigme($utilisateur->getEmail(), $idPartie, $idEnigme);
$index = $index + 1;
header("Location: index.php?action=goToGame&idPartie=" . $idPartie . "&index=". $index);
}
catch (Exception $e) {
$error = $e->getMessage();
require($rep . $vues['erreur']);
}
}
}

@ -188,6 +188,7 @@ class UserModel
}
public function getPointsAtTheEnd(string $mailUtilisateur, int $idPartie) : int{
global $playerNumberPerGame;
$points = 0;
$result = $this->resoudre_gateway->getAllByPartieAndUtilisateur($mailUtilisateur, $idPartie);
foreach ($result as $row){
@ -197,9 +198,15 @@ class UserModel
else if ($row['classement'] == 2){
$points += $this->enigme_gateway->findById($row['enigme'])[0]->getPoints() * 0.75;
}
else{
else if ($row['classement'] == 3){
$points += $this->enigme_gateway->findById($row['enigme'])[0]->getPoints() * 0.5;
}
else if ($row['ended'] == 0){
$points += 0;
}
else{
$points += $this->enigme_gateway->findById($row['enigme'])[0]->getPoints() * 0.25;
}
}
return $points;
}
@ -254,4 +261,13 @@ class UserModel
$this->partie_gateway->delete($idPartie);
}
}
public function skipEnigme(string $mailUtilisateur, int $idPartie, int $idEnigme) {
$this->resoudre_gateway->skipEnigme($mailUtilisateur, $idPartie, $idEnigme);
}
// public function quitGame(string $mailUtilisateur, int $idPartie) {
// $this->partie_gateway->quitGame($mailUtilisateur, $idPartie);
// if ($this->partie_gateway->getPlayerNumber($idPartie) == 0){
// $this->partie_gateway->delete($idPartie);
// }
// }
}

@ -31,8 +31,9 @@
</div>
<div class="col-4 d-flex align-items-center justify-content-center px-0">
<button>Next</button>
</div><div class="col-4 d-flex align-items-center justify-content-center px-0">
<a href=<?php echo '"index.php?action=skipEnigme&id='. $enigme->getId() . '&index='. $index .'"' ?>>Skip</a>
</div>
<div class="col-4 d-flex align-items-center justify-content-center px-0">
<p>Temps restant : </p>
<?php
$end_time = $dateDebut->modify('+'. $_SESSION['tpsMaxPartie'] .'seconds');

Loading…
Cancel
Save