Ejemplo n.º 1
0
 /**
  * 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;
 }
Ejemplo n.º 2
0
 /**
  * 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);
             }
         }
     }
 }
Ejemplo n.º 3
0
 /**
  * @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;
 }
Ejemplo n.º 4
0
 /**
  * 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;
 }
Ejemplo n.º 5
0
 /**
  * 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;
 }
Ejemplo n.º 6
0
 /**
  * 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);
 }
Ejemplo n.º 7
0
 /**
  * @param Qg $qg
  */
 public function ajout(Qg $qg)
 {
     parent::ajout($qg);
     $qg->getMission()->setQgVirtuel($this);
 }