/**
  * Met les Parties de la collection dans le PartieStore
  * Vérifie si le Partie était déjà storé, dans ce cas, remplace le Partie concerné par celui du PartieStore
  */
 public function store()
 {
     $replaces = array();
     foreach ($this as $offset => $partie) {
         /** @var Partie $partie */
         if (PartieStore::exists($partie->getId())) {
             $replaces[$offset] = $partie;
         } else {
             PartieStore::store($partie);
         }
     }
     unset($offset);
     foreach ($replaces as $offset => $partie) {
         $this->offsetSet($offset, PartieStore::getById($partie->getId()));
     }
 }
Beispiel #2
0
 /**
  * Génère entièrement la carte
  */
 public function genererHexas()
 {
     PartieStore::store($this);
     $this->genererHexasVierges();
     $this->genererGermes();
     $this->cotesEnDentelle();
     $this->erosionMontagnes();
     $this->genererTemperatures();
     $this->creerRivieres();
     $this->genererVegetation();
     $this->lisserTemperatures();
     $this->lisserAltitudes();
     $this->lisserVegetation();
     foreach ($this->getHexas() as $hexa) {
         /** @var Hexa $hexa */
         HexaBusiness::insert($hexa);
     }
 }
Beispiel #3
0
 /**
  * Renvoie le Partie lié
  * @return Partie
  */
 public function getPartie()
 {
     return PartieStore::getById(JoueurStore::getById($this->getIdJoueur())->getIdPartie());
 }
Beispiel #4
0
#!/usr/bin/php
<?php 
namespace fr\gilman\nj;

use fr\gilman\nj\common\bb\DbHandler;
use fr\gilman\nj\common\bb\store\PartieStore;
use fr\gilman\nj\server\Conf;
use fr\gilman\nj\server\JsonServer;
use Ratchet\Server\IoServer;
use Ratchet\Http\HttpServer;
require dirname(__FILE__) . '/vendor/autoload.php';
require_once dirname(__FILE__) . '/models/Conf.php';
Conf::initCommon(dirname(__FILE__) . '/common.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']);
$options = getopt('', array("idPartie:"));
if (!isset($options['idPartie'])) {
    echo "Paramètre idPartie obligatoire\n";
    exit;
}
$jsonServer = JsonServer::getIntance();
$jsonServer->setPartie(PartieStore::getById($options['idPartie']));
$jsonServer->getPartie()->warm();
$server = IoServer::factory(new HttpServer($jsonServer), $jsonServer->getPartie()->getPort());
$server->run();
Beispiel #5
0
 /**
  * Renvoie le Partie lié
  * @return Partie
  */
 public function getPartie()
 {
     return PartieStore::getById(HexaStore::getById($this->getIdHexa())->getIdPartie());
 }
Beispiel #6
0
 public function partie()
 {
     $this->getMenu()->setAccueil('parties');
     if (!isset($_GET['idPartie'])) {
         $this->error("Paramètre idPartie obligatoire");
         return;
     }
     $this->data['partie'] = PartieStore::getById($_GET['idPartie']);
     $hexas = PartieStore::getById($_GET['idPartie'])->getHexas();
     $rivieres = PartieStore::getById($_GET['idPartie'])->getRivieres();
     $rivieres->addToCacheHexas();
     $this->data['dataHexas'] = json_encode($hexas);
     $this->display('pages/Accueil/Partie.php');
 }