/** * Renvoie les Qgs liés aux Competences de cette collection * @return QgCollection */ public function getQgs() { if (is_null($this->cacheQgs)) { $this->cacheQgs = QgBusiness::getFromCompetences($this); $this->cacheQgs->store(); } return $this->cacheQgs; }
/** * Renvoie les Qgs liés à la collection * @return QgCollection */ public function getQgs() { if (is_null($this->cacheQgs)) { $this->cacheQgs = QgBusiness::getFromUtilisateurs($this); $this->cacheQgs->store(); } return $this->cacheQgs; }
/** * Renvoie les Competences liés aux Qgs de la collection fournie en paramètre * @param QgCollection $qgs * @return CompetenceCollection */ public static function getFromQgs(QgCollection $qgs) { $ids = $qgs->getIdsStr(); if (!$ids) { return new CompetenceCollection(); } $req = "SELECT * FROM competence WHERE idQg IN (" . $ids . ");"; return DbHandler::collFromQuery($req, 'Competence', 'CompetenceCollection'); }
/** * Renvoie les Hexas liés à une collection de Qgs * @param QgCollection $qgs * @return HexaCollection */ public static function getFromQgs(QgCollection $qgs) { $ids = $qgs->getIdHexas(); if (!$ids) { return new HexaCollection(); } $req = "SELECT * FROM hexa WHERE idHexa IN (" . $ids . ");"; return DbHandler::collFromQuery($req, 'Hexa', 'HexaCollection'); }
/** * @param Qg $qg * @return QgCollection|Qg[] * @throws Exception */ public static function getQgsOnSamePosition(Qg $qg) { $ret = new QgCollection(); if (!isset(self::$indexParHexa[$qg->getPosition()->getId()])) { return $ret; } if (!isset(self::$indexParHexa[$qg->getPosition()->getId()][$qg->getId()])) { throw new Exception("Qg not indexed : " . $qg->getId()); } foreach (self::$indexParHexa[$qg->getPosition()->getId()] as $autreQg) { /** @var Qg $autreQg */ if ($autreQg->getId() != $qg->getId()) { $ret->ajout($autreQg); } } return $ret; }
/** * Renvoie les Qgs liés à l'objet * @return QgCollection */ public function getQgs() { if (is_null($this->cacheQgs)) { $this->cacheQgs = QgBusiness::getByJoueur($this); $this->cacheQgs->store(); } return $this->cacheQgs; }
/** * Ajoute un Qg aux soutiens * @param Qg $qg * @return void * @throws \Exception */ public function ajout(Qg $qg) { if (!$qg instanceof Qg) { throw new \Exception("Bad Type"); } parent::ajout($qg); if (!isset($this->indexMissions[$qg->getIdTypeMission()])) { $this->indexMissions[$qg->getIdTypeMission()] = array(); } $this->indexMissions[$qg->getIdTypeMission()][] = $qg; }
/** * Ajoute à la carte les objets visibles reliés à un hexa * @param Hexa $hexa * @return void */ protected function ajoutVisiblesHexa(Hexa $hexa) { $this->visiblesGeres = true; if ($this->joueur->getVisibles()->hexaExists($hexa)) { // Qgs foreach ($hexa->getQgs() as $qg) { /** @var Qg $qg */ $this->qgs->ajout($qg); // Unites foreach ($qg->getUnites() as $unite) { /** @var Unite $unite */ $this->unites->ajout($unite); } } } }
/** * @param Qg $qg */ public function ajout(Qg $qg) { parent::ajout($qg); $qg->getMission()->setQgVirtuel($this); }
/** * Renvoie les Productions liés aux Qgs de la collection fournie * @var QgCollection $qgs * @return ProductionCollection */ public static function getFromQgs(QgCollection $qgs) { $req = "SELECT * from production WHERE idUnite IN (SELECT unite.idUnite FROM unite WHERE unite.idQg IN (" . $qgs->getIdsStr() . "))"; return DbHandler::collFromQuery($req, 'Production', 'ProductionCollection'); }
/** * Renvoie les Qgs dont this est dans la ZDC * @param Hexa $hexa * @return QgCollection * @throws \Exception */ public function inZdcDe(Hexa $hexa) { $ret = new QgCollection(); if (is_null($this->getIdJoueur())) { throw new \Exception("Qg " . $this->getId() . " has no Joueur"); } $qgs = $hexa->getCouronnePleine(Missions::getMaxTailleZdc())->getQgs(); foreach ($qgs as $qg) { if (is_null($qg->getIdJoueur())) { throw new \Exception("Qg " . $qg->getId() . " has no Joueur"); } if ($qg->getJoueur()->isEnnemi($this->getJoueur()) && $qg->getIdTypeMission() != Missions::RETRANCHEMENT && ($qg->getIdTypeQg() == $this->getIdTypeQg() || $this->getIdTypeQg() == Unites::TYPE_AMPHIBIE && ($qg->getIdTypeQg() == Unites::TYPE_TERRESTRE || $qg->getIdTypeQg() == Unites::TYPE_NAVAL)) && $qg->getHexa()->getCouronnePleine(Missions::$types[$qg->getIdTypeMission()]['tailleZone'])->exists($hexa)) { $ret->ajout($qg); } } return $ret; }
/** * Renvoie les Joueurs liés à une collection de Qgs * @param QgCollection $qgs * @return JoueurCollection */ public static function getFromQgs(QgCollection $qgs) { $ids = $qgs->getIdJoueurs(); if (!$ids) { return new JoueurCollection(); } $req = "SELECT * FROM joueur WHERE IdJoueur IN (" . $ids . ");"; return DbHandler::collFromQuery($req, 'Joueur', 'JoueurCollection'); }
/** * Ajout un Qg au cache de Qgs de this * @param Qg $qg * @return void */ public function addQgCache(Qg $qg) { if (is_null($this->cacheQgs)) { $this->cacheQgs = new QgCollection(); } $this->cacheQgs->ajout($qg); }
/** * Renvoie les Trajs liés aux Qgs de la collection fournie en paramètre * @param QgCollection $qgs * @return TrajCollection */ public static function getFromQgs(QgCollection $qgs) { return self::getFromIdsQgs($qgs->getIdsStr()); }
/** * @param QgCollection $qgs */ public function setQgs($qgs) { $this->qgs = $qgs; $qgs->getTrajs(); }
/** * Renvoie seulement les Qgs dont l'hexa fait partie des hexas fournis en paramètre * @param QgCollection $qgs * @return UniteCollection */ public function filtresParQgs(QgCollection $qgs) { $ret = new UniteCollection(); $ids = ',' . $qgs->getIdsStr() . ','; foreach ($this as $unite) { /** @var Unite $unite */ if (strstr($ids, ',' . $unite->getIdQg() . ',')) { $ret->ajout($unite); } } return $ret; }
/** * Renvoie la collection mais sans les Qgs dont le joueur fourni en paramètre n'a pas le droit de voir les trajectoire et les ordres * @param Joueur $joueur * @return QgCollection */ public function filterByDroitVoirTraj(Joueur $joueur) { $ret = new QgCollection(); foreach ($this as $qg) { /** @var Qg $qg */ if ($qg->droitVoirTraj($joueur)) { $ret->ajout($qg); } } return $ret; }
/** * Renvoie les Utilisateurs liés aux Qgs de la collection fournie * @var QgCollection $qgs * @return UtilisateurCollection */ public static function getFromQgs(QgCollection $qgs) { $req = "SELECT * FROM utilisateur WHERE idUtilisateur IN (SELECT joueur.idUtilisateur FROM joueur WHERE joueur.idJoueur IN (" . $qgs->getIdJoueurs() . "))"; return DbHandler::collFromQuery($req, 'Utilisateur', 'UtilisateurCollection'); }