Rooms, items and some player stuff

This commit is contained in:
2021-11-04 20:58:37 +01:00
parent 36bb9264b3
commit a745ff299e
277 changed files with 14665 additions and 5 deletions

View File

@@ -0,0 +1,21 @@
export default function LookCommand(args, context) {
if (args.length == 0) {
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) {
context.output.say(`I could not find a ${args[1]}`);
} else {
context.output.say(item.name);
context.output.say(item.description);
}
}
}

View File

View File

@@ -0,0 +1,16 @@
export default async function UseCommand(args, context) {
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) {
context.output.say(`I could not find a ${args[1]}`);
} else {
await item.onUse();
}
}