-
Notifications
You must be signed in to change notification settings - Fork 2
/
lifeOfCat.js
133 lines (102 loc) · 3.04 KB
/
lifeOfCat.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
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
/**
* @module lifeOfCat
* author finderskeepers
* meow!
*/
var cat = function (yourCat) {
this.name = yourCat.name;
this.color = yourCat.color || colors[random(0, 4)];
this.age = yourCat.age || new Date(minutes);
this.sex = yourCat.sex || "female";
this.happiness = yourCat.happiness || 20;
// life counter
var life;
// cats of yourCat
var cats = [];
// some such WOW AMAZING colors
var colors = ['black', 'golden', 'white', 'grey', 'mixed'];
// generates random number from initial value to end value
var random = function (initial, end) {
return Math.floor((Math.random() * initial) + end);
};
//new troublemakers are loading...
var newMeows = function (name, color, age) {
var newCat = new cat({
name: name,
color: color,
age: age,
sex: random(0, 1) ? "male" : "female"
});
if( name === 'serafettin' || name === 'sero' ){ // kotu kedi serafettin detect.
throw new Error("he is most spesific cat of all the world. NOT BORN AGAIN!!!");
}else {
cats.push(newCat);
}
};
this.growUp = function () { //a minute is 1 such WOW....... boring new age.
life = setInterval(function () {
this.age++;
this.happiness -= 5;
}, 60000);
};
this.death = function () { //I can't endure hooomans stupidity anymore.
if (this.age > 10) {
clearInterval(life);
}
};
this.flee = function () { //That's it, bye.
if (this.happiness < -50) {
cat = null;
cats = [];
}
};
this.isHungry = function () {
return true; //You're god damn right, hooman!..
};
this.feedMeHooman = function () {
if (this.isHungry()) { //always...
this.happiness -= 20;
throw new Error("WHERE IS MY FUCKING FOOD HOOOOOMAN???");
}
};
this.eat = function () {
this.happiness += 10; //can't touch this \_o_/
console.log("Namnamnamnam");
};
this.giveAFuck = function (thing) {
if (thing != "food") { //What's in it what's in it c'moooooooon
throw new Error("Hmm, meow!" + " (There is no food, and no reason to give a fuck!)");
}
else { //Don't you see? I'm busy...
this.eat();
return true;
}
};
this.throwIt = function (thing) {
if (thing == 'unbreakable') { //Hmmm let me see, is it breakable??
//No? Nevermind...
}
else { //Yes?
this.happiness += 50; //Because I'm happy :3
throw new Error("Hmmm, meow!" + " (Zhehehe, I fucking throw it...)");
}
};
this.pregnant = function () {
var date = new Date();
var month = date.getMonth();
if (month == 2) { //Behoooold humans, March is coming....
this.getBaby(random(1, 100)); //It is impossible not to get pregnant, so 1...
this.happiness += 10;
return true;
}
else { //No March no babies...
return false;
}
};
this.getBaby = function (value) { //Sssssh wait, new troublemakers are coming...
for (var i = 0; i < value; i++) {
new newMeows('meow' + cats.length, colors[random(0, 5)], 0);
}
};
};
module.exports = cat;