Bonjour à tous, n'arrêtant pas d'entendre parlé de poo en php dans tous les magazines ou livres que je lis, j'ai décidé de m'y essayer en commençant un jeu basique, premier essai, 1er problème, j'ai une erreur que je n'arrive pas à comprendre :
Fatal error: Call to undefined method departJeu::arr_personnage() in D:\test\jeu.php on line 25
Voici la "chose" que j'ai faite :
Bon, je me doute qu'il y sans doute des trucs qui vont pas et peut-être même illogiques, mais j'ai jamais fait de poo.
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56 <?php class departJeu { private $vie; private $force; private $resistance; private $magie; private $temperament; private $personnage; private $arr_personnage; public function __construct() { $this -> vie = 20; $this -> force = 10; $this -> resistance = 20; $this -> magie = 20; $this -> temperament = 50; $this -> arr_personnage = array(1 => 'brutus', 'agilicius', 'maleficius', 'angelicius'); } private function capacite_personnage($id_personnage) { $this -> personnage = $this->arr_personnage($id_personnage); if( $this -> personnage == 'brutus' ) $this->force*=3; if( $this -> personnage == 'agilicius' ) $this->resistance*=3; if( $this -> personnage == 'maleficius' ) { $this -> magie+=20; $this->temperament-=20; } if( $this -> personnage == 'angelicus' ) { $this -> magie+=20; $this->temperament+=20; } } public function choix_personnage($id_personnage) { $this->capacite_personnage($id_personnage); return array($this->personnage, $this->vie, $this->force, $this->resitance, $this->magie, $this->temperament); } } $jeu = new departJeu; $id = 1; $attributs = $jeu->choix_personnage($id); print_r($attributs); ?>
Pourquoi ai-je cette erreur ?
Partager