Class: Tama::Animal
- Inherits:
-
Object
- Object
- Tama::Animal
- Defined in:
- lib/tama/animal_class.rb
Overview
Classe animal dont herite Virtualanimal. Elle contient toutes la base du tamagotchi
Direct Known Subclasses
Constant Summary collapse
- @@nbreAnimal =
Un player ne devra pas avoir plus d’un tama
0
Instance Attribute Summary collapse
-
#Date_of_death ⇒ Object
readonly
Returns the value of attribute Date_of_death.
-
#DateBirth ⇒ Object
readonly
Returns the value of attribute DateBirth.
-
#health ⇒ Object
readonly
Returns the value of attribute health.
-
#mental ⇒ Object
readonly
Returns the value of attribute mental.
Instance Method Summary collapse
-
#clean ⇒ Object
Fonction nettoyer le tama - le faire prendre un bain.
-
#cure ⇒ Object
Fonction soigner du tama.
- #DieOfTama ⇒ Object
-
#feed ⇒ Object
Fonction manger du tama.
-
#initialize ⇒ Animal
constructor
Construteur principal.
-
#isAlive? ⇒ Boolean
Fonction qui permet de savoir si le tama est vivant ou mort.
-
#teach ⇒ Object
Fonction enseigner du tama.
Constructor Details
#initialize ⇒ Animal
Construteur principal
16 17 18 19 20 21 22 23 |
# File 'lib/tama/animal_class.rb', line 16 def initialize @health=$TAMA_HEALTH @mental=$TAMA_MENTAL @@nbreAnimal+=1 puts "Creation de l'animal \n" @DateBirth=Chronic.parse("now") @Date_of_death=Chronic.parse("#{$TIME_OF_LIFE} minutes from now") end |
Instance Attribute Details
#Date_of_death ⇒ Object (readonly)
Returns the value of attribute Date_of_death.
13 14 15 |
# File 'lib/tama/animal_class.rb', line 13 def Date_of_death @Date_of_death end |
#DateBirth ⇒ Object (readonly)
Returns the value of attribute DateBirth.
12 13 14 |
# File 'lib/tama/animal_class.rb', line 12 def DateBirth @DateBirth end |
#health ⇒ Object (readonly)
Returns the value of attribute health.
10 11 12 |
# File 'lib/tama/animal_class.rb', line 10 def health @health end |
#mental ⇒ Object (readonly)
Returns the value of attribute mental.
11 12 13 |
# File 'lib/tama/animal_class.rb', line 11 def mental @mental end |
Instance Method Details
#clean ⇒ Object
Fonction nettoyer le tama - le faire prendre un bain
49 50 51 52 53 54 |
# File 'lib/tama/animal_class.rb', line 49 def clean puts"Vous nettoyez votre animal \n" @mental +=10 @health +=30 return 4 end |
#cure ⇒ Object
Fonction soigner du tama
40 41 42 43 44 45 |
# File 'lib/tama/animal_class.rb', line 40 def cure puts"Vous soignez votre animal \n" @mental +=30 @health +=60 return 3 end |
#DieOfTama ⇒ Object
73 74 75 |
# File 'lib/tama/animal_class.rb', line 73 def DieOfTama ObjectSpace.garbage_collect end |
#feed ⇒ Object
Fonction manger du tama
26 27 28 29 30 |
# File 'lib/tama/animal_class.rb', line 26 def feed puts"Votre animal se nourrit \n" @health += 30 return 1 end |
#isAlive? ⇒ Boolean
Fonction qui permet de savoir si le tama est vivant ou mort
59 60 61 62 63 64 65 66 67 68 69 |
# File 'lib/tama/animal_class.rb', line 59 def isAlive? time_to_die=@Date_of_death actual_time=Chronic.parse("now") if actual_time > time_to_die puts "Votre tama est mort" return false else puts "Votre tama est vivant" return true end end |
#teach ⇒ Object
Fonction enseigner du tama
33 34 35 36 37 |
# File 'lib/tama/animal_class.rb', line 33 def teach puts"Votre animal apprend quelque chose \n" @mental += 10 return 2 end |