|
|
@ -219,10 +219,11 @@ class UserController
|
|
|
|
$_SESSION['idPartie'] = $idPartie;
|
|
|
|
$_SESSION['idPartie'] = $idPartie;
|
|
|
|
$lesJoueurs = $model->getLesJoueurs($idPartie);
|
|
|
|
$lesJoueurs = $model->getLesJoueurs($idPartie);
|
|
|
|
if($etat == 1){
|
|
|
|
if($etat == 1){
|
|
|
|
|
|
|
|
$model->launchGame($idPartie);
|
|
|
|
header("Location: index.php?action=goToGame&idPartie=" . $idPartie . "&index=1");
|
|
|
|
header("Location: index.php?action=goToGame&idPartie=" . $idPartie . "&index=1");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else{
|
|
|
|
else{
|
|
|
|
while ($etat == 0){
|
|
|
|
while ($etat != 1){
|
|
|
|
sleep(5);
|
|
|
|
sleep(5);
|
|
|
|
$etat = $model->getEtatPartie($idPartie);
|
|
|
|
$etat = $model->getEtatPartie($idPartie);
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -234,7 +235,8 @@ class UserController
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public function goToGame(){
|
|
|
|
public function goToGame()
|
|
|
|
|
|
|
|
{
|
|
|
|
try {
|
|
|
|
try {
|
|
|
|
global $rep, $vues, $error;
|
|
|
|
global $rep, $vues, $error;
|
|
|
|
$model = new UserModel();
|
|
|
|
$model = new UserModel();
|
|
|
@ -242,15 +244,15 @@ class UserController
|
|
|
|
$idPartie = $_GET['idPartie'];
|
|
|
|
$idPartie = $_GET['idPartie'];
|
|
|
|
$index = $_GET['index'];
|
|
|
|
$index = $_GET['index'];
|
|
|
|
$lastIndex = $model->getLastIndex($idPartie);
|
|
|
|
$lastIndex = $model->getLastIndex($idPartie);
|
|
|
|
if($lastIndex != 0 && $index == $lastIndex + 1){
|
|
|
|
if ($lastIndex != 0 && $index == $lastIndex + 1) {
|
|
|
|
if ($model->checkGameIsEnd($idPartie)){
|
|
|
|
if ($model->checkGameIsEnd($idPartie)) {
|
|
|
|
$this->endGame();
|
|
|
|
$this->endGame();
|
|
|
|
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
$dateDebut = $model->getDateDebut($idPartie);
|
|
|
|
$dateDebut = $model->getDateDebut($idPartie);
|
|
|
|
$points = $model->getPointsAtTheEnd($utilisateur->getEmail(), $idPartie);
|
|
|
|
$points = $model->getPointsAtTheEnd($utilisateur->getEmail(), $idPartie);
|
|
|
|
require($rep . $vues['lobbyEnd']);
|
|
|
|
require($rep . $vues['lobbyEnd']);
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
else{
|
|
|
|
|
|
|
|
$enigme = $model->getEnigmebyPartieIdAndIndex($idPartie, $index);
|
|
|
|
$enigme = $model->getEnigmebyPartieIdAndIndex($idPartie, $index);
|
|
|
|
$model->resoudreEnigmeMulti($utilisateur, $enigme->getIdEnigme(), $idPartie, $index);
|
|
|
|
$model->resoudreEnigmeMulti($utilisateur, $enigme->getIdEnigme(), $idPartie, $index);
|
|
|
|
$code = $model->getCode($utilisateur->getEmail(), $enigme->getIdEnigme());
|
|
|
|
$code = $model->getCode($utilisateur->getEmail(), $enigme->getIdEnigme());
|
|
|
@ -261,18 +263,6 @@ class UserController
|
|
|
|
require($rep . $vues['erreur']);
|
|
|
|
require($rep . $vues['erreur']);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
public function launchGame(){
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
|
|
|
global $rep, $vues, $error;
|
|
|
|
|
|
|
|
$model = new UserModel();
|
|
|
|
|
|
|
|
$model->launchGame();
|
|
|
|
|
|
|
|
require($rep . $vues['partie']);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
catch (Exception $e) {
|
|
|
|
|
|
|
|
$error = $e->getMessage();
|
|
|
|
|
|
|
|
require($rep . $vues['erreur']);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
public function logout()
|
|
|
|
public function logout()
|
|
|
|
{
|
|
|
|
{
|
|
|
|
$_SESSION['role'] = 'visitor';
|
|
|
|
$_SESSION['role'] = 'visitor';
|
|
|
@ -347,6 +337,7 @@ class UserController
|
|
|
|
global $rep, $vues, $error;
|
|
|
|
global $rep, $vues, $error;
|
|
|
|
$model = new UserModel();
|
|
|
|
$model = new UserModel();
|
|
|
|
$idPartie = $_SESSION['idPartie'];
|
|
|
|
$idPartie = $_SESSION['idPartie'];
|
|
|
|
|
|
|
|
$lesInfos = $model->getEndGameInfo($idPartie);
|
|
|
|
$model->endGame($idPartie);
|
|
|
|
$model->endGame($idPartie);
|
|
|
|
require ($rep . $vues['gameEnd']);
|
|
|
|
require ($rep . $vues['gameEnd']);
|
|
|
|
}
|
|
|
|
}
|
|
|
|