-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathtamagotchi.js
81 lines (71 loc) · 1.67 KB
/
tamagotchi.js
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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
// Create class below
class Tamagotchi {
constructor(name, energy=9, full=8, mood=6, sick=false, rehomed=false) {
this.name = name;
this.energy = energy;
this.full = full;
this.mood = mood;
this.sick = sick;
this.rehomed = rehomed;
}
greet() {
console.log(`Hell, I'm ${this.name}!`)
}
status() {
}
eat() {
this.full +=2;
this.energy -= 1;
if(this.full > 10 ) {
this.sick = true;
}
}
medicate() {
if(this.sick) {
this.full = 9;
this.energy -= 3;
this.sick = false;
} else {
console.log("refusal to take medicine");
this.energy -= 1;
}
}
play() {
if(this.sick) {
this.mood -= 1;
this.energy -= 1;
} else if(this.energy <= 3) {
console.log("I'm took tired to play");
this.energy -= 1;
} else if(this.mood > 9){
this.energy -= 2;
this.full -= 1;
} else {
this.mood += 2;
this.energy -= 1;
this.full -= 1;
}
}
sleep() {
this.energy += 4;
this.full -= 3;
}
timePasses() {
if(!this.sick) {
this.mood -= 2;
this.full -= 1;
this.energy -= 1;
} else {
this.mood -= 3;
this.full -= 2;
this.energy -= 2;
}
}
badGuardian() {
if(this.energy <= 0 || this.mood <= 0 || this.full <= 0) {
this.rehomed = true;
}
}
}
// Do not edit below this line
module.exports = Tamagotchi;