erland.game.tetris
Class TetrisPlayer

java.lang.Object
  extended by erland.game.tetris.TetrisPlayer
All Implemented Interfaces:
GamePlayerInterface

public class TetrisPlayer
extends Object
implements GamePlayerInterface


Field Summary
protected  boolean bEnd
          true if game is completed or game over has occurred
protected  erland.game.tetris.Block block
          Current active block in the main game area
protected  erland.game.tetris.Block blockNext
          Current active block in the preview block area
protected  GameServerEnvironmentInterface environment
          Game environment
protected  int level
          Current level
protected  erland.game.tetris.BlockContainerData mainContainer
          Container representing the main game area
protected  int MAX_LEVEL
          Number of levels
protected  int MAX_SPEED
          Maximum block speed
protected  int ROWS_PER_LEVEL
          Number of rows that has to be removed before level is increased
protected  int rowsThisLevel
          Number of rows that has been removed in this level
protected  long score
          Current score
protected  int updateCounter
          Counter that is increased every update, when it reaches the current game speed the active block will be moved down one step
 
Constructor Summary
TetrisPlayer(GameServerEnvironmentInterface environment)
           
 
Method Summary
 void doCommand(String command)
           
 String getBlockString(erland.game.tetris.Block b)
           
 NetworkConnectionInterface getConnection()
           
 int getLevel()
           
 erland.game.tetris.BlockContainerData getMainContainer()
           
 erland.game.tetris.Block getNextBlock()
           
 String getNumberString(int length, long number)
           
 long getScore()
           
 void init()
           
 boolean isCompleted()
           
 boolean isGameOver()
           
 boolean moveDown()
          Move the active block in the main game area one step down
 boolean moveDownBottom()
           
 boolean moveLeft()
          Move the active block in the main game area one step left
 boolean moveRight()
          Move the active block in the main game area one step right
 boolean needUpdate()
           
protected  void removeCompletedRows()
          Removes all completed rows in the main game area and increases score
 boolean rotateRight()
          Rotate the active block in the main game area 90 degrees clockwize
 void setConnection(NetworkConnectionInterface connection)
           
 void startNewGame()
           
 String toString()
           
 boolean update()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

block

protected erland.game.tetris.Block block
Current active block in the main game area


blockNext

protected erland.game.tetris.Block blockNext
Current active block in the preview block area


updateCounter

protected int updateCounter
Counter that is increased every update, when it reaches the current game speed the active block will be moved down one step


MAX_LEVEL

protected final int MAX_LEVEL
Number of levels

See Also:
Constant Field Values

MAX_SPEED

protected final int MAX_SPEED
Maximum block speed

See Also:
Constant Field Values

score

protected long score
Current score


level

protected int level
Current level


rowsThisLevel

protected int rowsThisLevel
Number of rows that has been removed in this level


mainContainer

protected erland.game.tetris.BlockContainerData mainContainer
Container representing the main game area


ROWS_PER_LEVEL

protected final int ROWS_PER_LEVEL
Number of rows that has to be removed before level is increased

See Also:
Constant Field Values

bEnd

protected boolean bEnd
true if game is completed or game over has occurred


environment

protected GameServerEnvironmentInterface environment
Game environment

Constructor Detail

TetrisPlayer

public TetrisPlayer(GameServerEnvironmentInterface environment)
Method Detail

setConnection

public void setConnection(NetworkConnectionInterface connection)
Specified by:
setConnection in interface GamePlayerInterface

getConnection

public NetworkConnectionInterface getConnection()
Specified by:
getConnection in interface GamePlayerInterface

doCommand

public void doCommand(String command)

init

public void init()

startNewGame

public void startNewGame()

isGameOver

public boolean isGameOver()

isCompleted

public boolean isCompleted()

update

public boolean update()

removeCompletedRows

protected void removeCompletedRows()
Removes all completed rows in the main game area and increases score


getBlockString

public String getBlockString(erland.game.tetris.Block b)

getNumberString

public String getNumberString(int length,
                              long number)

toString

public String toString()
Overrides:
toString in class Object

moveLeft

public boolean moveLeft()
Move the active block in the main game area one step left

Returns:
true/false (Success/Failure)

moveRight

public boolean moveRight()
Move the active block in the main game area one step right

Returns:
true/false (Success/Failure)

rotateRight

public boolean rotateRight()
Rotate the active block in the main game area 90 degrees clockwize

Returns:
true/false (Success/Failure)

moveDown

public boolean moveDown()
Move the active block in the main game area one step down

Returns:
true/false (Success/Failure)

moveDownBottom

public boolean moveDownBottom()

needUpdate

public boolean needUpdate()

getMainContainer

public erland.game.tetris.BlockContainerData getMainContainer()

getNextBlock

public erland.game.tetris.Block getNextBlock()

getScore

public long getScore()

getLevel

public int getLevel()


Copyright © 2003-2006 Erland Isaksson. All Rights Reserved.