Ejemplo n.º 1
0
 /**
  * @param QgVirtuel $qg
  * @return MissionVirtuelle
  */
 public static function factory(QgVirtuel $qg)
 {
     switch ($qg->getIdTypeMission()) {
         case Missions::APPUI_SOL:
             return new AppuiSol($qg);
             break;
         case Missions::ASSAUT:
             return new Assaut($qg);
             break;
         case Missions::ASSAUT_AERONAVAL:
             return new AssautAeronaval($qg);
             break;
         case Missions::ASSAUT_NAVAL:
             return new AssautNaval($qg);
             break;
         case Missions::ASW:
             return new Asw($qg);
             break;
         case Missions::BLITZ:
             return new Blitz($qg);
             break;
         case Missions::BLOCUS:
             return new Blocus($qg);
             break;
         case Missions::BOMBARDEMENT:
             return new Bombardement($qg);
             break;
         case Missions::DEPLACEMENT:
             return new Deplacement($qg);
             break;
         case Missions::ESCORTE:
             return new Escorte($qg);
             break;
         case Missions::INTERCEPTION:
             return new Interception($qg);
             break;
         case Missions::INTERDICTION:
             return new Interdiction($qg);
             break;
         case Missions::PILONNAGE:
             return new Pilonnage($qg);
             break;
         case Missions::REPOS:
             return new Repos($qg);
             break;
         case Missions::RETRANCHEMENT:
             return new Retranchement($qg);
             break;
         case Missions::TORPILLAGE:
             return new Torpillage($qg);
             break;
         default:
             return new Repos($qg);
     }
 }
Ejemplo n.º 2
0
 /**
  *
  * @param QgVirtuel $adversaire
  */
 public function determineIsAttaquant(QgVirtuel $adversaire)
 {
     foreach ($this as $qg) {
         /** @var Qg $qg */
         if (!$qg->isMissionMouvement()) {
             $this->cacheisAttaquant = false;
         }
     }
     if (is_null($this->cacheisAttaquant)) {
         if ($this->getVitesse() < $adversaire->getVitesse()) {
             $this->cacheisAttaquant = true;
         } elseif ($this->getVitesse() > $adversaire->getVitesse()) {
             $this->cacheisAttaquant = false;
         } else {
             if ($this->getMoral() < $adversaire->getMoral()) {
                 $this->cacheisAttaquant = true;
             } elseif ($this->getMoral() > $adversaire->getMoral()) {
                 $this->cacheisAttaquant = false;
             } else {
                 if ($this->getCapop() < $adversaire->getCapop()) {
                     $this->cacheisAttaquant = true;
                 } elseif ($this->getCapop() > $adversaire->getCapop()) {
                     $this->cacheisAttaquant = false;
                 } else {
                     if (rand(0, 1)) {
                         $this->cacheisAttaquant = true;
                     } else {
                         $this->cacheisAttaquant = false;
                     }
                 }
             }
         }
     }
     $adversaire->setCacheisAttaquant(!$this->cacheisAttaquant);
 }