From d6998c7b9651fcc124d7ba4d9c519d42c67ae8f0 Mon Sep 17 00:00:00 2001 From: johan Date: Fri, 9 Dec 2022 15:00:54 +0100 Subject: [PATCH] =?UTF-8?q?Premi=C3=A8res=20=C3=A9tapes=20pour=20la=20cr?= =?UTF-8?q?=C3=A9ation=20d'=C3=A9v=C3=A9nements?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- WEB/Controller/UserController.php | 10 ++++++++++ WEB/Model/UserModel.php | 25 ++++++++----------------- 2 files changed, 18 insertions(+), 17 deletions(-) diff --git a/WEB/Controller/UserController.php b/WEB/Controller/UserController.php index 7331bc7c..36bc9677 100644 --- a/WEB/Controller/UserController.php +++ b/WEB/Controller/UserController.php @@ -10,6 +10,7 @@ class UserController global $dsn, $rep, $vues, $error; $model = new UserModel(); $action = $_REQUEST['action']; + //register_event_handler('add_to_queue',array($this,"onAddToQueue")); switch ($action) { case NULL: $model->goToHome(); @@ -51,4 +52,13 @@ class UserController require($rep . $vues['erreur']); } } + public function onAddToQueue(){ + $model=new UserModel; + $model->AddUserToQueueEvent(); + $this->goToMulti(); + } + + /*public function goToMulti(){ + + }*/ } \ No newline at end of file diff --git a/WEB/Model/UserModel.php b/WEB/Model/UserModel.php index 8a57cfd7..32607d1c 100644 --- a/WEB/Model/UserModel.php +++ b/WEB/Model/UserModel.php @@ -97,15 +97,8 @@ class UserModel } public function addToQueue(){ echo '1'; - $userGroup=$this->utilisateur_gateway->findUsersInQueue(); if($this->utilisateur_gateway->isAlreadyInqueue($_SESSION['utilisateur'])) { - if ($this->utilisateur_gateway->queueFilled()) - { - echo "Partie is launched"; - $this->utilisateur_gateway->launchGame($_SESSION['utilisateur']); - } else - $this->attente(); return; } echo '2'; @@ -126,18 +119,16 @@ class UserModel } echo '8'; $this->utilisateur_gateway->addToQueue($_SESSION['utilisateur'],$partie); - echo '9'; - if ($this->utilisateur_gateway->queueFilled()) - { - echo "Partie is launched"; - trigger_event('queue_filled',$user_group,$partie,$user_group); - $this->utilisateur_gateway->launchGame($_SESSION['utilisateur']); - } - $this->attente(); + $userGroup=$this->utilisateur_gateway->findUsersInQueue(); + //trigger_event('add_to_queue',$userGroup); } - public function onQueueFilled{ - + public function AddUserToQueueEvent(){ + $userGroup=$this->utilisateur_gateway->findUsersInQueue(); + if($userGroup.count()>=4) + { + $this->utilisateur_gateway->launchGame(); + } } public function logout()