Class GameClient

java.lang.Object
  |
  +--GameClient

public class GameClient
extends java.lang.Object

LOA game client for Gamed server.

Version:
$Revision: 1.5 $
Author:
Bart Massey

Field Summary
 int black_time_control
          Number of seconds black player has at start of game, if playing under time controls.
 Move move
          Move returned by get_move() method as side-effect.
 int my_time
          Number of seconds the client has currently remaining, if playing under time controls.
 int opp_time
          Number of seconds the client's opponent has currently remaining, if playing under time controls.
static int STATE_CONTINUE
          Game will continue.
static int STATE_DONE
          Game over.
 boolean time_controls
          True if playing under time controls.
 int white_time_control
          Number of seconds white player has at start of game, if playing under time controls.
 int who
          Which side this client is playing.
static int WHO_BLACK
          Player is black.
static int WHO_NONE
          Player is nobody.
static int WHO_OTHER
          Player is undefined.
static int WHO_WHITE
          Player is white.
 int winner
          If done, player which won.
 
Constructor Summary
GameClient(int side, java.lang.String host, int server)
          Construct a game client, connected to the specified server and ready to play.
 
Method Summary
 int get_move()
          Get a move from the server.
 int make_move(Move m)
          Make a move on the server.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

WHO_NONE

public static final int WHO_NONE
Player is nobody.

WHO_WHITE

public static final int WHO_WHITE
Player is white.

WHO_BLACK

public static final int WHO_BLACK
Player is black.

WHO_OTHER

public static final int WHO_OTHER
Player is undefined.

STATE_CONTINUE

public static final int STATE_CONTINUE
Game will continue.

STATE_DONE

public static final int STATE_DONE
Game over.

who

public int who
Which side this client is playing.

winner

public int winner
If done, player which won.

move

public Move move
Move returned by get_move() method as side-effect.

time_controls

public boolean time_controls
True if playing under time controls.

white_time_control

public int white_time_control
Number of seconds white player has at start of game, if playing under time controls.

black_time_control

public int black_time_control
Number of seconds black player has at start of game, if playing under time controls.

my_time

public int my_time
Number of seconds the client has currently remaining, if playing under time controls.

opp_time

public int opp_time
Number of seconds the client's opponent has currently remaining, if playing under time controls.
Constructor Detail

GameClient

public GameClient(int side,
                  java.lang.String host,
                  int server)
           throws java.io.IOException
Construct a game client, connected to the specified server and ready to play.
Parameters:
side - Should be either WHO_WHITE or WHO_BLACK. Side the client will play.
host - Hostname of the server.
server - Server number of server on host.
Throws:
java.io.IOException - Unable to connect to specified server as specified side.
Method Detail

make_move

public int make_move(Move m)
              throws java.io.IOException
Make a move on the server. The server must be expecting a move (that is, it must be this client's turn), and the move must be legal.
Parameters:
m - What move to make.
Throws:
java.io.IOException - Move is illegal or communication failed.

get_move

public int get_move()
             throws java.io.IOException
Get a move from the server. The server must be expecting a move from the opponent (that is, it must be this client's opponent's turn). The move field will indicate the returned move.
Throws:
java.io.IOException - Move is illegal or communication failed.