2021-07-09 19:56:23 +00:00
|
|
|
inventory = []
|
|
|
|
|
|
|
|
function checkInventory() {
|
2021-07-10 00:54:28 +00:00
|
|
|
if (userInput.value.toLowerCase() === "inventory") {
|
|
|
|
if (inventory.length === 0) {
|
|
|
|
printBold("You have nothing.")
|
|
|
|
} else {
|
|
|
|
printBold(inventory.join(", "));
|
|
|
|
}
|
|
|
|
}
|
2021-07-09 19:56:23 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
function pickUp() {
|
2021-07-10 00:54:28 +00:00
|
|
|
let target;
|
|
|
|
if (userInput.value.toLowerCase().startsWith("pick up ")) {
|
|
|
|
target = userInput.value.substring("pick up ".length)
|
|
|
|
} else if (userInput.value.toLowerCase().startsWith("grab ")) {
|
|
|
|
target = userInput.value.substring("grab ".length)
|
|
|
|
}
|
|
|
|
if (locations[currentLocation].collectables[target]) {
|
|
|
|
inventory.push(target)
|
|
|
|
printBold("You pick up the " + target)
|
|
|
|
delete locations[currentLocation].collectables[target]
|
|
|
|
} else {
|
|
|
|
printBold("Nothing to pick up!")
|
|
|
|
}
|
2021-07-09 19:56:23 +00:00
|
|
|
}
|