コード例 #1
0
 public function update()
 {
     $connexion = new Connexion();
     $sql = "";
     $sql = "UPDATE \"libertribes\".\"CASE\" set coord = '" . $this->coord . "', occupee_par = '" . $this->occupee_par . "', occupant_id = '" . $this->occupant_id . "', nom_terrain = '" . $this->nom_terrain . "' ";
     $sql .= "WHERE id = '" . $this->id . "'";
     return $connexion->Requete($sql);
 }
コード例 #2
0
 function __construct($row)
 {
     $this->lien_regles = "http://wiki.hegoa.eu/Personnage";
     if (!is_array($row)) {
         // - on  établit une connexion car on n'a pas transmis de données venant déjà de la BDD; la variable row est soit l'ID de l'avatar soit le nom (qui doit être unique)
         $connexion = new Connexion();
         // premier test, sur l'ID
         $sql = "SELECT * FROM \"libertribes\".\"AVATAR\" WHERE avatar_id = '" . $row . "'";
         $result = $connexion->Requete($sql);
         if (isset($result) && !empty($result)) {
             $num_rows = pg_num_rows($result);
             while ($row = pg_fetch_array($result)) {
                 $this->id = $row['avatar_id'];
                 $this->nom = $row['avatar_nom'];
                 $this->date_creation = $row['date_creation'];
                 $this->agressivite = $row['niveau_agressivite'];
                 $this->efficacite = $row['niveau_efficacite'];
                 $this->commerce = $row['niveau_commerce'];
                 $this->escroquerie = $row['niveau_escroquerie'];
                 $this->compte_id = $row['compte_id'];
                 $this->race = $row['race'];
                 $this->niveau = $row['niveau'];
                 $this->num_image = $row['numero_image'];
                 $this->derniere_position = $row['derniere_position'];
                 $this->derniere_connexion = $row['derniere_connexion'];
                 $this->histoire = $row['histoire'];
             }
         }
         if (!isset($num_rows) || !$num_rows || $num_rows == 0) {
             // deuxième test, sur le nom
             $sql = "SELECT * FROM \"libertribes\".\"AVATAR\" WHERE avatar_nom = '" . $row . "'";
             $result = $connexion->Requete($sql);
             if (isset($result) && !empty($result)) {
                 while ($row = pg_fetch_array($result)) {
                     $this->id = $row['avatar_id'];
                     $this->nom = $row['avatar_nom'];
                     $this->date_creation = $row['date_creation'];
                     $this->agressivite = $row['niveau_agressivite'];
                     $this->efficacite = $row['niveau_efficacite'];
                     $this->commerce = $row['niveau_commerce'];
                     $this->escroquerie = $row['niveau_escroquerie'];
                     $this->compte_id = $row['compte_id'];
                     $this->race = $row['race'];
                     $this->niveau = $row['niveau'];
                     $this->num_image = $row['numero_image'];
                     $this->derniere_position = $row['derniere_position'];
                     $this->derniere_connexion = $row['derniere_connexion'];
                     $this->histoire = $row['histoire'];
                 }
             }
         }
     } else {
         //  on a transmis des données venant déjà de la BDD; la variable row est un tableau contenant les champ de l'avatar
         $this->id = $row['avatar_id'];
         $this->nom = $row['avatar_nom'];
         $this->date_creation = $row['date_creation'];
         $this->agressivite = $row['niveau_agressivite'];
         $this->efficacite = $row['niveau_efficacite'];
         $this->commerce = $row['niveau_commerce'];
         $this->escroquerie = $row['niveau_escroquerie'];
         $this->compte_id = $row['compte_id'];
         $this->race = $row['race'];
         $this->niveau = $row['niveau'];
         $this->num_image = $row['numero_image'];
         $this->derniere_position = $row['derniere_position'];
         $this->derniere_connexion = $row['derniere_connexion'];
         $this->histoire = $row['histoire'];
     }
     //  on charge tous les villages de l'avatar, ainsi que toutes les autres cases occupées
     if (!isset($connexion)) {
         $connexion = new Connexion();
     }
     $villages = array();
     $i = 0;
     $sql = "SELECT * FROM \"libertribes\".\"VILLAGE\" WHERE avatar_iden = '" . $this->id . "'";
     $result = $connexion->Requete($sql);
     if (isset($result) && !empty($result)) {
         while ($row = pg_fetch_array($result)) {
             $villages[$i] = new Village($row['village_id']);
             $i++;
         }
     }
     $mes_cases = array();
     $i = 0;
     $sql = "SELECT * FROM \"libertribes\".\"CASE\" WHERE occupant_id = '" . $this->id . "'";
     $result = $connexion->Requete($sql);
     if (isset($result) && !empty($result)) {
         while ($row = pg_fetch_array($result)) {
             $mes_cases[$i] = new Caza($row);
             $i++;
         }
     }
     $this->villages = $villages;
     $this->mes_cases = $mes_cases;
     $this->calculProductionVillages();
     $this->calculManaTotal();
 }
コード例 #3
0
 private function obtenirTauxNatalite($avatar_id)
 {
     $connexion = new Connexion();
     $sql = "SELECT race FROM \"libertribes\".\"AVATAR\" WHERE avatar_id = " . $avatar_id;
     $result = $connexion->Requete($sql);
     if (isset($result) && !empty($result)) {
         $row = pg_fetch_row($result);
         $larace = $row[0];
     }
     //  les races sont déjà mises en SESSION, dans $_SESSION['races_possibles']
     foreach ($_SESSION['races_possibles'] as $race) {
         if ($larace == $race->nom) {
             $this->natalite = $race->taux_natalite;
             break;
         }
     }
 }
コード例 #4
0
 function __construct($row)
 {
     if (!is_array($row)) {
         // - on  établit une connexion car on n'a pas transmis de données venant déjà de la BDD; la variable row est soit l'ID du compte du joueur soit l'email (qui doit être unique)
         $connexion = new Connexion();
         // premier test, sur l'ID
         $sql = "SELECT * FROM \"libertribes\".\"COMPTE\" WHERE compte_id = '" . $row . "'";
         $result = $connexion->Requete($sql);
         if (isset($result) && !empty($result)) {
             $num_rows = pg_num_rows($result);
             while ($row = pg_fetch_array($result)) {
                 $this->id = $row['compte_id'];
                 $this->nom = $row['nom'];
                 $this->prenom = $row['prenom'];
                 $this->password = $row['password'];
                 $this->email = $row['email'];
                 $this->date_inscription = $row['date_inscription'];
                 $this->confirmation = $row['confirmation'];
                 $this->ville = $row['ville'];
                 $this->pays = $row['pays'];
                 $this->date_anniv = $row['date_anniv'];
                 $this->presentation = $row['presentation'];
                 $this->statut = $row['statut'];
                 $this->type_compte = $row['type_compte'];
             }
         }
         if (!isset($num_rows) || !$num_rows || $num_rows == 0) {
             // deuxième test, sur l'email
             $sql = "SELECT * FROM \"libertribes\".\"COMPTE\" WHERE email = '" . $row . "'";
             $result = $connexion->Requete($sql);
             if (isset($result) && !empty($result)) {
                 while ($row = pg_fetch_array($result)) {
                     $this->id = $row['compte_id'];
                     $this->nom = $row['nom'];
                     $this->prenom = $row['prenom'];
                     $this->password = $row['password'];
                     $this->email = $row['email'];
                     $this->date_inscription = $row['date_inscription'];
                     $this->confirmation = $row['confirmation'];
                     $this->ville = $row['ville'];
                     $this->pays = $row['pays'];
                     $this->date_anniv = $row['date_anniv'];
                     $this->presentation = $row['presentation'];
                     $this->statut = $row['statut'];
                     $this->type_compte = $row['type_compte'];
                 }
             }
         }
     } else {
         //  on a transmis des données venant déjà de la BDD; la variable row est un tableau contenant les champ de l'avatar
         $this->id = $row['compte_id'];
         $this->nom = $row['nom'];
         $this->prenom = $row['prenom'];
         $this->password = $row['password'];
         $this->email = $row['email'];
         $this->date_inscription = $row['date_inscription'];
         $this->confirmation = $row['confirmation'];
         $this->ville = $row['ville'];
         $this->pays = $row['pays'];
         $this->date_anniv = $row['date_anniv'];
         $this->presentation = $row['presentation'];
         $this->statut = $row['statut'];
         $this->type_compte = $row['type_compte'];
     }
 }