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

19 lines
569 B
JavaScript
Raw Normal View History

2021-11-04 21:47:09 +00:00
export default function DropCommand(args, context) {
const room = context.getRoom(context.player.currentRoom);
const items = context.player.getInventory();
let item = null;
for (let i of items) {
if (i.name.includes(args[1])) {
item = i;
break;
}
}
if (!item) {
context.print(`You're not carrying a ${args[1]}`);
} else {
context.player.removeItem(item.id);
room.addItem(item.id);
context.print(`You set ${item.name} down on the floor.`);
item.onDrop();
}
}