net.sourceforge.yagurashogi.server
Class Game

java.lang.Object
  extended by net.sourceforge.yagurashogi.server.Game

public class Game
extends java.lang.Object

Object containing all the information about proposed and started games.


Field Summary
static int FINISHED
           
 Player player1
           
 Player player2
           
static int PROPOSED
           
static int STARTED
           
 
Constructor Summary
Game(ShogiServer shogiServer, java.lang.String gameName, Player p1, Player p2)
          Creates new game proposal for two players.
 
Method Summary
 void agree(Player who)
          One of the players agrees to the conditions.
 void claimWin(Player who)
          One of the players claims that he has won.
 int getByoyomi()
          Returns byoyomi (maximum time for one move).
 Player getCurrentPlayer()
          Returns the player whose turn is now.
 int getState()
          Returns game's current state.
 long getTimeOfStart()
          Returns the timestamp of when the game started.
 long getTimestamp()
          Returns the timestamp of when last move has taken place.
 int getTotalTime()
          Returns game's maximum time
 boolean move(Player who, java.lang.String what)
          One of the players wants to move one of his pieces.
 void reject(Player who)
          One of the players rejects the conditions.
 void remove()
          Remove game.
 void sendConditions()
          Sends game conditions to both players.
 void surrender(Player who)
          One of the players surrenders.
 void timeUp(Player who)
          Deals with the situation when the time is up.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

player1

public Player player1

player2

public Player player2

PROPOSED

public static final int PROPOSED
See Also:
Constant Field Values

STARTED

public static final int STARTED
See Also:
Constant Field Values

FINISHED

public static final int FINISHED
See Also:
Constant Field Values
Constructor Detail

Game

public Game(ShogiServer shogiServer,
            java.lang.String gameName,
            Player p1,
            Player p2)
Creates new game proposal for two players.

Parameters:
shogiServer - server on which the game is to be played
gameName - unique game ID
p1 - first player
p2 - second player
Method Detail

getState

public int getState()
Returns game's current state.

Returns:
current state

getTimeOfStart

public long getTimeOfStart()
Returns the timestamp of when the game started.

Returns:
time of start (in milliseconds)

getTimestamp

public long getTimestamp()
Returns the timestamp of when last move has taken place.

Returns:
time of last move (in milliseconds)

getByoyomi

public int getByoyomi()
Returns byoyomi (maximum time for one move).

Returns:
game's byoyomi

getTotalTime

public int getTotalTime()
Returns game's maximum time

Returns:
maximum time the game can be played

getCurrentPlayer

public Player getCurrentPlayer()
Returns the player whose turn is now.

Returns:
player with his turn now.

sendConditions

public void sendConditions()
Sends game conditions to both players.


timeUp

public void timeUp(Player who)
Deals with the situation when the time is up.

Parameters:
who - the player that reached byoyomi or null when the total match time is up

agree

public void agree(Player who)
One of the players agrees to the conditions.

Parameters:
who - the player that agrees

reject

public void reject(Player who)
One of the players rejects the conditions.

Parameters:
who - the player that rejects

surrender

public void surrender(Player who)
One of the players surrenders.

Parameters:
who - the player that surrenders

claimWin

public void claimWin(Player who)
One of the players claims that he has won.

Parameters:
who - the player that claims win

move

public boolean move(Player who,
                    java.lang.String what)
One of the players wants to move one of his pieces.

Parameters:
who - the player that moves
what - the action, eg. +7776FU
Returns:
true if move was legal, false otherwise

remove

public void remove()
Remove game.