Esempio n. 1
0
 /**
  * @return void
  */
 public function main()
 {
     $ret = array('error' => 0, 'errorMsg' => '');
     while (true) {
         if (is_null($this->getHttp()->getPost('idCentre')) || is_null($this->getHttp()->getPost('largeur')) || is_null($this->getHttp()->getPost('hauteur'))) {
             $ret['error'] = 1;
             $ret['errorMsg'] = "Données manquantes";
             break;
         }
         $token = null;
         if (!is_null($this->getHttp()->getCookie('token'))) {
             $token = $this->getHttp()->getCookie('token');
         } elseif ($this->getHttp()->getGet('token')) {
             $token = $this->getHttp()->getGet('token');
         } elseif ($this->getHttp()->getPost('token')) {
             $token = $this->getHttp()->getPost('token');
         }
         if (is_null($token)) {
             $ret['error'] = 2;
             $ret['errorMsg'] = "Pas de token de session";
             break;
         }
         $session = SessionStore::getByToken($token);
         $carte = new Carte($session->getPartie(), HexaStore::getById($this->getHttp()->getPost('idCentre')), $session->getJoueur(), $this->getHttp()->getPost('largeur'), $this->getHttp()->getPost('hauteur'));
         $this->output($carte->getJson());
         break;
     }
 }
Esempio n. 2
0
 /**
  * @return void
  */
 public function main()
 {
     $ret = array('error' => 0, 'errorMsg' => '', 'debug' => '');
     while (true) {
         if (is_null($this->getHttp()->getGet('idUnite'))) {
             $ret['error'] = 1;
             $ret['errorMsg'] = "Données manquantes (idUnite)";
             break;
         }
         $idUnite = $this->getHttp()->getGet('idUnite');
         $token = null;
         if (!is_null($this->getHttp()->getCookie('token'))) {
             $token = $this->getHttp()->getCookie('token');
         } elseif ($this->getHttp()->getGet('token')) {
             $token = $this->getHttp()->getGet('token');
         } elseif ($this->getHttp()->getPost('token')) {
             $token = $this->getHttp()->getPost('token');
         }
         if (is_null($token)) {
             $ret['error'] = 2;
             $ret['errorMsg'] = "Pas de token de session";
             break;
         }
         $session = SessionStore::getByToken($token);
         $unite = UniteStore::getById($idUnite);
         if (is_null($unite)) {
             $ret['error'] = 2;
             $ret['errorMsg'] = "Unite inconnue";
             break;
         }
         if ($unite->getQg()->getIdJoueur() != $session->getIdJoueur()) {
             $ret['error'] = 3;
             $ret['errorMsg'] = "Unite inconnue";
             break;
         }
         $nlleUnite = UniteBusiness::getById($idUnite);
         $unite->setIdQgTransfert($nlleUnite->getIdQgTransfert());
         $unite->resetJson();
         CacheCarte::$infosVisibles = array();
         break;
     }
     $this->output('rienDuTout(' . json_encode($ret) . ');');
 }