package net.sourceforge.pain.logic.event.console.command; import net.sourceforge.pain.data.type.*; import net.sourceforge.pain.logic.event.console.*; import net.sourceforge.pain.logic.fn.*; public final class Drop extends CommandHandler { public boolean isAccessible() { return super.isAccessible() && player.is(Equipped.class); } public void processCommand() throws Exception { String targetName = commandParams; if (targetName == null) { MessageOutFn.outln(console, "Drop what?"); return; } Equipped equipped = (Equipped) player.getRole(Equipped.class); Interactive iTarget = SpaceFindFn.findByPrefix(player.asLocated(), equipped.getInventory(), targetName); Physical physTarget = iTarget != null ? (Physical) iTarget.getRole(Physical.class) : null; if (physTarget == null) { if (iTarget != null) { MessageOutFn.outln(console, "You failed."); } else { MessageOutFn.outln(console, "I see no " + targetName + " here."); } return; } DropFn.drop(equipped, physTarget); } public void showHelp() { MessageOutFn.outln(console, command.name + ": use this command to drop items"); } }