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

37 lines
1004 B
JavaScript
Raw Normal View History

2025-07-18 14:33:56 +00:00
function DropCommand(args, context) {
2022-10-26 14:45:32 +00:00
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 {
2024-03-22 17:23:46 +00:00
context.player.removeItem(item.getID());
room.addItem(item.getID());
2022-10-26 14:45:32 +00:00
context.print(`You set ${item.name} down on the floor.`);
item.onDrop();
2025-07-18 14:33:56 +00:00
// Refresh mobile commands when items change
context.commandHandler.refreshMobileCommands();
2022-10-26 14:45:32 +00:00
}
2025-07-18 14:33:56 +00:00
}
DropCommand.metadata = {
category: "Actions",
description: "Drop an object",
arguments: [
{
type: "item",
name: "target",
optional: false,
description: "Object to drop"
}
]
};
export default DropCommand;