/**
  * @param Hexa $hexa1
  * @param Hexa $hexa2
  * @return Riviere
  */
 public static function getByHexas(Hexa $hexa1, Hexa $hexa2)
 {
     $index = min($hexa1->getId(), $hexa2->getId()) . '_' . max($hexa1->getId(), $hexa2->getId());
     if (isset(self::$indexByHexas[$index])) {
         return self::$indexByHexas[$index];
     } else {
         $riviere = RiviereBusiness::getEntre2Hexas($hexa1, $hexa2);
         if (is_null($riviere)) {
             self::$indexByHexas[$index] = null;
         } else {
             self::store($riviere);
         }
         return $riviere;
     }
 }
Exemple #2
0
 /**
  * Combat constructor.
  * @param Hexa $hexa
  */
 public function __construct(Hexa $hexa)
 {
     $this->hexa = $hexa;
     $this->attaquants = new QgVirtuel();
     $this->defenseurs = new QgVirtuel();
     $this->spectateurs = new QgCollection();
     Log::getInstance()->debug(array('msg' => 'combat construct', 'hexa' => $hexa->getId()));
 }
 /**
  * Renvoie le pont entre 2 hexas ou null si aucun n'est trouvé
  * @param Hexa $hexa1
  * @param Hexa $hexa2
  * @return Infrastructure De type pont
  */
 public static function getPontEntre2Hexas(Hexa $hexa1, Hexa $hexa2)
 {
     $req = "SELECT * FROM infrastructure WHERE (idHexa='" . $hexa1->getId() . "' AND idHexa2='" . $hexa2->getId() . "') OR (idHexa2='" . $hexa1->getId() . "' AND idHexa='" . $hexa2->getId() . "') AND idType=" . Infrastructures::PONT . ";";
     return DbHandler::objFromQuery($req, 'Infrastructure');
 }
Exemple #4
0
 /**
  * @param Hexa $hexa1
  * @param Hexa $hexa2
  * @return string
  */
 public static function getIndexCouple(Hexa $hexa1, Hexa $hexa2)
 {
     return min($hexa1->getId(), $hexa2->getId()) . '_' . max($hexa1->getId(), $hexa2->getId());
 }
 /**
  * Dit si un hexa est repésenté dans les visibles de la collection
  * @param Hexa $hexa
  * @return bool
  */
 public function hexaExists(Hexa $hexa)
 {
     return isset($this->indexParHexa[$hexa->getId()]);
 }
 /**
  * @param Hexa $hexa
  * @param int $enConstruction
  * @return BaseCollection
  */
 public static function getByHexaDOrigine(Hexa $hexa, $enConstruction = null)
 {
     $req = "SELECT * FROM unite WHERE idHexaConstruit = " . $hexa->getId() . " ";
     if (!is_null($enConstruction)) {
         $req .= " AND enConstruction = " . $enConstruction . " ";
     }
     $req .= ";";
     return DbHandler::collFromQuery($req, 'Unite', 'UniteCollection');
 }
Exemple #7
0
 function jsonSerialize()
 {
     return array('noPassageDebordement' => $this->noPassageDebordement, 'hexa' => is_null($this->hexa) ? 0 : $this->hexa->getId(), 'provenance' => is_null($this->provenance) ? 0 : $this->provenance->getId());
 }
 /**
  * Dit si une infra est storée pour les 2 hexas fournis
  * @param Hexa $hexa1
  * @param Hexa $hexa2
  * @return bool
  */
 public static function existsByHexas(Hexa $hexa1, Hexa $hexa2)
 {
     $index = min($hexa1->getId(), $hexa2->getId()) . '_' . max($hexa1->getId(), $hexa2->getId());
     return isset(self::$indexByHexas[$index]);
 }