Class Game

java.lang.Object
  extended by Game

public class Game
extends java.lang.Object

A game object is responsible for keeping track of the exact state of the game, for updating the state of the game once both players have reported their moves, and for making callbacks to the GameServer once both player moves have been reported and the game advances to a new move.


Constructor Summary
Game()
          Creates a Game object (which keeps track of a rock-paper-scissors match).
 
Method Summary
 void makeMove(GameServer server, int playerNumber, long moveNumber, Move move)
          This method, called by GameServer, indicates that the given player has committed to the given move, for the given moveNumber.
 void startGame(GameServer server)
          Called by the server to start the game.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Game

public Game()
Creates a Game object (which keeps track of a rock-paper-scissors match).

Method Detail

startGame

public void startGame(GameServer server)
Called by the server to start the game.

Parameters:
server - reference to the GameServer object, used for callback to moveAvailable.

makeMove

public void makeMove(GameServer server,
                     int playerNumber,
                     long moveNumber,
                     Move move)
This method, called by GameServer, indicates that the given player has committed to the given move, for the given moveNumber. This should only be called for the current move, and is ignored if the moveNumber doesn't match the serial number of the current game move. Once both players have been committed to a move, the game is updated to reflect this change in state, and (provided the game isn't over) a callback is made to the moveAvailable method of the given GameServer object.

Parameters:
server - the GameServer to make the moveAvailable callback to.
playerNumber - the ID number of the player making the move.
moveNumber - the serial number of the game move for which a move is being reported.
move - the move to make in the game. Cannot be null.