Class games.Battle.server.BattleGame.BattleGame
All Packages  Class Hierarchy  This Package  Previous  Next  Index

Class games.Battle.server.BattleGame.BattleGame

java.lang.Object
   |
   +----games.Battle.server.BattleGame.BattleGame

public class BattleGame
extends Object
implements Runnable
BattleGame implements the server thread for one particular game running on the server. Many games may be simultanously in progress, and each one is an instance of a BattleGame with its own thread.

Constructor Index

 o BattleGame(Socket[], int, GameReferee, Logger)
construct a new game

Method Index

 o getBoard()
returns the board that the game is being played on
 o getPlayer(ServerSocket)
return a new player socket.
 o howMuchTime(long, String)
a function to time portions of the server to debug problems meeting the time bound
 o initBoard()
initialize a game board from scratch for this game.
 o initPlayer(int)
place the given player on the game board, and set up an input thread for the player
 o log(String)
a convenient log function that identifies which game we are as well as logging the message.
 o main(String[])
a mainline that allows this to run as a standalone application to debug the game thread outside of the full server
 o run()
the main game loop is in the run thread.
 o start()
start up the server game thread
 o stop()
halt this game

Constructors

 o BattleGame
  public BattleGame(Socket socket[],
                    int gameId,
                    GameReferee r,
                    Logger l)
construct a new game
Parameters:
socket - an array of sockets to all participants
gameId - the id of the GameInfo packet
r - the referee for this game
l - the logfile service for this game

Methods

 o getBoard
  public ServerBoard getBoard()
returns the board that the game is being played on
 o log
  public void log(String msg)
a convenient log function that identifies which game we are as well as logging the message.
Parameters:
msg - the message to be logged for this game
 o initBoard
  public void initBoard()
initialize a game board from scratch for this game.
 o getPlayer
  public static Socket getPlayer(ServerSocket ss)
return a new player socket. used to test the game thread outside the full server, as a standalone application.
 o initPlayer
  public void initPlayer(int p)
place the given player on the game board, and set up an input thread for the player
Parameters:
p - the player number of the player to set up.
 o main
  public static void main(String argv[])
a mainline that allows this to run as a standalone application to debug the game thread outside of the full server
 o start
  public void start()
start up the server game thread
 o stop
  public void stop()
halt this game
 o run
  public void run()
the main game loop is in the run thread. it updates the board, sends all the players the differences, and tris at all times to maintain a constant game pace.
 o howMuchTime
  public long howMuchTime(long oldtime,
                          String msg)
a function to time portions of the server to debug problems meeting the time bound

All Packages  Class Hierarchy  This Package  Previous  Next  Index