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(Creature.class);
}
public void processCommand() throws Exception {
String targetName = commandParams;
if (targetName == null) {
MessageOutFn.outln(console, "Drop what?");
return;
}
Creature creature = (Creature) player.getRole(Creature.class);
Interactive iTarget = SpaceFindFn.findByPrefix(player.asLocated(), creature.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(creature, physTarget);
}
public void showHelp() {
MessageOutFn.outln(console, command.name + ": use this command to drop items");
}
}