public function update(Personnage $personnage) { $request = $this->db->prepare(' UPDATE personnage SET degat = :degat, experience = :experience, nom = :nom, nombreAttaque = :nombreAttaque, mouvement = :mouvement, pointDeVie = :pointDeVie, planId = :planId, pointInvestissement = :pointInvestissement, positionX = :positionX, positionY = :positionY, tourDeJeu = :tourDeJeu, prochainTourDeJeu = :prochainTourDeJeu WHERE id = :id'); $request->bindValue(':degat', $personnage->getDegat()); $request->bindValue(':experience', $personnage->getExperience()); $request->bindValue(':id', $personnage->getId()); $request->bindValue(':nom', $personnage->getNom()); $request->bindValue(':nombreAttaque', $personnage->getNombreAttaque()); $request->bindValue(':mouvement', $personnage->getMouvement()); $request->bindValue(':planId', $personnage->getPlanId()); $request->bindValue(':pointInvestissement', $personnage->getPointInvestissement()); $request->bindValue(':pointDeVie', $personnage->getPointDeVie()); $request->bindValue(':positionX', $personnage->getPositionX()); $request->bindValue(':positionY', $personnage->getPositionY()); $request->bindValue(':tourDeJeu', $personnage->getTourDeJeu()); $request->bindValue(':prochainTourDeJeu', $personnage->getProchainTourDeJeu()); $request->execute(); }
require_once 'Carte.class.php'; require_once 'JoueurManager.class.php'; require_once 'Joueur.class.php'; require_once 'PersonnageManager.class.php'; require_once 'Personnage.class.php'; require_once 'PersonnageType.class.php'; require_once 'PersonnageTypeManager.class.php'; if (isset($_REQUEST)) { $action = $_REQUEST['action']; switch ($action) { case 'activer': $PersonnageManager = new PersonnageManager($db); // Instance du personnage courant $Personnage = new Personnage($PersonnageManager->get($_SESSION['personnageCourant'])); // Vérification si le personnage a le droit d'activer if (strtotime(date('Y-m-d H:i:s')) > strtotime($Personnage->getProchainTourDeJeu())) { $Personnage->setTourDeJeu(date('Y-m-d H:i:s')); $Personnage->setProchainTourDeJeu(date('Y-m-d H:i:s', strtotime(date('Y-m-d H:i:s')) + INT_TOUR_DE_JEU)); $PersonnageTypeManager = new PersonnageTypeManager($db); // Instance du personnage type $PersonnageType = new PersonnageType($PersonnageTypeManager->get($Personnage->getPersonnageTypeId())); $Personnage->setMouvement($PersonnageType->getMouvement()); $Personnage->setNombreAttaque($PersonnageType->getNombreAttaque()); // Mise à jour du personnage $PersonnageManager->update($Personnage); } $_SESSION['ajax'] = true; require_once 'jeu.php'; break; case 'chercherLogin': $login = $_REQUEST['login'];