tama 0.0.1 → 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/tama/animal_class.rb +43 -8
- data/lib/tama/constant.rb +24 -0
- data/lib/tama/player_class.rb +7 -1
- data/lib/tama/version.rb +1 -1
- data/test/tama/animal_class_test.rb +8 -0
- data/test/tama_test.rb +13 -0
- metadata +7 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 14d40ac9dfd74bacac7aec1893fc2b5cdf83e82b
|
4
|
+
data.tar.gz: 25f1f77457f1b40fe8389ce231f1febf3e1224f7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7cdb90e998e6effd666e3bacf374956850bb8da9f152232a1cd5745320e49533ff5118de81310ae0190f989f7d4381b01a746b013da9e50c7c3597717b7c0dea
|
7
|
+
data.tar.gz: 4be9e716da03f3b180b14dccfe14ef532953c169560c088f5bdf9bc6b5adb0602eaf9d049e031e97807f009d26b1aa88ebc7eed18712066b3d6eb5a418283a81
|
data/lib/tama/animal_class.rb
CHANGED
@@ -1,44 +1,79 @@
|
|
1
1
|
# encoding: utf-8
|
2
2
|
module Tama
|
3
|
+
require 'chronic'
|
4
|
+
require_relative 'constant'
|
5
|
+
|
3
6
|
#Classe animal dont herite Virtualanimal.
|
4
7
|
#Elle contient toutes la base du tamagotchi
|
5
8
|
class Animal
|
6
9
|
@@nbreAnimal=0 #Un player ne devra pas avoir plus d'un tama
|
7
|
-
|
8
|
-
|
10
|
+
attr_reader :health
|
11
|
+
attr_reader :mental
|
12
|
+
attr_reader :DateBirth
|
13
|
+
attr_reader :Date_of_death
|
9
14
|
|
10
15
|
#Construteur principal
|
11
16
|
def initialize
|
12
|
-
@health
|
13
|
-
@mental
|
17
|
+
@health=$TAMA_HEALTH
|
18
|
+
@mental=$TAMA_MENTAL
|
14
19
|
@@nbreAnimal+=1
|
15
20
|
puts "Creation de l'animal \n"
|
21
|
+
@DateBirth=Chronic.parse("now")
|
22
|
+
@Date_of_death=Chronic.parse("#{$TIME_OF_LIFE} minutes from now")
|
16
23
|
end
|
17
24
|
|
18
25
|
#Fonction manger du tama
|
19
|
-
def feed
|
26
|
+
def feed
|
20
27
|
puts"Votre animal se nourrit \n"
|
28
|
+
@health += 30
|
21
29
|
return 1
|
22
30
|
end
|
23
31
|
|
24
32
|
#Fonction enseigner du tama
|
25
|
-
def teach
|
33
|
+
def teach
|
26
34
|
puts"Votre animal apprend quelque chose \n"
|
35
|
+
@mental += 10
|
27
36
|
return 2
|
28
37
|
end
|
29
38
|
|
30
39
|
#Fonction soigner du tama
|
31
|
-
def cure
|
40
|
+
def cure
|
32
41
|
puts"Vous soignez votre animal \n"
|
42
|
+
@mental +=30
|
43
|
+
@health +=60
|
33
44
|
return 3
|
34
45
|
end
|
35
46
|
|
36
47
|
#Fonction nettoyer le tama - le faire prendre
|
37
48
|
#un bain
|
38
|
-
def clean
|
49
|
+
def clean
|
39
50
|
puts"Vous nettoyez votre animal \n"
|
51
|
+
@mental +=10
|
52
|
+
@health +=30
|
40
53
|
return 4
|
41
54
|
end
|
55
|
+
|
56
|
+
#Fonction qui permet de savoir
|
57
|
+
#si le tama est vivant ou mort
|
58
|
+
|
59
|
+
def isAlive?
|
60
|
+
time_to_die=@Date_of_death
|
61
|
+
actual_time=Chronic.parse("now")
|
62
|
+
if actual_time > time_to_die
|
63
|
+
puts "Votre tama est mort"
|
64
|
+
return false
|
65
|
+
else
|
66
|
+
puts "Votre tama est vivant"
|
67
|
+
return true
|
68
|
+
end
|
69
|
+
end
|
70
|
+
|
71
|
+
|
72
|
+
|
73
|
+
def DieOfTama
|
74
|
+
ObjectSpace.garbage_collect
|
75
|
+
end
|
76
|
+
|
42
77
|
|
43
78
|
end
|
44
79
|
end
|
data/lib/tama/constant.rb
CHANGED
@@ -4,4 +4,28 @@ module Tama
|
|
4
4
|
#qui comprendront tout ce que devra etre
|
5
5
|
#statique sur le tama
|
6
6
|
|
7
|
+
|
8
|
+
#Constante globale qui determine le temps de vie de tout tamagotchi
|
9
|
+
|
10
|
+
$TIME_OF_LIFE=3600
|
11
|
+
|
12
|
+
#Constante par défaut de la vie du tama sante et mental
|
13
|
+
|
14
|
+
$TAMA_HEALTH=100
|
15
|
+
$TAMA_MENTAL=100
|
16
|
+
|
17
|
+
# Tableau qui determine les etats de vie du tamagotchi
|
18
|
+
|
19
|
+
$STATE_OF_LIFE=["Oeuf","bebe","enfant","adulte","age","mort"]
|
20
|
+
|
21
|
+
#Humeur du tama
|
22
|
+
|
23
|
+
$MOOD=["heureux","neutre","melancolique","depressif","triste"]
|
24
|
+
|
25
|
+
# Un tama ne peut pas etre immortel => cette constante assure ce probleme
|
26
|
+
# A reflechir dessus
|
27
|
+
|
28
|
+
$TAMA_MAX_LIFE=9600
|
29
|
+
|
30
|
+
|
7
31
|
end
|
data/lib/tama/player_class.rb
CHANGED
data/lib/tama/version.rb
CHANGED
data/test/tama_test.rb
ADDED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: tama
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Mori
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-
|
11
|
+
date: 2014-03-03 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -100,6 +100,8 @@ files:
|
|
100
100
|
- lib/tama/player_class.rb
|
101
101
|
- lib/tama/version.rb
|
102
102
|
- tama.gemspec
|
103
|
+
- test/tama/animal_class_test.rb
|
104
|
+
- test/tama_test.rb
|
103
105
|
homepage: http://github.com/mosleymos/tama.com
|
104
106
|
licenses:
|
105
107
|
- MIT
|
@@ -124,4 +126,6 @@ rubygems_version: 2.2.1
|
|
124
126
|
signing_key:
|
125
127
|
specification_version: 4
|
126
128
|
summary: Tama est un projet de tamagotchi en version informatique.
|
127
|
-
test_files:
|
129
|
+
test_files:
|
130
|
+
- test/tama/animal_class_test.rb
|
131
|
+
- test/tama_test.rb
|