klaus.backend
Class OfflinePlayingBackend

java.lang.Object
  extended by klaus.backend.NullBackend
      extended by klaus.backend.OfflinePlayingBackend
All Implemented Interfaces:
ChessBackend, ScrollingBackend
Direct Known Subclasses:
AnalyzeBackend

public class OfflinePlayingBackend
extends NullBackend
implements ScrollingBackend


Nested Class Summary
private  class OfflinePlayingBackend.UpdateThread
           
 
Field Summary
private  Engine black
           
private  long blackTime
           
private  boolean gameRunning
           
private  int increment
           
private  boolean incremented
           
private  long lastUpdateTime
           
protected  Party party
           
private  int plyPointer
          The current ply number
private  int secondPeriod
           
private  int secondPeriodStart
           
private  boolean secondStarted
           
private  boolean started
           
private  int startingTimeInMinutes
          Values for time on startup used for engine time management
private  boolean stopped
           
private  int thirdPeriod
           
private  int thirdPeriodStart
           
private  boolean thirdStarted
           
private  Engine white
           
private  long whiteTime
           
 
Fields inherited from class klaus.backend.NullBackend
active
 
Constructor Summary
OfflinePlayingBackend()
           
 
Method Summary
 boolean addMove(Move move)
          Add a certain move to the backend.
 void fireResultListeners(Result result)
           
 void forceMove()
           
 Engine getBlack()
           
 long getBlackTime()
          Gives the remaining time for black [im milliseconds]
 Party getParty()
           
 Position getPosition()
           
 Engine getWhite()
           
 long getWhiteTime()
          Gives the remaining time for white [in milliseconds]
 void goToFirst()
           
 void goToLast()
           
 void goToNext()
           
 void goToPrevious()
           
 boolean isEngineThinking()
           
 boolean isGameRunning()
           
 void setBlackEngine(Engine e)
           
 void setGameModel(NewGameModel model)
           
 void setWhiteEngine(Engine e)
           
 void startCalculation()
           
 void unload()
          Unload the backend, e. g. close file/database/process connections
private  void updateTimes()
          Update the clocks for both players.
 
Methods inherited from class klaus.backend.NullBackend
addMoveListener, addResultListener, fireMoveListeners, removeMoveListener, removeResultListener, setActive, setInactive, setPosition
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

lastUpdateTime

private long lastUpdateTime

party

protected Party party

started

private boolean started

stopped

private boolean stopped

white

private Engine white

black

private Engine black

whiteTime

private long whiteTime

blackTime

private long blackTime

startingTimeInMinutes

private int startingTimeInMinutes
Values for time on startup used for engine time management


gameRunning

private boolean gameRunning

plyPointer

private int plyPointer
The current ply number


secondPeriodStart

private int secondPeriodStart

secondPeriod

private int secondPeriod

thirdPeriodStart

private int thirdPeriodStart

thirdPeriod

private int thirdPeriod

increment

private int increment

secondStarted

private boolean secondStarted

thirdStarted

private boolean thirdStarted

incremented

private boolean incremented
Constructor Detail

OfflinePlayingBackend

public OfflinePlayingBackend()
Method Detail

addMove

public boolean addMove(Move move)
Description copied from interface: ChessBackend
Add a certain move to the backend. The backend has to react to this move. If the move is accepted, true is returned and the move can be displayed. If not, the interface should beep and/or show an error message.

Specified by:
addMove in interface ChessBackend
Overrides:
addMove in class NullBackend
Parameters:
move - the move that has been done by the user
Returns:
true if the move was accepted, else false

forceMove

public void forceMove()

getBlack

public Engine getBlack()

getBlackTime

public long getBlackTime()
Description copied from interface: ChessBackend
Gives the remaining time for black [im milliseconds]

Specified by:
getBlackTime in interface ChessBackend
Overrides:
getBlackTime in class NullBackend
Returns:

getParty

public Party getParty()
Specified by:
getParty in interface ChessBackend
Overrides:
getParty in class NullBackend

getPosition

public Position getPosition()
Specified by:
getPosition in interface ChessBackend
Overrides:
getPosition in class NullBackend

getWhite

public Engine getWhite()

getWhiteTime

public long getWhiteTime()
Description copied from interface: ChessBackend
Gives the remaining time for white [in milliseconds]

Specified by:
getWhiteTime in interface ChessBackend
Overrides:
getWhiteTime in class NullBackend
Returns:

goToFirst

public void goToFirst()
Specified by:
goToFirst in interface ScrollingBackend

goToLast

public void goToLast()
Specified by:
goToLast in interface ScrollingBackend

goToNext

public void goToNext()
Specified by:
goToNext in interface ScrollingBackend

goToPrevious

public void goToPrevious()
Specified by:
goToPrevious in interface ScrollingBackend

isEngineThinking

public boolean isEngineThinking()

setBlackEngine

public void setBlackEngine(Engine e)

setWhiteEngine

public void setWhiteEngine(Engine e)

startCalculation

public void startCalculation()

unload

public void unload()
Description copied from interface: ChessBackend
Unload the backend, e. g. close file/database/process connections

Specified by:
unload in interface ChessBackend
Overrides:
unload in class NullBackend

updateTimes

private void updateTimes()
Update the clocks for both players. This method is called a) when the game is started and b) by the UpdateThread ca. each 100 miliseconds.


fireResultListeners

public void fireResultListeners(Result result)
Specified by:
fireResultListeners in interface ChessBackend
Overrides:
fireResultListeners in class NullBackend

setGameModel

public void setGameModel(NewGameModel model)

isGameRunning

public boolean isGameRunning()
Specified by:
isGameRunning in interface ChessBackend
Overrides:
isGameRunning in class NullBackend