Пример #1
0
 /**
  * Fait une retraite pour le QG
  * @return void
  */
 public function retraite()
 {
     Log::getInstance()->debug(array('msg' => 'retraite', 'qg' => $this->getId()));
     if ($this->getTrajectoireRavitaillement()->isPossible()) {
         $destination = $this->getMission()->choixHexaReculForce();
         Log::getInstance()->debug(array('msg' => 'retraite', 'destination' => $destination->getId()));
         if ($destination->getQgs()->count()) {
             $this->dissolution();
         } else {
             // Déplace le Qg vers son point de retraite
             $this->setIdHexa($destination->getId());
             $this->setIdTypeMission(Missions::REPOS);
             $this->save();
             $this->getMission()->setAuMoinsUnDeplacementFait(true);
             $this->resetMission();
         }
     } else {
         $this->dissolution();
     }
     $this->resetMission();
 }
Пример #2
0
#!/usr/bin/php
<?php 
use fr\gilman\nj\client\models\Conf;
use fr\gilman\nj\common\admin\Log;
use fr\gilman\nj\common\bb\DbHandler;
error_reporting(E_ALL);
ini_set("display_errors", 1);
try {
    spl_autoload_register('autoload_client');
    Conf::initCommon(dirname(__FILE__) . '/common.ini');
    Conf::initPath(dirname(__FILE__) . '/path.ini');
    require_once Conf::common()['path']['commonClasses'] . '/inc.php';
    DbHandler::connect(Conf::common()['DB']['HOST'], Conf::common()['DB']['DB'], Conf::common()['DB']['USER'], Conf::common()['DB']['PASS']);
    Log::getInstance()->setPath(Conf::path()['logs']['path']);
    Log::getInstance()->setDebugPath(Conf::path()['logs']['debugPath']);
    Log::getInstance()->setDebugMode(Conf::path()['logs']['debug']);
    //DbHandler::update('TRUNCATE qg;');
    //DbHandler::update('TRUNCATE traj;');
    //DbHandler::update('TRUNCATE unite;');
    //DbHandler::insert("INSERT INTO nj.qg (idJoueur, idHexa, nom, capop, xp, niveau, idTypeMission, idTypeQg, idCibleMission) VALUES (2, 844, 'id 1', 100, 0, 1, 1, 1, 2);");
    //DbHandler::insert("INSERT INTO nj.qg (idJoueur, idHexa, nom, capop, xp, niveau, idTypeMission, idTypeQg, idCibleMission) VALUES (6, 876, 'id 2', 100, 0, 1, 1, 1, 0);");
    //DbHandler::insert("INSERT INTO nj.qg (idJoueur, idHexa, nom, capop, xp, niveau, idTypeMission, idTypeQg, idCibleMission) VALUES (2, 875, 'id 3', 100, 0, 1, 3, 1, 0);");
    //DbHandler::insert("INSERT INTO nj.unite (idQg, idType, nom, xp, moral, idHexaConstruit, enConstruction, idQgTransfert) VALUES (1, 1, 'Infanterie I', 0, 100, 0, 0, 0);");
    //DbHandler::insert("INSERT INTO nj.unite (idQg, idType, nom, xp, moral, idHexaConstruit, enConstruction, idQgTransfert) VALUES (2, 1, 'Infanterie I', 0, 100, 0, 0, 0);");
    //DbHandler::insert("INSERT INTO nj.unite (idQg, idType, nom, xp, moral, idHexaConstruit, enConstruction, idQgTransfert) VALUES (3, 1, 'Infanterie I', 0, 100, 0, 0, 0);");
    //DbHandler::insert("INSERT INTO nj.traj(idQg, idHexa, ordre) VALUES(1,875,1);");
    //DbHandler::insert("INSERT INTO nj.traj(idQg, idHexa, ordre) VALUES(2,875,1);");
    \fr\gilman\nj\common\bb\business\PartieBusiness::getById(2)->nouveauTour();
} catch (Exception $e) {
    echo utf8_decode($e->getMessage()) . "\n" . $e->getTraceAsString();
}
Пример #3
0
 /**
  * Résout un tour de combat
  * @return void
  */
 public function tour()
 {
     $rapport = $this->getAttaquants()->getAssaut() / $this->getDefenseurs()->getResistance();
     $d6_2 = rand(1, 6) + rand(1, 6);
     Log::getInstance()->debug(array('msg' => 'tourCombat', 'tour' => $this->tour, 'rapport' => $rapport, '2D6' => $d6_2));
     Log::getInstance()->debug(array('msg' => 'modifAtt', 'o' => Combats::getModificateurs(Combats::ATTAQUE, $rapport, $d6_2)));
     Log::getInstance()->debug(array('msg' => 'modifDef', 'o' => Combats::getModificateurs(Combats::DEFENSE, $rapport, $d6_2)));
     $this->getAttaquants()->appliquerModificateurs(Combats::getModificateurs(Combats::ATTAQUE, $rapport, $d6_2));
     $this->getDefenseurs()->appliquerModificateurs(Combats::getModificateurs(Combats::DEFENSE, $rapport, $d6_2));
 }
Пример #4
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;
 }
Пример #5
0
 /**
  * @param Modificateurs $modificateurs
  */
 public function appliquerModificateurs(Modificateurs $modificateurs)
 {
     $modificateurs = $this->getMission()->getModifCombat()->get($modificateurs);
     Log::getInstance()->debug(array('msg' => 'modifCombat', 'isAttaquant' => $this->isAttaquant(), 'modificateurs' => $modificateurs));
     foreach ($this->getUnitesActives() as $unite) {
         /** @var Unite $unite */
         $unite->setMoral($unite->getMoral() + $modificateurs->moral);
     }
     foreach ($this as $qg) {
         /** @var Qg $qg */
         $qg->setCapop($qg->getCapop() + $modificateurs->capop);
         Log::getInstance()->debug(array('msg' => 'qgApresModif', 'qg' => $qg->debug()));
     }
 }