Glomus.Server
Class RemotePlayer

java.lang.Object
  extended by Glomus.Server.Player
      extended by Glomus.Server.RemotePlayer

public class RemotePlayer
extends Player

The Player Class is used within the Server to keep track of remote players. The Player class has cards, a location, and a character that it is playing as. The Game class uses the Player to determine if an illegal move has been made, and to communicate with the actual remote Player

See Also:
Protocol

Constructor Summary
RemotePlayer(java.net.Socket link)
          Creates the server-side representation of an remote player.
 
Method Summary
 java.lang.String accuse()
          Asks the Player to communicate with its remote counterpart and make an accusation if they wish
 void deletePlayer()
          Closes all I/O streams and sockets for this player.
 void forward(java.lang.String message)
          Forwards the broadcast message to its remote counterpart
 java.lang.String getAnswer()
          Asks the player to tell us all the pieces of the answer that it knows for sure
 java.lang.String refute(java.lang.String claim)
          Asks the Player to communicate with its remote counterpart and make a refutation of the last suggestion (if it can)
 java.lang.String suggest()
          Asks the Player to communicate with its remote counterpart and make a suggestion
 
Methods inherited from class Glomus.Server.Player
forceMove, getCards, getInit, getLocation, getName, initialize
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

RemotePlayer

public RemotePlayer(java.net.Socket link)
             throws java.io.IOException
Creates the server-side representation of an remote player. Note, the constructor only initializes the data that is neccesary for communication, in order to play a new game, the newGame method must be called

Parameters:
The - Socket on which the real remote player is communicating
Throws:
java.io.IOException - If the I/O streams from the socket cannot be initialized
Method Detail

suggest

public java.lang.String suggest()
                         throws IllegalTurnException,
                                TimeoutException,
                                NetworkFailureException,
                                java.lang.IllegalArgumentException
Asks the Player to communicate with its remote counterpart and make a suggestion

Overrides:
suggest in class Player
Returns:
The claim made by the player, in the form, "claim [suspect] [weapon] [room] [player]"
Throws:
IllegalTurnException - if player does not move to proper room
java.lang.IllegalArgumentException - when player's message includes illegal values
TimeoutException
NetworkFailureException

refute

public java.lang.String refute(java.lang.String claim)
                        throws IllegalTurnException,
                               TimeoutException,
                               NetworkFailureException
Asks the Player to communicate with its remote counterpart and make a refutation of the last suggestion (if it can)

Overrides:
refute in class Player
Parameters:
The - claim to refute, in the form "[suspect] [weapon] [room] [player]"
Returns:
the ability or inability of the remote player to refute the last suggestion; in the format "show" if not possible, and "show [value]" if possible
Throws:
IllegalTurnException - when the remote player either didn't refute when it could have, or refuted with a card it does not have
TimeoutException
NetworkFailureException

accuse

public java.lang.String accuse()
                        throws IllegalTurnException,
                               TimeoutException,
                               NetworkFailureException,
                               java.lang.IllegalArgumentException
Asks the Player to communicate with its remote counterpart and make an accusation if they wish

Overrides:
accuse in class Player
Returns:
the message to broadcast to all the other players about this player's accusation; in the format "accuse" if not desired and "accuse [suspect] [weapon] [room]" if desired
Throws:
java.lang.IllegalArgumentException - when player's message includes illegal values
IllegalTurnException
TimeoutException
NetworkFailureException

getAnswer

public java.lang.String getAnswer()
                           throws IllegalTurnException,
                                  TimeoutException,
                                  NetworkFailureException
Asks the player to tell us all the pieces of the answer that it knows for sure

Overrides:
getAnswer in class Player
Returns:
A string containing which pieces of the answer are known for certain
Throws:
IllegalTurnException
TimeoutException
NetworkFailureException

forward

public void forward(java.lang.String message)
Forwards the broadcast message to its remote counterpart

Overrides:
forward in class Player
Parameters:
The - message to forward to the remote player

deletePlayer

public void deletePlayer()
Closes all I/O streams and sockets for this player. This must be called for each player in a game, before the game signals that it is finished

Overrides:
deletePlayer in class Player