private function selectpartie() { try { //connexion à la BD $db = db::getInstance(); //Dans le cas où le joueur souhaite arbitrer la carte après une partie en tant que devin if (isset($_SESSION["idCard"]) && isset($_SESSION["idEnregistrement"])) { $idCarte = $_SESSION["idCard"]; $idEnregistrement = $_SESSION["idEnregistrement"]; $sql = "SELECT * FROM `enregistrement` WHERE `enregistrementID` = {$idEnregistrement}"; $db->query($sql); if ($db->num_rows() > 0) { $this->raisin = $db->fetch_object(); //why why why ça et adresse ? $this->enregistrement = "enregistrements/" . $this->raisin->cheminEnregistrement; // récupération du pseudo du joueur arbitré $sql = 'SELECT username FROM user WHERE userid ="' . $this->raisin->idOracle . '"'; $this->result = $db->query($sql); $this->res2 = mysqli_fetch_assoc($this->result); $this->card = new Card($_SESSION["idCard"], './views/card.inline.display.php'); //construction de l'adresse de l'enregistrement à partir du nom du fichier $this->adresse = "enregistrements/" . $this->raisin->cheminEnregistrement; $this->partie = true; unset($_SESSION["idCard"]); unset($_SESSION["idEnregistrement"]); return true; //two returns } else { array_push($this->errors, 'noEnregistrement'); } } else { $this->partie = false; $recordingFactory = new ItemFactory($this->druid, $this->userlang); $this->raisin = $recordingFactory->get_recording(ItemFactory::LIMBO_RECORDING_ME_IF_POSSIBLE); if (is_object($this->raisin) && file_exists("enregistrements/" . $this->raisin->cheminEnregistrement)) { //construction de l'adresse de l'enregistrement à partir du nom du fichier $this->adresse = "enregistrements/" . $this->raisin->cheminEnregistrement; $this->enregistrement = $this->raisin->enregistrementID; // récupération du pseudo du joueur arbitré $sql = 'SELECT username FROM user WHERE userid ="' . $this->raisin->idOracle . '"'; $this->result = $db->query($sql); $this->res2 = mysqli_fetch_assoc($this->result); //récupération de la carte jouée $this->card = new Card($this->raisin->carteID, './views/card.inline.display.php'); $this->partie = true; } else { //$this->partie reste faux array_push($this->errors, 'noEnregistrement'); } } } catch (Exception $e) { //$this->partie reste faux array_push($this->errors, 'noEnregistrement'); } return $this->partie; }
private function selectpartie() { $res = false; try { $recordingFactory = new ItemFactory($this->diviner, $this->userlang); $this->raisin = $recordingFactory->get_recording(ItemFactory::VALID_RECORDING_NOT_ME); if (is_object($this->raisin)) { // construction de l'adresse de l'enregistrement à partir du nom du fichier son $this->adresse = "enregistrements/" . $this->raisin->cheminEnregistrement; //On vérifie ici que l'enregistrement est bien sur le serveur if (file_exists($this->adresse)) { //récupération du contenu de la carte $carte = new Card($this->raisin->carteID); $this->card = $carte; // récupération du pseudo de l'oracle pour savoir qui on écoute $db = db::getInstance(); $sql = 'SELECT username FROM user WHERE userid ="' . $this->raisin->idOracle . '"'; if ($db->query($sql) && $db->num_rows() > 0) { $this->res2 = $db->fetch_assoc(); //récupération du pseudo du créateur de la carte $sql = 'SELECT username FROM user WHERE userid ="' . $this->card->get_author() . '"'; if ($db->query($sql) && $db->num_rows() > 0) { $this->res4 = $db->fetch_assoc(); $res = true; } else { throw new Exception("Pas pu récupérer le nom de l'auteur '{$this->raisin}->idOracle'"); } } else { throw new Exception("Pas pu récupérer le nom de l'oracle '" . $this->card->get_author() . "'"); } } } else { array_push($this->errors, 'NoGame'); } } catch (Exception $e) { array_push($this->errors, 'NoGame'); } $this->setcarteValide($res); return $res; }