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 ae626336e0

@ -66,7 +66,8 @@ class PartieGateway
$query = "SELECT p.id $query = "SELECT p.id
FROM Partie p, Participer pa FROM Partie p, Participer pa
WHERE pa.etat=0 WHERE pa.etat=0
AND pa.partie=p.id"; AND pa.partie=p.id
LIMIT 1";
$this->con->executeQuery($query); $this->con->executeQuery($query);
$results = $this->con->getResults(); $results = $this->con->getResults();
return $results[0]['id']; return $results[0]['id'];

@ -205,12 +205,10 @@ class UserController
require($rep . $vues['queue']); require($rep . $vues['queue']);
$model = new UserModel(); $model = new UserModel();
$model->addToQueue(); $model->addToQueue();
$usergroup = $model->findUserGroup();
echo echo
'<script> '<script>
socket.on("launchGame", () => { io.to($userGroup).emit("launchGame");
launchGame();
});
io.to($userGroup).emit("launchGame");
<script/>'; <script/>';
} catch (Exception $e) { } catch (Exception $e) {
$error = $e->getMessage(); $error = $e->getMessage();

@ -112,7 +112,7 @@ class UtilisateurGateway
public function queueFilled(){ public function queueFilled(){
$query = "SELECT count(*) FROM Participer WHERE etat=0"; $query = "SELECT count(*) FROM Participer WHERE etat=0";
$this->con->executeQuery($query); $this->con->executeQuery($query);
if ($this->con->getResults()[0]['count(*)'] >= 4) if ($this->con->getResults()[0]['count(*)'] >= 2)
return True; return True;
else else
return False; return False;

@ -44,7 +44,7 @@ class Partie
} }
/** /**
* @param array $datePartie * @param dateTime $datePartie
*/ */
public function setDatePartie(dateTime $datePartie): void public function setDatePartie(dateTime $datePartie): void
{ {

@ -25,11 +25,15 @@ class UserModel
public function addToQueue() public function addToQueue()
{ {
echo '1'; echo '1';
var_dump($this->utilisateur_gateway->isAlreadyInQueue($_SESSION['utilisateur']));
if ($this->utilisateur_gateway->isAlreadyInqueue($_SESSION['utilisateur'])) { if ($this->utilisateur_gateway->isAlreadyInqueue($_SESSION['utilisateur'])) {
var_dump($this->utilisateur_gateway->queueFilled());
if($this->utilisateur_gateway->queueFilled()) if($this->utilisateur_gateway->queueFilled())
{ {
$_REQUEST['action']='launchGame'; $_REQUEST['action']='launchGame';
var_dump($_REQUEST['action']);
} }
return;
} }
echo '2'; echo '2';
if (!$this->partie_gateway->partieInQueueExists()) { if (!$this->partie_gateway->partieInQueueExists()) {
@ -55,6 +59,10 @@ class UserModel
</script>'; </script>';
} }
public function findUserGroup() : int {
return $this->partie_gateway->findPartieInQueue();
}
public function launchGame() public function launchGame()
{ {
$this->utilisateur_gateway->launchGame($_SESSION['utilisateur']); $this->utilisateur_gateway->launchGame($_SESSION['utilisateur']);

@ -3,5 +3,6 @@
<!--script src="/root/node_modules/socket.io"></script--> <!--script src="/root/node_modules/socket.io"></script-->
<script src="C:\wamp64\www\Scripted\node_modules/socket.io"></script> <script src="C:\wamp64\www\Scripted\node_modules/socket.io"></script>
<script src="C:\wamp64\www\Scripted\server.js"></script> <script src="C:\wamp64\www\Scripted\server.js"></script>
vous êtes dans la partie
</body> </body>
</html> </html>
Loading…
Cancel
Save