<?php if (!isset($_SESSION)) { session_start(); } require_once 'initClass.php'; require_once 'init.php'; if (isset($_SESSION['idJoueurCourant']) && $_SESSION['idJoueurCourant'] != '') { $JoueurManager = new JoueurManager($db); $Joueur = new Joueur($JoueurManager->get($_SESSION['idJoueurCourant'])); $listePersonnage = $JoueurManager->getListePersonnageFromJoueur($Joueur->getId()); $PersonnageManager = new PersonnageManager($db); $Personnages = array(); $i = 0; if (count($listePersonnage) > 0) { foreach ($listePersonnage as $key => $item) { if (!isset($_SESSION['personnageCourant'])) { if ($i == 0) { $_SESSION['personnageCourant'] = $item->id; } else { $Personnages[] = new Personnage($PersonnageManager->get($item->id)); } } else { if ($item->id != $_SESSION['personnageCourant']) { $Personnages[] = new Personnage($PersonnageManager->get($item->id)); } } $i = $i + 1; } } $Personnage = new Personnage($PersonnageManager->get($_SESSION['personnageCourant']));
$_SESSION['ajax'] = true; require_once 'jeu.php'; break; case 'chercherLogin': $login = $_REQUEST['login']; $JoueurManager = new JoueurManager($db); $joueur = $JoueurManager->chercherLogin($login); if (is_array($joueur) && count($joueur) == 1) { echo $joueur[0]['login']; die; } break; case 'changerJoueur': $joueurId = $_REQUEST['joueurId']; $JoueurManager = new JoueurManager($db); $joueur = $JoueurManager->get($joueurId); if (is_array($joueur) && count($joueur) > 0) { $_SESSION['personnageCourant'] = null; $_SESSION['idJoueurCourant'] = $joueur['id']; echo true; die; } break; case 'seDeplacer': $_SESSION['ajax'] = true; $_SESSION['tourDisponible'] = true; $PersonnageManager = new PersonnageManager($db); $Personnage = new Personnage($PersonnageManager->get($_SESSION['personnageCourant'])); $positionX = $_REQUEST['positionX']; $positionY = $_REQUEST['positionY']; if ($Personnage->tourDisponible()) {