public function frapper(Personnage $personnage)
 {
     if ($personnage->getId() == $this->getId()) {
         return self::CEST_MOI;
     }
     $personnage->recevoirDegats();
 }
 public function update(Personnage $perso)
 {
     $q = $this->_db->prepare('UPDATE personnages SET degats = :degats WHERE id = :id');
     $q->bindValue(':degats', $perso->getDegats(), PDO::PARAM_INT);
     $q->bindValue(':id', $perso->getId(), PDO::PARAM_INT);
     $q->execute();
 }
 public function frapperUnPersonnage(Personnage $persoAFrapper)
 {
     if ($persoAFrapper->getId() == $this->id) {
         return self::DETECT_ME;
     }
     if ($this->toBeAsleep()) {
         return self::PERSO_ASLEEP;
     }
     // Indication au personnage qu'il reçoit un coup / des dégats
     // Puis on retourne la valeur renvoyée par la méthode : self::PERSONNAGE_TUE ou self::PERSONNAGE_FRAPPE
     return $persoAFrapper->recevoirUnCoup();
 }
 public function deletePersonnage(Personnage $perso)
 {
     $this->bdd->exec('DELETE FROM Personnages_v2
                              WHERE id = ' . $perso->getId());
     // execute DELETE request
 }
Exemple #5
0
 $PersonnageType = new PersonnageType($PersonnageTypeManager->get($Personnage->getPersonnageTypeId()));
 $EvolutionManager = new EvolutionManager($db);
 //Récuperation de la liste des évolutions correspondant au personnage type
 $evolutionGetBy = $EvolutionManager->getBy('personnageTypeId', $Personnage->getPersonnageTypeId());
 $listeEvolution = array();
 if (count($evolutionGetBy) > 0) {
     foreach ($evolutionGetBy as $evolution) {
         // Instance de chaque evolution
         $iEvolution = new Evolution($evolution);
         // Si l'expérience du personnage est comprise dans la tranche d'evolution
         if ($iEvolution->getPalierInferieur() <= $Personnage->getExperience() && $iEvolution->getPalierSuperieur() > $Personnage->getExperience()) {
             $iconePersonnageId = $iEvolution->getIconePersonnageId();
             $Personnage->setIconePersonnageId($iconePersonnageId);
             $PersonnageManager->update_iconepersonnage_personnage($Personnage);
             //On met à jour le personnage
             $Personnage = new Personnage($PersonnageManager->get($Personnage->getId()));
         }
     }
 }
 // Liste des joueurs
 $listeJoueur = $JoueurManager->getAll();
 // Contruction d'une variable selectJoueurs au format d'un optiongroup
 $selectJoueurs = array();
 if (count($listeJoueur) > 0) {
     foreach ($listeJoueur as $key => $item) {
         if (!isset($selectJoueurs[$item['roleNom']])) {
             $selectJoueurs[$item['roleNom']] = array();
         }
         array_push($selectJoueurs[$item['roleNom']], new Joueur($item));
     }
 }
 public function update_iconepersonnage_personnage(Personnage $personnage)
 {
     $request = $this->db->prepare('
         UPDATE 
                 _iconepersonnage_personnage
         SET 
                 iconePersonnageId = :iconePersonnageId
         WHERE 
                 personnageId= :personnageId');
     $request->bindValue(':iconePersonnageId', $personnage->getIconePersonnageId());
     $request->bindValue(':personnageId', $personnage->getId());
     $request->execute();
 }