} if (isset($_POST['creer']) && isset($_POST['nom'])) { $perso = new Personnage(['nom' => $_POST['nom']]); // On crée un nouveau personnage. if (!$perso->nomValide()) { $message = 'Le nom choisi est invalide.'; unset($perso); } elseif ($manager->exists($perso->getNom())) { $message = 'Le nom du personnage est déjà pris.'; unset($perso); } else { $manager->add($perso); } } elseif (isset($_POST['utiliser']) && isset($_POST['nom'])) { if ($manager->exists($_POST['nom'])) { $perso = $manager->get($_POST['nom']); } else { $message = 'Ce personnage n\'existe pas !'; // S'il n'existe pas, on affichera ce message. } } elseif (isset($_GET['frapper'])) { if (!isset($perso)) { $message = 'Merci de créer un personnage ou de vous identifier.'; } else { if (!$manager->exists((int) $_GET['frapper'])) { $message = 'Le personnage que vous voulez frapper n\'existe pas !'; } else { $persoAFrapper = $manager->get((int) $_GET['frapper']); $retour = $perso->frapper($persoAFrapper); // On stocke dans $retour les éventuelles erreurs ou messages que renvoie la méthode frapper. switch ($retour) {
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'])); $smarty->assign('personnage', $Personnage); $smarty->assign('personnages', $Personnages); $smarty->display('page/pageAmelioration.tpl'); } else { header('Location: index.php');
$_SESSION['messageMouvement'] = true; $_SESSION['tourDisponible'] = false; } require_once 'jeu.php'; break; case 'selectPersonnage': $_SESSION['ajax'] = true; $_SESSION['personnageCourant'] = $_REQUEST['selectedPersonnage']; require_once 'jeu.php'; break; case 'attaquer': $_SESSION['ajax'] = true; $_SESSION['messageAttaque'] = true; $personnageAttaquerId = $_REQUEST['personnageAttaquerId']; $PersonnageManager = new PersonnageManager($db); $Personnage = new Personnage($PersonnageManager->get($_SESSION['personnageCourant'])); $PersonnageAttaquer = new Personnage($PersonnageManager->get($personnageAttaquerId)); $_SESSION['personnage'] = $Personnage; $_SESSION['personnageAttaquer'] = $PersonnageAttaquer; $seToucher = false; $_SESSION['seToucher'] = $seToucher; $nombreAttaqueDisponible = true; $_SESSION['nombreAttaqueDisponible'] = $nombreAttaqueDisponible; if ($PersonnageAttaquer->seToucher($Personnage)) { $seToucher = true; $_SESSION['seToucher'] = $seToucher; if ($Personnage->tourDisponible()) { $_SESSION['tourDisponible'] = true; if ($Personnage->getNombreAttaque() <= 0) { $nombreAttaqueDisponible = false; $_SESSION['nombreAttaqueDisponible'] = $nombreAttaqueDisponible;