Drop.java

mudlibs/tinylib/src/net/sourceforge/pain/tinylib/logic/event/console/command/Drop.java · 1.3 KB

From the archive pain_0_45.tgz

Download the archive   « Back to the archive contents

package net.sourceforge.pain.tinylib.logic.event.console.command;

import net.sourceforge.pain.tinylib.data.type.*;
import net.sourceforge.pain.tinylib.logic.event.console.*;
import net.sourceforge.pain.tinylib.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");
    }

}

Site Stats

Snippets: 1791
Codebases: 571