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()