Command.java

jmud-0.11/src/Command.java · 1.1 KB

From the archive jmud-0_11.tgz

Download the archive   « Back to the archive contents

import java.util.StringTokenizer;

import util.bit.Bit;

abstract class Command {

    /* options */
    static final int OPT_PLR  = Bit.BIT0;
    static final int OPT_CRT  = Bit.BIT1;

  
    static protected Manager theManager = null;
    static protected World   theWorld   = null;

  static void setManager(Manager aManager) {
    theManager = aManager;
  }

  static void setWorld(World aWorld) {
    theWorld = aWorld;
  }
  
    private String theName = null;
    private int    minRank;
    private int    minPos;
    private int    options;
  
  Command(String name, int mRank, int mPos, int opt) {
    theName = name;
    minRank = mRank;
    minPos  = mPos;
    options = opt;
  }
    
    String getName() {
      return theName;
    }
    
    boolean hasName(String name) {
      return getName().startsWith(name);
    }
    
    int getMinRank() {
      return minRank;
    }

    int getMinPos() {
	return minPos;
    }

    boolean allowPlayer() {
	return Bit.isSet(options, OPT_PLR);
    }

    boolean allowCreature() {
	return Bit.isSet(options, OPT_CRT);
    }

    abstract void execute(Char aChar, StringTokenizer toker, String cmd, String cmdLine);
}

Site Stats

Snippets: 1791
Codebases: 571