package net.sourceforge.pain.logic.event.console.command;
import net.sourceforge.pain.data.type.*;
import net.sourceforge.pain.logic.affect.*;
import net.sourceforge.pain.logic.fn.*;
import net.sourceforge.pain.*;
public final class Freeze extends GrantedCommand {
public void processCommand() throws Exception {
String target = commandParams;
final boolean stopFreeze = "OFF".equals(command.tag);
if (target == null || target.length() == 0) {
MessageOutFn.outln(console, stopFreeze ? "Remove freeze from whom?" : "Freeze whom?");
return;
}
final Interactive victim = SpaceFindFn.findByPrefix(player.asLocated(), target);
if (victim == null) {
MessageOutFn.outln(console, "They aren't here");
return;
}
Mobile mob = (Mobile) victim.getRole(Mobile.class);
if (mob == null) {
MessageOutFn.outln(console, "You failed.");
return;
}
if (stopFreeze) {
if (!victim.isAffected(AffectType.AFFECT_IMMOBILE)) {
MessageOutFn.outOne(player, "$n is frozen.", victim);
} else {
ImmobilityAffect.cancelAffect(mob);
MessageOutFn.outln(player, "FREEZE removed.");
}
} else {
if (victim.isAffected(AffectType.AFFECT_IMMORTAL)) {
MessageOutFn.outln(player, "Not on immortals.");
} else if (victim.isAffected(AffectType.AFFECT_IMMOBILE)) {
MessageOutFn.outln(player, "Already frozen.");
} else {
ImmobilityAffect.applyToObject((Mobile) victim.getRole(Mobile.class), Time.PULSE_PER_MIN);
MessageOutFn.outln(player, "FREEZE set.");
}
}
}
public void showHelp() {
final boolean stopFreeze = "OFF".equals(command.tag);
if (stopFreeze) {
MessageOutFn.outln(console, command.name + ": remove IMMOBILE affect from target");
} else {
MessageOutFn.outln(console, command.name + ": adds IMMOBILE affect to victim");
}
}
}