コード例 #1
0
ファイル: Combat.php プロジェクト: eleparquier/nj_common
 /**
  * Déroule le combat
  * @return void
  */
 public function run()
 {
     while (!$this->termine) {
         $this->tour++;
         if ($this->getAttaquants()->getNbMaxToursDeCombat() != 0 && $this->tour > $this->getAttaquants()->getNbMaxToursDeCombat()) {
             break;
         }
         Log::getInstance()->debug(array('msg' => 'combatRun', $this->debug()));
         $this->testMoral();
         if ($this->termine) {
             break;
         }
         $this->tour();
     }
     foreach ($this->attaquants as $qg) {
         IndexPositions::reindexQg($qg);
     }
     foreach ($this->defenseurs as $qg) {
         IndexPositions::reindexQg($qg);
     }
 }
コード例 #2
0
 /**
  * Détermine quels seront les combats en fonction des collisions
  * @return CombatCollection
  */
 public function combatsAFaire()
 {
     $ret = new CombatCollection();
     foreach (IndexPositions::getHexasAvecCollisions() as $qgsEnPosition) {
         $combat = $qgsEnPosition->createCombat();
         if (!is_null($combat)) {
             $ret->ajout($combat);
         }
     }
     Log::getInstance()->debug(array('msg' => 'combatsAFaire', 'o' => $ret->debug()));
     return $ret;
 }
コード例 #3
0
ファイル: Mission.php プロジェクト: eleparquier/nj_common
 /**
  * Fait faire un pas au qg
  * @param $maxVitesse
  */
 public function pas($maxVitesse)
 {
     if ($this->modeTrajectoire) {
         $this->mvtDepensePartiel += $this->getQg()->getMvtTotal() / $maxVitesse;
         $coutProchaineCase = $this->getQg()->getCoutDeplacement($this->getPosition(), $this->nextTraj->getHexa());
         if ($this->mvtDepensePartiel >= $coutProchaineCase || $this->mvtDepenseTotal < $this->getQg()->getMvtTotal() && $this->mvtDepenseTotal + $coutProchaineCase >= $maxVitesse) {
             // Avancement d'une case
             $this->historiquePositions->ajout($this->nextTraj->getHexa());
             $nextTraj = $this->getQg()->getTrajs()->getByOrdre($this->nextTraj->getOrdre() + 1);
             if (!is_null($nextTraj)) {
                 $this->nextTraj = $nextTraj;
             } else {
                 $this->modeTrajectoire = false;
             }
             $this->incrMvtDepensePartiel(-1 * $coutProchaineCase);
             $this->incrMvtDepenseTotal($coutProchaineCase);
             IndexPositions::reindexQg($this->getQg());
             $this->auMoinsUnDeplacementFait = true;
         }
     }
 }