Humans...
Darn humans.
JavaScript
(function(window) {
function Human(parents) {
var self = this;
init();
var meaningless = "meaningless";
var hp = 100;
var gender = (Math.random() < 0.5) ? "M" : "F";
var family = {"parents": parents || [], "children": [], "siblings": [], "couple": [self]};
this.name = undefined;
this.money = 0;
this.career = undefined;
// Creating these methods without using prototype causes much more memory overhead...
// but we gotta access those privates...
this.suicide = function() {
var rand = Math.floor(Math.random() * 101); // 0 to 100
// this = null; // Impossible
// delete this; // Nope
if (hp - rand > 0)
hp -= rand;
else
hp = 1;
console.log('I see you like hurting yourself.\nNot dead yet though.\nKeep trying.\nHP remaining: ' + hp + '.');
return self;
}
this.increaseLifetimeHappiness = function(happiness) {
if (typeof(happiness) === "number" && happiness >= 1) {
hp += happiness;
}
else {
throw ("We must be happy :))");
}
console.log("Everything's better when you're happy! \nHP remaining: " + hp + '.');
return self;
}
this.getDepression = function(sadness) {
console.log("Go see a therapist.");
if (hp - sadness <= 10) {
this.suicide();
}
else {
hp = hp - sadness;
console.log("Cheer up ): \nHP remaining: " + hp + '.');
}
return self;
}
this.giveBirth = function(count) {
if(family.couple.length != 2)
throw "Really now? Try 2 people.";
if(gender === "F") {
count = count || 1;
var...