package net.sourceforge.pain.logic.event.console.command;
import net.sourceforge.pain.logic.event.console.*;
import net.sourceforge.pain.logic.fn.*;
import net.sourceforge.pain.data.type.*;
public final class Look extends CommandHandler {
public boolean isAccessible() {
return super.isAccessible() && player.asReceptive().canSee();
}
public void processNotAccessible() {
MessageOutFn.outln(console, "You can't see anything!");
}
public void processCommand() throws Exception {
Receptive receptive = console.getPlayer().asReceptive();
String targetName = commandParams;
if (targetName == null) {
lookSpace();
} else {
targetName = targetName.trim().toLowerCase();
if (targetName.length() > 3 && (targetName.startsWith("on ") || targetName.startsWith("at "))) {
targetName = targetName.substring(3).trim();
}
Interactive actor = player.asInteractive();
Interactive victim = SpaceFindFn.findByPrefix(actor.asLocated(), targetName);
if (victim == null) {
MessageOutFn.outOne(player, "You can't find $t here", targetName);
} else {
if (victim == actor) {
MessageOutFn.outSpace(actor, "$n looks at $mself.", actor, actor);
} else {
MessageOutFn.outOne(victim, "$n looks at you.", actor, null);
MessageOutFn.outSpaceNoVictim(actor, victim, "$n looks at $N.", actor, victim);
}
ShowFn.showObject(receptive, victim);
}
}
}
private void lookSpace() {
ShowFn.showSpace(player.asReceptive(), player.getLocation());
}
public void showHelp() {
MessageOutFn.outln(console, command.name + ":shows description of the place and interactive objects in it");
}
}