import CommandBuilder from "../builders/command"; function lookHandler(args, context) { if (args.length == 1) { 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) { 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(`You look at ${item.name}.`); context.output.say(item.description); } } } export default new CommandBuilder() .withName("look") .withAliases(["l"]) .withCategory("Actions") .withDescription("Examine room or object") .withArgument("item", "target", true, "Object to examine") .withHandler(lookHandler) .create();