/** * 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 * @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 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 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; }
/** * 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); }
/** * @param Qg $qg */ public function ajout(Qg $qg) { parent::ajout($qg); $qg->getMission()->setQgVirtuel($this); }