Esempio n. 1
0
 /**
  * @param Qg $qg
  */
 public static function reindexQg(Qg $qg)
 {
     /** @var Hexa $oldPosition */
     if (isset(self::$indexParQg[$qg->getId()])) {
         $oldPosition = self::$indexParQg[$qg->getId()];
     } else {
         $oldPosition = null;
     }
     if (!is_null($oldPosition) && isset(self::$indexParHexa[$oldPosition->getId()][$qg->getId()])) {
         unset(self::$indexParHexa[$oldPosition->getId()][$qg->getId()]);
     }
     if (!$qg->isEfface()) {
         self::$indexParQg[$qg->getId()] = $qg->getPosition();
         if (!isset(self::$indexParHexa[$qg->getPosition()->getId()])) {
             self::$indexParHexa[$qg->getPosition()->getId()] = new QgCollection();
         }
         if (!isset(self::$indexParHexa[$qg->getPosition()->getId()][$qg->getId()])) {
             self::$indexParHexa[$qg->getPosition()->getId()][$qg->getId()] = $qg;
         }
     }
     /*
      * Zones d'interception
      */
     if (in_array($qg->getIdTypeMission(), Missions::missionsInterception())) {
         foreach ($qg->getPosition()->getCouronnePleine(Missions::$types[Missions::INTERCEPTION]['tailleZone']) as $hexa) {
             if (!isset(self::$indexIntercepteurs[$hexa->getId()])) {
                 self::$indexIntercepteurs[$hexa->getId()] = new QgCollection();
             }
             self::$indexIntercepteurs[$hexa->getId()]->ajout($qg);
         }
     }
 }
Esempio n. 2
0
 public function carte()
 {
     if (!$this->checkDroit(Droit::LOGGE_PARTIE)) {
         header('Location: ' . Conf::common()['url']['base'] . '/index.php?page=Accueil&action=parties');
         exit;
     }
     $this->getMenu()->setJeu('carte');
     /**
      * Données
      */
     $url = 'http://nj.leparquier.fr:' . SessionBusiness::getCookieSession()->getPartie()->getPort() . '/JsonCarte';
     $idCentre = SessionBusiness::getCookieSession()->getJoueur()->getCapitale()->getId();
     $ch = curl_init();
     curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
     curl_setopt($ch, CURLOPT_URL, $url);
     curl_setopt($ch, CURLOPT_POST, true);
     curl_setopt($ch, CURLOPT_POSTFIELDS, "idCentre=" . $idCentre . "&largeur=11&hauteur=9&token=" . SessionBusiness::getCookieSession()->getToken());
     $result = curl_exec($ch);
     curl_close($ch);
     $this->data['dataDyn'] = $result;
     $this->data['typesUnites'] = json_encode(Unites::getArrayIndexesId());
     $this->data['typesTerrains'] = json_encode(Terrains::getArrayIndexesId());
     $this->data['typesMissions'] = json_encode(Missions::getArrayIndexesId());
     $this->data['PORT_PARTIE'] = SessionBusiness::getCookieSession()->getPartie()->getPort();
     $this->data['idCentre'] = $idCentre;
     /**
      * Templates
      */
     $this->data['tpl_case'] = $this->getTemplateStr('elements/infosCarte/case.php');
     $this->data['tpl_proprioCase'] = $this->getTemplateStr('elements/infosCarte/proprioCase.php');
     $this->data['tpl_qg'] = $this->getTemplateStr('elements/infosCarte/qg.php');
     $this->data['tpl_unite'] = $this->getTemplateStr('elements/infosCarte/qg_unites.php');
     $this->data['tpl_totalMvtQg'] = $this->getTemplateStr('elements/infosCarte/totalMvtQg.php');
     $this->data['tpl_riviere'] = $this->getTemplateStr('elements/infosCarte/riviere.php');
     $this->data['tpl_infraCase'] = $this->getTemplateStr('elements/infosCarte/infraCase.php');
     $this->data['tpl_loading'] = $this->fetch('elements/cadres/loading.php');
     $this->data['DROIT_ADMIN'] = $this->checkDroit(Droit::ADMIN);
     $this->display('pages/Jeu/Carte.php');
 }
Esempio n. 3
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;
 }
Esempio n. 4
0
<ul>
    <?php 
use fr\gilman\nj\common\rules\Missions;
foreach (Missions::getDansOrdreResolution() as $ordre => $mission) {
    ?>
        <li><?php 
    echo $mission['ordreResolution'];
    ?>
. <?php 
    echo ucfirst($mission['nom']);
    ?>
</li>
    <?php 
}
?>
</ul>
Esempio n. 5
0
 /**
  * Résoud les déplacements des Qgs et les combats
  * @return void
  */
 public function resolve()
 {
     Log::getInstance()->debug(array('msg' => 'qgsAvantDeplacement', 'qgs' => $this->qgs->debug()));
     $intercepteurs = new QgCollection();
     foreach ($this->qgs as $qg) {
         $qg->getMission()->beforeDeplacements();
     }
     foreach ($this->qgs->getByMission() as $idTypeMission => $qgs) {
         if (in_array($idTypeMission, Missions::missionsInterception())) {
             $intercepteurs = $qgs;
         }
         if (!in_array($idTypeMission, Missions::missionsDeplacement())) {
             continue;
         }
         $maxVitesse = $qgs->maxVitesse(true);
         for ($pas = 1; $pas <= $maxVitesse; $pas++) {
             Log::getInstance()->debug(array('msg' => 'pas', 'idTypeMission' => $idTypeMission, 'pas' => $pas));
             /*
              * Pas et interceptions
              */
             foreach ($qgs as $qg) {
                 /** @var Qg $qg */
                 $qg->getMission()->pas($maxVitesse);
                 /*
                  * Zones d'interception
                  */
                 if ($qg->getMission()->isInterceptable() && IndexPositions::getIntercepteursOnSamePosition($qg)->count()) {
                     foreach (IndexPositions::getIntercepteursOnSamePosition($qg) as $intercepteur) {
                         if ($qg->getJoueur()->isEnnemi($intercepteur->getJoueur())) {
                             /** @var Interception $mission */
                             $mission = $intercepteur->getMission();
                             $mission->getCiblesPotentielles()->ajout($qg);
                         }
                     }
                 }
             }
             /*
              * Interceptions (combat)
              */
             $interceptions = new CombatCollection();
             foreach ($intercepteurs as $intercepteur) {
                 /** @var Qg $intercepteur */
                 $mission = $intercepteur->getMission();
                 /** @var Interception $mission */
                 $combat = $mission->createCombat();
                 if (!is_null($combat)) {
                     $interceptions->ajout($combat);
                 }
             }
             $interceptions->run();
             /*
              * Combats
              */
             $this->combatsAFaire()->run();
         }
         /*
          * Stacks à gérer en fin de déplacements
          */
         $recul = true;
         while ($recul) {
             $recul = false;
             foreach (IndexPositions::getStacks() as $stack) {
                 foreach ($stack->qgsQuiDoiventBouger() as $qg) {
                     /** @var Qg $qg */
                     $qg->getMission()->recul();
                 }
                 $recul = true;
             }
             IndexPositions::reset();
             foreach ($this->qgs as $qg) {
                 IndexPositions::reindexQg($qg);
             }
             $this->combatsAFaire()->run();
         }
     }
     foreach ($this->qgs as $qg) {
         $qg->getMission()->afterDeplacements();
     }
     Log::getInstance()->debug(array('msg' => 'qgsApresDeplacement', 'qgs' => $this->qgs->debug()));
 }
Esempio n. 6
0
 /**
  * @return bool
  */
 public function isInterceptable()
 {
     return in_array($this->getQg()->getIdTypeMission(), Missions::missionsInterceptables()) || $this->getQg()->getIdTypeMission() == Missions::DEPLACEMENT && $this->getQg()->getIdTypeQg() == Unites::TYPE_AERIEN;
 }