Class MudUtil

java.lang.Object
   |
   +----MudUtil

public class MudUtil
extends Object
General utility class which helps in some common taks which are general to all application. e.g : handeling printing an exception and exit. All functions are static so no need to create an instance.


Variable Index

 o CHANNEL_PORT
 o d_mazeHeight
 o d_mazeWidth
 o DEBUG
 o EMPTY
 o GROUP_NAME
 o INITIAL_MONSTER_POWER
 o INITIAL_PLAYER_POWER
 o ITEM
 o MONSTER
 o NONE
 o PLAYER
 o PROPS
 o RMI_TIMEOUT
 o VC_GET_USER_STAT
 o VC_MASTER_INIT
 o VC_PROCESSING
 o VC_READY
 o VC_STATE_TRANSFER
 o WALL

Constructor Index

 o MudUtil()

Method Index

 o color2string(Color)
Translates colors to regular english names.
 o Debug(String)
Used for debug messages.
 o die(Exception)
Dies with a message to stderr
 o die(String)
Dies with a message to stderr
 o die(String, Exception)
Dies with a message to stderr
 o getHostName()
Gets the host name of the machine the program is running on
 o isNeighbor(int, int, int, int)
Checks if two points are close to each other by the following rule : 1.
 o printMaze(int[][])
A debug method.
 o printSquare(int[][], int, int)
Debug method.
 o readMazeFile()
Reads a file ( d_mazeFile ) which consists of the following format : num of lines , num of rows line 1 line 2 ....
 o sleep(long)
Sleeps some time.

Variables

 o DEBUG
 public static final boolean DEBUG
 o GROUP_NAME
 public static final String GROUP_NAME
 o CHANNEL_PORT
 public static final int CHANNEL_PORT
 o RMI_TIMEOUT
 public static final int RMI_TIMEOUT
 o PROPS
 public static final String PROPS
 o VC_READY
 public static final int VC_READY
 o VC_PROCESSING
 public static final int VC_PROCESSING
 o VC_GET_USER_STAT
 public static final int VC_GET_USER_STAT
 o VC_MASTER_INIT
 public static final int VC_MASTER_INIT
 o VC_STATE_TRANSFER
 public static final int VC_STATE_TRANSFER
 o d_mazeWidth
 public static int d_mazeWidth
 o d_mazeHeight
 public static int d_mazeHeight
 o EMPTY
 public static final int EMPTY
 o WALL
 public static final int WALL
 o ITEM
 public static final int ITEM
 o PLAYER
 public static final int PLAYER
 o MONSTER
 public static final int MONSTER
 o NONE
 public static final int NONE
 o INITIAL_PLAYER_POWER
 public static final int INITIAL_PLAYER_POWER
 o INITIAL_MONSTER_POWER
 public static final int INITIAL_MONSTER_POWER

Constructors

 o MudUtil
 public MudUtil()

Methods

 o getHostName
 public static String getHostName()
Gets the host name of the machine the program is running on

Returns:
String machine name
 o isNeighbor
 public static boolean isNeighbor(int x1,
                                  int y1,
                                  int x2,
                                  int y2)
Checks if two points are close to each other by the following rule : 1. they have the same X coord and differ at 1 with the Y coord. OR 2. they have the same Y coord and differ at 1 with the X coord.

Parameters:
x1 - First x coord.
y1 - First y coord.
x2 - Second x coord.
y2 - Second y coord.
Returns:
boolean
 o color2string
 public static String color2string(Color c)
Translates colors to regular english names. Knows only few colors

Parameters:
c - Color
Returns:
String color name
 o readMazeFile
 public static int[][] readMazeFile()
Reads a file ( d_mazeFile ) which consists of the following format : num of lines , num of rows line 1 line 2 ....

Returns:
int[][] the maze read from the file.
 o die
 public static void die(Exception e)
Dies with a message to stderr

Parameters:
e - The exception that occured
 o die
 public static void die(String s,
                        Exception e)
Dies with a message to stderr

Parameters:
s - A string to add to the error message
e - The exception that occured
 o die
 public static void die(String e)
Dies with a message to stderr

Parameters:
e - A string to add to the error message
 o sleep
 public static void sleep(long milliseconds)
Sleeps some time.

Parameters:
milliseconds - number of milliseconds to sleep.
 o printSquare
 public static void printSquare(int m[][],
                                int x,
                                int y)
Debug method. Prints squares near to a coord given

Parameters:
m - int[][] - the maze
x - int : the x coord
y - int : the y coord
 o Debug
 public static void Debug(String s)
Used for debug messages. If MudUtil.DEBUG is false will not print any debug messages.

Parameters:
s - The message to print to the stderr.
 o printMaze
 public static void printMaze(int m[][])
A debug method. Prints the whole maze

Parameters:
m - int[][] - The maze.