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.
-
CHANNEL_PORT
-
-
d_mazeHeight
-
-
d_mazeWidth
-
-
DEBUG
-
-
EMPTY
-
-
GROUP_NAME
-
-
INITIAL_MONSTER_POWER
-
-
INITIAL_PLAYER_POWER
-
-
ITEM
-
-
MONSTER
-
-
NONE
-
-
PLAYER
-
-
PROPS
-
-
RMI_TIMEOUT
-
-
VC_GET_USER_STAT
-
-
VC_MASTER_INIT
-
-
VC_PROCESSING
-
-
VC_READY
-
-
VC_STATE_TRANSFER
-
-
WALL
-
-
MudUtil()
-
-
color2string(Color)
- Translates colors to regular english names.
-
Debug(String)
- Used for debug messages.
-
die(Exception)
- Dies with a message to stderr
-
die(String)
- Dies with a message to stderr
-
die(String, Exception)
- Dies with a message to stderr
-
getHostName()
- Gets the host name of the machine the program is running on
-
isNeighbor(int, int, int, int)
- Checks if two points are close to each other by the following rule :
1.
-
printMaze(int[][])
- A debug method.
-
printSquare(int[][], int, int)
- Debug method.
-
readMazeFile()
- Reads a file ( d_mazeFile ) which consists of the following format :
num of lines , num of rows
line 1
line 2 ....
-
sleep(long)
- Sleeps some time.
DEBUG
public static final boolean DEBUG
GROUP_NAME
public static final String GROUP_NAME
CHANNEL_PORT
public static final int CHANNEL_PORT
RMI_TIMEOUT
public static final int RMI_TIMEOUT
PROPS
public static final String PROPS
VC_READY
public static final int VC_READY
VC_PROCESSING
public static final int VC_PROCESSING
VC_GET_USER_STAT
public static final int VC_GET_USER_STAT
VC_MASTER_INIT
public static final int VC_MASTER_INIT
VC_STATE_TRANSFER
public static final int VC_STATE_TRANSFER
d_mazeWidth
public static int d_mazeWidth
d_mazeHeight
public static int d_mazeHeight
EMPTY
public static final int EMPTY
WALL
public static final int WALL
ITEM
public static final int ITEM
PLAYER
public static final int PLAYER
MONSTER
public static final int MONSTER
NONE
public static final int NONE
INITIAL_PLAYER_POWER
public static final int INITIAL_PLAYER_POWER
INITIAL_MONSTER_POWER
public static final int INITIAL_MONSTER_POWER
MudUtil
public MudUtil()
getHostName
public static String getHostName()
- Gets the host name of the machine the program is running on
- Returns:
- String machine name
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
color2string
public static String color2string(Color c)
- Translates colors to regular english names. Knows only few colors
- Parameters:
- c - Color
- Returns:
- String color name
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.
die
public static void die(Exception e)
- Dies with a message to stderr
- Parameters:
- e - The exception that occured
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
die
public static void die(String e)
- Dies with a message to stderr
- Parameters:
- e - A string to add to the error message
sleep
public static void sleep(long milliseconds)
- Sleeps some time.
- Parameters:
- milliseconds - number of milliseconds to sleep.
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
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.
printMaze
public static void printMaze(int m[][])
- A debug method. Prints the whole maze
- Parameters:
- m - int[][] - The maze.