ShowFn.java
src/net/sourceforge/pain/logic/fn/ShowFn.java · 1.7 KB
From the archive pain_0_41.zip
Download the archive « Back to the archive contents
package net.sourceforge.pain.logic.fn;
import net.sourceforge.pain.console.*;
import net.sourceforge.pain.data.type.*;
import net.sourceforge.pain.logic.fn.util.*;
/**
* PAiN Date: 04.06.2003 Time: 1:17:35
*/
public final class ShowFn {
public static void showSpace(Receptive receptive, Space space) {
if (!receptive.canSee()) {
MessageOutFn.outln(receptive, "You can't see anything!");
return;
}
Located looker = (Located) receptive.getRole(Located.class);
// if (looker.is(Builder.class)) {
//
// }
MessageOutFn.outln(receptive, "{W" + space.getName() + "{x", Receptive.SEE);
MessageOutFn.outln(receptive, space.getDesc(), Receptive.SEE);
for (Located obj = space.getFirstInSpace(); obj != null; obj = obj.getNextInSpace()) {
Interactive i = (Interactive) obj.getRole(Interactive.class);
if (i != null && obj != looker) {
MessageOutFn.outln(receptive, " " + i.getDesc(), Receptive.SEE);
}
}
}
public static void showObject(Receptive receptive, Interactive victim) {
final Console console = ConsoleFn.getConsole(receptive);
if (!receptive.canSee()) {
MessageOutFn.outln(console, "You can't see anything!");
return;
}
Physical p = (Physical) victim.getRole(Physical.class);
String appearanceDesc = p == null ? null : p.getAppearanceDesc();
MessageOutFn.outln(console, victim.getDesc());
if (p != null && appearanceDesc != null && appearanceDesc.length() != 0) {
MessageOutFn.outln(console, appearanceDesc);
}
LifeForm lf = (LifeForm) victim.getRole(LifeForm.class);
if (lf != null) {
Race r = lf.getRace();
MessageOutFn.outln(console, LangUtil.He(lf.getSex()) + " is " + r.getName().toLowerCase());
}
}
}