/** * * Le joueur de l'environnement rejoind la partie /!\ SI PAS DEJA FAIT * ou créer un invité * @return Slot */ public function rejoindre() { Env::requiert('partie'); Env::requiert('jeu'); if (!joueur()) { Joueur::connecterInvite(); } // Refus de rejoindre si la partie n'est plus en préparation et n'est pas une room non plus. if ($this->etat != PARTIE::PREPARATION && !jeu()->isRoom()) { throw new Exception('Trop tard pour rejoindre cette partie. (code etat partie : ' . $this->etat . ')'); } $slot = $this->hasJoueur(joueur()); if (!is_null($slot)) { return $slot; } $s = new Slot(); $s->partie_id = $this->getID(); $s->joueur_id = joueur()->getID(); $s->position = count($this->slots) + 1; $s->save(); $this->slots[] = $s; return $s; }