Merge branch 'master' of https://codefirst.iut.uca.fr/git/nathan.boileau/Scripted
continuous-integration/drone/push Build is passing Details

ServeurDeTest
nathan boileau 2 years ago
commit b2c835d1e8

@ -122,6 +122,12 @@ class AdminController extends UserController
case "goToDashboard": case "goToDashboard":
$this->goToDashboard(); $this->goToDashboard();
break; break;
case "getPlayersPseudo":
$this->getPlayersPseudo();
break;
case "getDashboardInfo":
$this->getDashboardInfo();
break;
case "report": case "report":
$this->report(); $this->report();
break; break;

@ -342,29 +342,43 @@ class ResoudreGateway
$query = "UPDATE Resoudre $query = "UPDATE Resoudre
SET ended=:ended SET ended=:ended
WHERE utilisateur=:utilisateur WHERE utilisateur=:utilisateur
AND partie=:partie"; AND partie=:partie
AND enigme=:enigme";
$this->con->executeQuery($query, array( $this->con->executeQuery($query, array(
"utilisateur" => array($mailUtilisateur, SQLITE3_TEXT), "utilisateur" => array($mailUtilisateur, SQLITE3_TEXT),
"partie" => array($idPartie, SQLITE3_INTEGER), "partie" => array($idPartie, SQLITE3_INTEGER),
"enigme" => array($idEnigme, SQLITE3_INTEGER),
"ended" => array(1, SQLITE3_INTEGER))); "ended" => array(1, SQLITE3_INTEGER)));
$query = "UPDATE Resoudre $query = "UPDATE Resoudre
SET temps=:temps SET temps=:temps
WHERE utilisateur=:utilisateur WHERE utilisateur=:utilisateur
AND partie=:partie"; AND partie=:partie
AND enigme=:enigme";
$this->con->executeQuery($query, array( $this->con->executeQuery($query, array(
"utilisateur" => array($mailUtilisateur, SQLITE3_TEXT), "utilisateur" => array($mailUtilisateur, SQLITE3_TEXT),
"partie" => array($idPartie, SQLITE3_INTEGER), "partie" => array($idPartie, SQLITE3_INTEGER),
"enigme" => array($idEnigme, SQLITE3_INTEGER),
"temps" => array(null, SQLITE3_NULL))); "temps" => array(null, SQLITE3_NULL)));
$query = "UPDATE Resoudre $query = "UPDATE Resoudre
SET classement=:classement SET classement=:classement
WHERE utilisateur=:utilisateur WHERE utilisateur=:utilisateur
AND partie=:partie"; AND partie=:partie
AND enigme=:enigme";
$this->con->executeQuery($query, array( $this->con->executeQuery($query, array(
"utilisateur" => array($mailUtilisateur, SQLITE3_TEXT), "utilisateur" => array($mailUtilisateur, SQLITE3_TEXT),
"partie" => array($idPartie, SQLITE3_INTEGER), "partie" => array($idPartie, SQLITE3_INTEGER),
"enigme" => array($idEnigme, SQLITE3_INTEGER),
"classement" => array($playerNumberPerGame, SQLITE3_INTEGER))); "classement" => array($playerNumberPerGame, SQLITE3_INTEGER)));
} }
public function cleanCodeAfterGame(int $idPartie) {
$query = "UPDATE Resoudre
SET code=:code
WHERE partie=:partie";
$this->con->executeQuery($query, array(
"partie" => array($idPartie, SQLITE3_INTEGER),
"code" => array('', SQLITE3_TEXT)));
}
} }

@ -79,12 +79,6 @@ class UserController
case "getPlayersPseudo": case "getPlayersPseudo":
$this->getPlayersPseudo(); $this->getPlayersPseudo();
break; break;
case "getPlayersEmail":
$this->getPlayersEmail();
break;
case "getPlayerScore":
$this->getPlayerScore();
break;
case "getDashboardInfo": case "getDashboardInfo":
$this->getDashboardInfo(); $this->getDashboardInfo();
break; break;
@ -466,36 +460,6 @@ class UserController
require($rep . $vues['erreur']); require($rep . $vues['erreur']);
} }
} }
public function getPlayersEmail(){
try {
global $rep, $vues, $error;
$model = new UserModel();
$idPartie = $_SESSION['idPartie'];
$lesJoueurs = $model->getLesJoueurs($idPartie);
$lesJoueurs = json_encode($lesJoueurs);
echo $lesJoueurs;
}
catch (Exception $e) {
$error = $e->getMessage();
require($rep . $vues['erreur']);
}
}
public function getPlayerScore(){
try {
global $rep, $vues, $error;
$model = new UserModel();
$idPartie = $_SESSION['idPartie'];
$pseudo = $_POST['pseudo'];
$mailUtilisateur = $model->getMailFromPseudo($pseudo);
$score = $model->getPlayerScore($mailUtilisateur, $idPartie);
$score = json_encode($score);
echo $score;
}
catch (Exception $e) {
$error = $e->getMessage();
require($rep . $vues['erreur']);
}
}
public function getDashboardInfo(){ public function getDashboardInfo(){
try { try {
global $rep, $vues, $error; global $rep, $vues, $error;

@ -205,10 +205,7 @@ class UserModel
$points = 0; $points = 0;
$result = $this->resoudre_gateway->getAllByPartieAndUtilisateur($mailUtilisateur, $idPartie); $result = $this->resoudre_gateway->getAllByPartieAndUtilisateur($mailUtilisateur, $idPartie);
foreach ($result as $row){ foreach ($result as $row){
if ($row['temps'] == 0){ if ($row['temps'] == 0 || $row['ended'] == 0){
$points += 0;
}
else if ($row['ended'] == 0){
$points += 0; $points += 0;
} }
else if ($row['classement'] == 1){ else if ($row['classement'] == 1){
@ -261,6 +258,7 @@ class UserModel
return true; return true;
} }
public function endGame(int $idPartie) { public function endGame(int $idPartie) {
$this->resoudre_gateway->cleanCodeAfterGame($idPartie);
$this->partie_gateway->endGame($idPartie); $this->partie_gateway->endGame($idPartie);
} }

@ -34,8 +34,6 @@
}, },
axisY: { axisY: {
title: "Point", title: "Point",
titleFontColor: "#6D78AD",
lineColor: "#6D78AD",
gridThickness: 0, gridThickness: 0,
lineThickness: 1, lineThickness: 1,
}, },

@ -18,7 +18,7 @@
<div class="d-flex flex-column align-items-center"> <div class="d-flex flex-column align-items-center">
<h1>Partie Terminée !</h1> <h1>Partie Terminée !</h1>
<h2>Gagnant : <?php echo $lesInfos[3]->getPseudo() ?></h2> <h2>Gagnant : <?php echo $lesInfos[3]->getPseudo() ?></h2>
<p>Bien joué à tous la partie est finis, voici le classement :</p> <p>Bien joué à tous la partie est fini, voici le classement :</p>
</div> </div>
<table class="table"> <table class="table">
<thead class="text-center"> <thead class="text-center">

@ -18,7 +18,7 @@
</div> </div>
<div class="row"> <div class="row">
<div class="col-12 d-flex flex-column align-items-center"> <div class="col-12 d-flex flex-column align-items-center">
<p>Vous avez terminer toute les énimges.</p> <p>Vous avez terminé toutes les énigmes.</p>
<p>Votre score est de : <?php echo $points ?> points.</p> <p>Votre score est de : <?php echo $points ?> points.</p>
<p>Temps restant avant la fin de la partie :</p> <p>Temps restant avant la fin de la partie :</p>
<?php <?php

Loading…
Cancel
Save