Add loading functionality
This commit is contained in:
15
src/engine/commands/inventory.js
Normal file
15
src/engine/commands/inventory.js
Normal file
@@ -0,0 +1,15 @@
|
||||
export default function InventoryCommand(args, context) {
|
||||
const items = context.player.getInventory();
|
||||
if (items.length < 1) return context.print(`You're not carrying anything.`);
|
||||
let itemDescription = `You are carrying `;
|
||||
items.forEach((item, index) => {
|
||||
if (index < items.length - 2) {
|
||||
itemDescription += `${item.name}, `;
|
||||
} else if (index < items.length - 1) {
|
||||
itemDescription += `${item.name} and `;
|
||||
} else {
|
||||
itemDescription += item.name
|
||||
}
|
||||
});
|
||||
context.print(itemDescription + ".");
|
||||
}
|
@@ -11,10 +11,19 @@ export default function LookCommand(args, context) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!item) {
|
||||
const items = context.player.getInventory();
|
||||
for (let i of items) {
|
||||
if (i.name.includes(args[1])) {
|
||||
item = i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!item) {
|
||||
context.output.say(`I could not find a ${args[1]}.`);
|
||||
} else {
|
||||
context.output.say(item.name);
|
||||
context.output.say(`You look at ${item.name}.`);
|
||||
context.output.say(item.description);
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user