de.farafin.snEADy.communication
Class D_Level

java.lang.Object
  extended by de.farafin.snEADy.communication.D_Level
All Implemented Interfaces:
I_PlayFieldConstants

public final class D_Level
extends java.lang.Object
implements I_PlayFieldConstants

The Level with all its informations

Version:
$Revision: 1.26 $
Author:
roland, lars

Field Summary
 java.lang.String author
          the author of the level
 java.lang.String comment
          Comment to this arena
 java.lang.String fileName
          the filename of the level
 int height
          height of the playfield
 int maxPlayer
          the number of maximum player this level was designt for
 java.lang.String name
          name of the arena
 char[][] playField
          the playfield of the game
 int width
          width of the playfield
 
Fields inherited from interface de.farafin.snEADy.communication.I_PlayFieldConstants
EXIT, FIELD_B, FIELD_C, FIELD_D, FIELD_E, FIELD_F, FIELD_G, FIELD_H, FIELD_I, FIELD_J, FIELD_K, FIELD_L, FIELD_M, FIELD_N, FIELD_O, FIELD_P, FIELD_Q, FIELD_R, FIELD_S, FIELD_T, FIELD_U, FIELD_V, FIELD_W, FIELD_X, FIELD_Y, FIELD_Z, FREE, GOODY_f, GOODY_g, GOODY_h, GOODY_i, GOODY_j, GOODY_k, GOODY_l, GOODY_LAST, GOODY_m, GOODY_n, GOODY_o, GOODY_p, GOODY_q, GOODY_r, GOODY_s, GOODY_START, GOODY_t, GOODY_u, GOODY_v, GOODY_w, GOODY_x, GOODY_y, GOODY_z, LENGTH, PLAYER_0, PLAYER_1, PLAYER_2, PLAYER_3, PLAYER_4, PLAYER_5, PLAYER_6, PLAYER_7, PLAYER_8, PLAYER_9, POINTS, SHORT, SLOW, SPEED, WALL
 
Constructor Summary
D_Level()
          default - constructor
D_Level(D_Level level)
          copy - constructor reference-copy of attrbutes: use copy() if you need a full copy
D_Level(java.lang.String name, int height, int width, char[][] playField, int maxPlayer)
          arena-based constructor
D_Level(java.lang.String fileName, java.lang.String name, java.lang.String author, char[][] playField, int maxPlayer)
          constructor
D_Level(java.lang.String fileName, java.lang.String name, java.lang.String author, int height, int width, char[][] playField, int maxPlayer)
          create - constructor
 
Method Summary
 java.lang.Object clone()
           
 void copyOnMe(D_Level level)
          copys all data from level to the lokal instance. there is no new Instance created if all array sizes fit to each other
 char getCharOf(D_Vec2D vec)
          returns the character of the specified coordinates
 char getCharOf(int y, int x)
          returns the character of the specified coordinates
 int getHeight()
           
 char[] getLineCopy(int l)
           
 int getMaxPlayer()
           
 java.lang.String getName()
           
 char[][] getPlayFieldCopy()
           
 char[] getRowCopy(int r)
           
 int getWidth()
           
protected  boolean isFieldOfLevel(D_Vec2D vec)
          tests if the coordinates are element of the playField
protected  boolean isFieldOfLevel(int y, int x)
          tests if the coordinates are element of the playField
 boolean isFree(D_Vec2D vec)
           
 boolean isFree(int y, int x)
           
 boolean isGoody(D_Vec2D vec)
           
 boolean isGoody(int y, int x)
           
 boolean isSnake(D_Vec2D vec)
           
 boolean isSnake(int y, int x)
           
 boolean isSpecialField(D_Vec2D vec)
           
 boolean isSpecialField(int y, int x)
           
 boolean isWall(D_Vec2D vec)
           
 boolean isWall(int y, int x)
           
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

fileName

public java.lang.String fileName
the filename of the level


name

public java.lang.String name
name of the arena


comment

public java.lang.String comment
Comment to this arena


author

public java.lang.String author
the author of the level


height

public int height
height of the playfield


width

public int width
width of the playfield


playField

public char[][] playField
the playfield of the game


maxPlayer

public int maxPlayer
the number of maximum player this level was designt for

Constructor Detail

D_Level

public D_Level()
default - constructor


D_Level

public D_Level(java.lang.String fileName,
               java.lang.String name,
               java.lang.String author,
               int height,
               int width,
               char[][] playField,
               int maxPlayer)
create - constructor

Parameters:
fileName -
name -
author -
height -
width -
playField -
maxPlayer -

D_Level

public D_Level(java.lang.String fileName,
               java.lang.String name,
               java.lang.String author,
               char[][] playField,
               int maxPlayer)
constructor

Parameters:
fileName -
name -
author -
playField -
maxPlayer -

D_Level

public D_Level(D_Level level)
copy - constructor reference-copy of attrbutes: use copy() if you need a full copy

Parameters:
level -

D_Level

public D_Level(java.lang.String name,
               int height,
               int width,
               char[][] playField,
               int maxPlayer)
arena-based constructor

Parameters:
name -
height -
width -
playField -
maxPlayer -
Method Detail

clone

public java.lang.Object clone()
Overrides:
clone in class java.lang.Object

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object

isFieldOfLevel

protected boolean isFieldOfLevel(int y,
                                 int x)
tests if the coordinates are element of the playField

Parameters:
y - line
x - row
Returns:
true if the coordiantes are in height - and width - renge

isFieldOfLevel

protected boolean isFieldOfLevel(D_Vec2D vec)
tests if the coordinates are element of the playField

Parameters:
vec - coordinate as 2D-vector
Returns:
true if the coordiantes are in height - and width - renge

getPlayFieldCopy

public char[][] getPlayFieldCopy()
Returns:
Returns a copy of the playField.

getCharOf

public char getCharOf(int y,
                      int x)
returns the character of the specified coordinates

Parameters:
y - line number
x - row number
Returns:
the charactor of the specified field and '?' if the field does not exist

getCharOf

public char getCharOf(D_Vec2D vec)
returns the character of the specified coordinates

Parameters:
vec - the vector of the field that should returned
Returns:
the charactor of the specified field

getLineCopy

public char[] getLineCopy(int l)
Parameters:
l - lineNumber
Returns:
the line, null if line doesnt exist

getRowCopy

public char[] getRowCopy(int r)
Parameters:
r - rowNumber
Returns:
the row, null if row doesnt exist

getHeight

public int getHeight()
Returns:
Returns the height.

getMaxPlayer

public int getMaxPlayer()
Returns:
Returns the maxPlayer.

getName

public java.lang.String getName()
Returns:
Returns the name.

getWidth

public int getWidth()
Returns:
Returns the width.

isFree

public boolean isFree(int y,
                      int x)
Parameters:
y - line
x - row
Returns:
true if there is a goody at the coordinates
See Also:
I_PlayFieldConstants

isFree

public boolean isFree(D_Vec2D vec)
Parameters:
vec - controll this position
Returns:
true if there is a goody at vec position
See Also:
I_PlayFieldConstants

isWall

public boolean isWall(int y,
                      int x)
Parameters:
y - line
x - row
Returns:
true if there is a goody at the coordinates
See Also:
I_PlayFieldConstants

isWall

public boolean isWall(D_Vec2D vec)
Parameters:
vec - controll this position
Returns:
true if there is a goody at vec position
See Also:
I_PlayFieldConstants

isSnake

public boolean isSnake(int y,
                       int x)
Parameters:
y - line
x - row
Returns:
true if there is a goody at the coordinates
See Also:
I_PlayFieldConstants

isSnake

public boolean isSnake(D_Vec2D vec)
Parameters:
vec - controll this position
Returns:
true if there is a goody at vec position
See Also:
I_PlayFieldConstants

isGoody

public boolean isGoody(int y,
                       int x)
Parameters:
y - line
x - row
Returns:
true if there is a goody at the coordinates
See Also:
I_PlayFieldConstants

isGoody

public boolean isGoody(D_Vec2D vec)
Parameters:
vec - controll this position
Returns:
true if there is a goody at vec position
See Also:
I_PlayFieldConstants

isSpecialField

public boolean isSpecialField(int y,
                              int x)
Parameters:
y - line
x - row
Returns:
true if there is a goody at the coordinates
See Also:
I_PlayFieldConstants

isSpecialField

public boolean isSpecialField(D_Vec2D vec)
Parameters:
vec - controll this position
Returns:
true if there is a goody at vec position
See Also:
I_PlayFieldConstants

copyOnMe

public void copyOnMe(D_Level level)
copys all data from level to the lokal instance. there is no new Instance created if all array sizes fit to each other

Parameters:
level - the origin where the date should be copyed from