Example #1
0
 /**
  * Renvoie l'altitude moyenne des voisins, sans les hexas de la couronne et sans les hexas d'altitude 0
  * @param Hexa $hexa
  * @param HexaCollection $couronne
  * @return float
  */
 public function altitudeMoyenneSansCouronne(Hexa $hexa, HexaCollection $couronne)
 {
     $altitudes = array();
     for ($angle = 0; $angle <= 5; $angle++) {
         $voisin = $hexa->getVoisin($angle);
         if (!is_null($voisin) && !$couronne->exists($voisin) && $voisin->getAltitude() > 0) {
             $altitudes[] = $voisin->getAltitude();
         }
     }
     if (count($altitudes) == 0) {
         return 0;
     }
     return array_sum($altitudes) / count($altitudes);
 }
Example #2
0
 /**
  *
  * @param Noeud $noeud
  * @return bool
  */
 public function objectifAtteint(Noeud $noeud)
 {
     if ($this->hexasInterdits->exists($noeud->getHexa())) {
         return false;
     }
     if ($this->but == self::BUT_RAVITAILLEMENT) {
         if ($noeud->getHexa()->getIdJoueur() == $this->pov->getId()) {
             return true;
         }
     } elseif ($this->but == self::BUT_COMMERCE) {
         if ($noeud->getHexa()->getIdTerritoire() == $this->pov->getId()) {
             return true;
         }
     } elseif ($this->but == self::BUT_VILLE_ENNEMIE) {
         if ($noeud->getHexa()->getIdJoueur() == $this->pov->getId()) {
             return true;
         }
     }
     return false;
 }