-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
60ba374
commit 9cf10af
Showing
1 changed file
with
76 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,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; |