Glomus.Client.Java
Class JavaClient

java.lang.Object
  extended by Glomus.Client.Java.JavaClient
All Implemented Interfaces:
Client

public class JavaClient
extends java.lang.Object
implements Client

A demonstration client that plays a legal, but ignorant game. To extend, add intelligent behavior to the following methods as desired; additional state may be necessary as well.

See Also:
Glomus.Client.Client, Glomus.Client.ServerConnection

Constructor Summary
JavaClient()
           
 
Method Summary
 void accuse(java.lang.String suspect, java.lang.String weapon, java.lang.String room, java.lang.String player)
          A failed accusation overheard (successful ones end the game, and thus do not need to be reported)
 void answer(java.lang.String suspect, java.lang.String weapon, java.lang.String room, java.lang.String player)
          Tells the client who won and what the answer was
 void cantRefute(java.lang.String suspect, java.lang.String weapon, java.lang.String room, java.lang.String player)
          A failed refutation overheard
 void endKnowledge(java.lang.String suspect, java.lang.String weapon, java.lang.String room, java.lang.String player)
          Informs the player of what another player in the game knows for certain
 void init(java.lang.String identity, java.lang.String startRoom, java.util.HashSet<java.lang.String> suspects, java.util.HashSet<java.lang.String> weapons, java.util.HashMap<java.lang.String,java.util.HashSet<java.lang.String>> rooms, java.util.HashSet<java.lang.String> cards, java.util.ArrayList<java.lang.String> players)
          Initialize the player's knowledgebase with the suspects, weapons, rooms (and their connectivity), and the cards that this player has
 void knows(ServerConnection server)
          A request to determine which pieces of information in the case folder this player knows
static void main(java.lang.String[] args)
          Main connects to the server, initializes the game, and has the server play with an instance of this class for the 'brains'
 void makeAccusation(ServerConnection server)
          A request for this player to make an accusation, if we wish
 void makeSuggestion(ServerConnection server)
          A request for this player to make a suggestion
 void message(java.lang.String message)
          Notifies the client of some user-specific information
 void refute(java.lang.String suspect, java.lang.String weapon, java.lang.String room, java.lang.String player, ServerConnection server)
          A request for this player to refute the claim, if possible
 void refuted(java.lang.String suspect, java.lang.String weapon, java.lang.String room, java.lang.String player)
          A refuted suggestion overheard
 void shows(java.lang.String player, java.lang.String card)
          A refutation of our suggestion from another player
 void suggestion(java.lang.String suspect, java.lang.String weapon, java.lang.String room, java.lang.String player)
          A suggestion overheard by all players
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

JavaClient

public JavaClient()
Method Detail

init

public void init(java.lang.String identity,
                 java.lang.String startRoom,
                 java.util.HashSet<java.lang.String> suspects,
                 java.util.HashSet<java.lang.String> weapons,
                 java.util.HashMap<java.lang.String,java.util.HashSet<java.lang.String>> rooms,
                 java.util.HashSet<java.lang.String> cards,
                 java.util.ArrayList<java.lang.String> players)
Initialize the player's knowledgebase with the suspects, weapons, rooms (and their connectivity), and the cards that this player has

Specified by:
init in interface Client
Parameters:
identity - Our name
startRoom - Our starting location
suspects - The set of all suspect names
weapons - The set of all weapon names
rooms - The map of all rooms to a list of adjacent rooms
cards - The set of all cards this player has
players - A list of suspects who are active in the game, in order of play (if that's important)

suggestion

public void suggestion(java.lang.String suspect,
                       java.lang.String weapon,
                       java.lang.String room,
                       java.lang.String player)
A suggestion overheard by all players

Specified by:
suggestion in interface Client
Parameters:
suspect - Who did it
weapon - How they did it
room - Where they did it
player - The player making the accusation

makeSuggestion

public void makeSuggestion(ServerConnection server)
A request for this player to make a suggestion

Specified by:
makeSuggestion in interface Client
Parameters:
server - The Glomus Server to reply to

makeAccusation

public void makeAccusation(ServerConnection server)
A request for this player to make an accusation, if we wish

Specified by:
makeAccusation in interface Client
Parameters:
server - The Glomus Server to reply to

refute

public void refute(java.lang.String suspect,
                   java.lang.String weapon,
                   java.lang.String room,
                   java.lang.String player,
                   ServerConnection server)
A request for this player to refute the claim, if possible

Specified by:
refute in interface Client
Parameters:
suspect - Who did it
weapon - How they did it
room - Where they did it
player - The player making the accusation
server - The Glomus Server to reply to

refuted

public void refuted(java.lang.String suspect,
                    java.lang.String weapon,
                    java.lang.String room,
                    java.lang.String player)
A refuted suggestion overheard

Specified by:
refuted in interface Client
Parameters:
suspect - Who did it
weapon - How they did it
room - Where they did it
player - The player who refuted the suggestion

cantRefute

public void cantRefute(java.lang.String suspect,
                       java.lang.String weapon,
                       java.lang.String room,
                       java.lang.String player)
A failed refutation overheard

Specified by:
cantRefute in interface Client
Parameters:
suspect - Who did it
weapon - How they did it
room - Where they did it
player - is the player who could not refute the suggestion

accuse

public void accuse(java.lang.String suspect,
                   java.lang.String weapon,
                   java.lang.String room,
                   java.lang.String player)
A failed accusation overheard (successful ones end the game, and thus do not need to be reported)

Specified by:
accuse in interface Client
Parameters:
suspect - Who did it
weapon - How they did it
room - Where they did it
player - The player who failed their accusation

shows

public void shows(java.lang.String player,
                  java.lang.String card)
A refutation of our suggestion from another player

Specified by:
shows in interface Client
Parameters:
player - The player who is refuting our suggestion
card - A suspect, weapon, or room that they show to us, refuting our claim

knows

public void knows(ServerConnection server)
A request to determine which pieces of information in the case folder this player knows

Specified by:
knows in interface Client
Parameters:
server - The Glomus Server to reply to

endKnowledge

public void endKnowledge(java.lang.String suspect,
                         java.lang.String weapon,
                         java.lang.String room,
                         java.lang.String player)
Informs the player of what another player in the game knows for certain

Specified by:
endKnowledge in interface Client
Parameters:
suspect - Who did it
weapon - How they did it
room - Where they did it
player - The player who knows the given info

answer

public void answer(java.lang.String suspect,
                   java.lang.String weapon,
                   java.lang.String room,
                   java.lang.String player)
Tells the client who won and what the answer was

Specified by:
answer in interface Client
Parameters:
suspect - Who did it
weapon - How they did it
room - Where they did it
player - The player who won the game

message

public void message(java.lang.String message)
Notifies the client of some user-specific information

Specified by:
message in interface Client
Parameters:
message - The message to pass onto the user

main

public static void main(java.lang.String[] args)
                 throws java.io.IOException
Main connects to the server, initializes the game, and has the server play with an instance of this class for the 'brains'

Parameters:
args - Parameters for setting up the game
Throws:
java.io.IOException