|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.ObjectGlomus.Server.Player
public class Player
The Player class is the server-side representation of a remote player. Two types of Players exist in a game (both use the same class), user players, who have a remote AI that is being tested through a series of games, and replacement players, who use a server-side AI and act as other players to test the user AI against.
Notes about usage: Before a Player is ready to play a game, the Initialization method must be called to setup all the player and GameBoard data. Once a Player has played all games it will play, the delete method should be called to allow the Player a chance to close all I/O, etc. Actual game play is via the refute, suggest, and accuse methods. All broadcasting must use the forward method.
The Player class depends heavily upon the common protocol defined for client-server interactions. Reference the Protocol class for more information.
Protocol,
GameBoard| Constructor Summary | |
|---|---|
Player(java.net.Socket link)
Creates the server-side representation of a 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 |
forceMove(java.lang.String newLocation)
Unconditionally moves a player from one room to another (This is used by the Server to move a player to a room they were suggested in) |
void |
forward(java.lang.String message)
Forwards the broadcast message to its remote counterpart |
java.lang.String |
getAnswer()
Asks the player to send all the pieces of the answer that it knows for certain |
java.util.HashSet<java.lang.String> |
getCards()
Returns this player's set of cards |
java.lang.String |
getInit()
Returns the last initialization message this Player received |
java.lang.String |
getLocation()
Returns the player's current location |
java.lang.String |
getName()
Asks the Player to return its name |
void |
initialize(java.lang.String initMessage,
java.lang.String name,
java.lang.String startingRoom,
java.util.HashSet<java.lang.String> cards,
java.util.ArrayList<java.lang.String> players,
java.util.HashSet<java.lang.String> suspects,
java.util.HashSet<java.lang.String> weapons,
java.util.HashSet<java.lang.String> rooms,
java.util.HashMap<java.lang.String,java.util.HashSet<java.lang.String>> connections)
Initializes a player for a given game and GameBoard. |
java.lang.String |
refute(java.lang.String claim)
Asks the Player to communicate with its remote counterpart and refute 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 java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public Player(java.net.Socket link)
throws java.io.IOException,
java.lang.IllegalArgumentException
link - The Socket on which the real remote player is
communicating
java.io.IOException - If the I/O streams from the socket cannot be
initialized
java.lang.IllegalArgumentException - If a null value is specified
for the link| Method Detail |
|---|
public void initialize(java.lang.String initMessage,
java.lang.String name,
java.lang.String startingRoom,
java.util.HashSet<java.lang.String> cards,
java.util.ArrayList<java.lang.String> players,
java.util.HashSet<java.lang.String> suspects,
java.util.HashSet<java.lang.String> weapons,
java.util.HashSet<java.lang.String> rooms,
java.util.HashMap<java.lang.String,java.util.HashSet<java.lang.String>> connections)
throws java.lang.IllegalArgumentException
initMessage - The initialization message, containing all the
data specified in the following arguments (kept so that it can be
passed on to the remote player, if there is one, and to a
ServerPlayer if need be)name - The name of this characterstartingRoom - The room this character will start incards - This player's cards for this gameplayers - All suspects who are also active players in this gamesuspects - The list of all suspectsweapons - The list of all weaponsrooms - The list of all roomsconnections - A connection detailing for each room which
other rooms it connects to
java.lang.IllegalArgumentException - If a null argument is given or if
any of the lists do not contain enough information
public java.lang.String suggest()
throws IllegalTurnException,
TimeoutException,
NetworkFailureException,
java.lang.IllegalArgumentException
IllegalTurnException - if player does not move to a proper
room
java.lang.IllegalArgumentException - When player's message includes
illegal values
TimeoutException
NetworkFailureException
public java.lang.String refute(java.lang.String claim)
throws IllegalTurnException,
TimeoutException,
NetworkFailureException
claim - The claim to refute, in the form "[suspect] [weapon]
[room] [player]"
IllegalTurnException - when the remote player either didn't
refute when it could have, or refuted with a card it does not have
TimeoutException
NetworkFailureException
public java.lang.String accuse()
throws IllegalTurnException,
TimeoutException,
NetworkFailureException,
java.lang.IllegalArgumentException
java.lang.IllegalArgumentException - when player's message includes
illegal values
IllegalTurnException
TimeoutException
NetworkFailureException
public java.lang.String getAnswer()
throws IllegalTurnException,
TimeoutException,
NetworkFailureException
IllegalTurnException
TimeoutException
NetworkFailureExceptionpublic void forward(java.lang.String message)
message - The message to forward to the remote playerpublic void deletePlayer()
public void forceMove(java.lang.String newLocation)
throws java.lang.IllegalArgumentException
java.lang.IllegalArgumentException - If the location to move to is
nullpublic java.lang.String getName()
public java.lang.String getLocation()
public java.util.HashSet<java.lang.String> getCards()
public java.lang.String getInit()
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||