-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.js
59 lines (46 loc) · 1.38 KB
/
app.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
import inquirer from "inquirer"
import { initQuestions, gameQuestion } from "./questions.js"
import { siberianTiger, redPanda, sloth } from "./classes.js"
// const { siberianTiger } = require("./classes")
let myPet
let ui = new inquirer.ui.BottomBar()
const init = async () => {
let response = await inquirer.prompt(initQuestions)
if (response.type === "Siberian Tiger") {
myPet = new siberianTiger(response.name)
} else if (response.type === "Red Panda") {
myPet = new redPanda(response.name)
} else {
myPet = new sloth(response.name)
}
ui.log.write(
`${myPet.name} | Hunger: ${myPet.hunger} | Thirst: ${myPet.thirst} | Energy: ${myPet.energy} | Hygiene: ${myPet.hygiene}`
)
gameLoop()
}
const gameLoop = async () => {
try {
if (myPet.health >= 150) {
console.log("Game Over")
return
}
myPet.time()
let response = await inquirer.prompt(gameQuestion)
if (response.action === "drink") {
myPet.drink()
} else if (response.action === "feed") {
myPet.feed()
} else if (response.action === "sleep") {
myPet.sleep()
} else if (response.action === "clean") {
myPet.clean()
}
ui.log.write(
`${myPet.name} | Hunger: ${myPet.hunger} | Thirst: ${myPet.thirst} | Energy: ${myPet.energy} | Hygiene: ${myPet.hygiene}`
)
gameLoop()
} catch (error) {
console.log(error)
}
}
init()