/** * Renvoie les Batiments liés aux Hexas de la collection fournie en paramètre * @param HexaCollection $hexas * @return BatimentCollection */ public static function getFromHexas(HexaCollection $hexas) { $ids = $hexas->getIdsStr(); if (!$ids) { return new BatimentCollection(); } $req = "SELECT * FROM batiment WHERE idHexa IN (" . $ids . ");"; return DbHandler::collFromQuery($req, 'Batiment', 'BatimentCollection'); }
/** * Renvoie les Visibles liés aux Hexas de la collection fournie en paramètre * @param HexaCollection $hexas * @param Joueur $joueur Ne fournit que les visiles de ce joueur pour la collection d'hexas * @return VisibleCollection */ public static function getFromHexas(HexaCollection $hexas, Joueur $joueur = null) { $ids = $hexas->getIdsStr(); if (!$ids) { return new VisibleCollection(); } $req = "SELECT * FROM visible WHERE idHexa IN (" . $ids . ")"; if (!is_null($joueur)) { $req .= " AND idJoueur = " . $joueur->getId(); } $req .= ";"; return DbHandler::collFromQuery($req, 'Visible', 'VisibleCollection'); }
/** * Renvoie les Infrastructures liés aux Hexas de la collection fournie en paramètre * @param HexaCollection $hexas * @return InfrastructureCollection */ public static function getFromHexas(HexaCollection $hexas) { return self::getFromIdsHexas($hexas->getIdsStr(true)); }
/** * Renvoie les Productions liés aux Hexas de la collection fournie * @var HexaCollection $hexas * @return ProductionCollection */ public static function getFromHexas(HexaCollection $hexas) { $req = "SELECT * from production WHERE idBatiment IN (SELECT batiment.idBatiment FROM batiment WHERE batiment.idHexa IN (" . $hexas->getIdsStr() . "))"; return DbHandler::collFromQuery($req, 'Production', 'ProductionCollection'); }
/** * Renvoie les Competences liés aux Hexas de la collection fournie * @var HexaCollection $hexas * @return CompetenceCollection */ public static function getFromHexas(HexaCollection $hexas) { $req = "SELECT * from competence WHERE idQg IN (SELECT qg.idQg FROM qg WHERE qg.idHexa IN (" . $hexas->getIdsStr() . "))"; return DbHandler::collFromQuery($req, 'Competence', 'CompetenceCollection'); }
/** * Renvoie les Trajectoires entières qui ont au moins 1 case dans $hexas * @param HexaCollection $hexas * @return TrajCollection */ public static function getEntieresFromHexas(HexaCollection $hexas) { $ids = $hexas->getIdsStr(); if (!$ids) { return new TrajCollection(); } $req = "SELECT * FROM traj WHERE idQg IN (SELECT DISTINCT(sousTraj.idQg) FROM traj sousTraj WHERE sousTraj.idHexa IN (" . $ids . "));"; return DbHandler::collFromQuery($req, 'Traj', 'TrajCollection'); }