Esempio n. 1
0
 public function parties()
 {
     $this->getMenu()->setAccueil('parties');
     if (!$this->checkDroit(Droit::PARTIE)) {
         $this->error("Vous devez être connecté pour voir les parties");
         return;
     }
     $this->data['parties'] = PartieBusiness::partiesActives();
     $this->display('pages/Accueil/Parties.php');
 }
Esempio n. 2
0
 /**
  * @return void
  */
 public function main()
 {
     $ret = array('error' => 0, 'errorMsg' => '');
     while (true) {
         if (is_null($this->getHttp()->getPost('password'))) {
             $ret['error'] = 1;
             $ret['errorMsg'] = "Password obligatoire";
             break;
         }
         if ($this->getHttp()->getPost('password') != Conf::common()['server']['passwordAdmin']) {
             $ret['error'] = 2;
             $ret['errorMsg'] = "Mauvais password";
             break;
         }
         BaseStore::reset();
         JsonServer::getIntance()->setPartie(PartieBusiness::GetById(JsonServer::getIntance()->getPartie()->getId()));
         JsonServer::getIntance()->getPartie()->warm();
         CacheCarte::reset();
         break;
     }
     $this->output(json_encode($ret));
 }
Esempio n. 3
0
 /**
  * Renvoie le prochain port libre pour un serveur de partie
  * @return int
  */
 public function getPortLibre()
 {
     $cpt = (int) Conf::common()['server']['port'];
     $cpt++;
     foreach (PartieBusiness::partiesActives() as $partie) {
         /** @var Partie $partie */
         $cpt++;
         if ($partie->getPort() != $cpt) {
             break;
         }
     }
     return $cpt;
 }
Esempio n. 4
0
/**
 * Démarre le serveur
 */
function start()
{
    foreach (PartieBusiness::partiesActives() as $partie) {
        /** @var Partie $partie */
        popen(SCRIPT_TO_LAUNCH . '=' . $partie->getId() . ' >> ' . Conf::common()['path']['serverLogs'] . '/' . $partie->getId() . '.log 2>&1 &', 'r');
    }
}
Esempio n. 5
0
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();
}
function autoload_client($class)
{
    if (strstr($class, 'fr\\gilman\\nj\\client')) {
        require_once dirname(__FILE__) . str_replace('\\', '/', str_replace('fr\\gilman\\nj\\client', '', $class)) . '.php';
    }
}
Esempio n. 6
0
 /**
  * Renvoie les Parties liés aux Joueurs de cette collection
  * @return PartieCollection
  */
 public function getParties()
 {
     if (is_null($this->cacheParties)) {
         $this->cacheParties = PartieBusiness::getFromJoueurs($this);
         $this->cacheParties->store();
     }
     return $this->cacheParties;
 }