assassin-bug/src/engine/commands/look.js

21 lines
617 B
JavaScript
Raw Normal View History

2021-11-04 19:58:37 +00:00
export default function LookCommand(args, context) {
2021-11-04 21:19:50 +00:00
if (args.length == 1) {
2021-11-04 19:58:37 +00:00
context.examineRoom();
} else {
const room = context.getRoom(context.player.currentRoom);
const items = room.getItems();
let item = null;
for (let i of items) {
if (i.name.includes(args[1])) {
item = i;
break;
}
}
if (!item) {
2021-11-05 13:28:01 +00:00
context.output.say(`I could not find a ${args[1]}.`);
2021-11-04 19:58:37 +00:00
} else {
context.output.say(item.name);
context.output.say(item.description);
}
}
}