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