|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectjava.lang.Thread
Glomus.Server.GameBoard
public class GameBoard
The GameBoard class oversees and manages the running of a Glomus game.
GameBoard has an initial mode it waits in until the game is ready to be run (either by time limit or because it is full). Gameboard will then run through a set number of individual games, logging results, replacing misbehaving players, etc. Any given game within the set of games played will have a random turn order though the same player will always play as the same suspect throughout all games to ensure consistency in the log file. (IE- Mr Green will always be Mr Green, Miss Scarlet always Miss Scarlet, etc). The GameBoard polices all games played, and replaces without question any misbehaving player with a standard default player that is known to play a legal game. Players receive no second chances, being kicked out is final. If all players in a given set of games have been kicked out the GameBoard ceases with testing (there is no point to test Server Side players against each other). The GameBoard class differentiates between players added via the addPlayer method (which are assumed to be user players) and players it adds to run a full game. Players added via the addPlayer method are treated as user-end clients, all other players are treated as Server-side agents.
The GameBoard class is its own Thread and runs entirely separately from the Server class. Once Execution is finished (nicely or not) the GameBoard signals the Server that it has finished and exits.
The GameBoard, like all classes in the Glomus.Server package, depends upon the Protocol class to determine what is legal communication protocol and detect illegal protocol accordingly.
Protocol,
Player| Nested Class Summary |
|---|
| Nested classes/interfaces inherited from class java.lang.Thread |
|---|
java.lang.Thread.State, java.lang.Thread.UncaughtExceptionHandler |
| Field Summary | |
|---|---|
protected static java.lang.String |
DEFAULT_CONFIGURATION
The configuration that describes a default clue game |
protected static int |
POINTS_FOR_CORRECT
The number of points given to a player for each known piece of the answer that is correct |
protected static int |
POINTS_FOR_WIN
The number of 'bonus' points given to the player who won the game |
| Fields inherited from class java.lang.Thread |
|---|
MAX_PRIORITY, MIN_PRIORITY, NORM_PRIORITY |
| Constructor Summary | |
|---|---|
GameBoard(java.lang.String name,
Player newPlayer,
boolean open,
int maxPlayers,
int iterations)
Constructs a new game with the classic setup |
|
GameBoard(java.lang.String name,
Player newPlayer,
boolean open,
int maxPlayers,
int iterations,
java.lang.String board)
Constructs a new, custom game board |
|
| Method Summary | |
|---|---|
void |
addPlayer(Player toAdd)
Adds a user-player to the game (should only be called during setup, calling after a game has launched will result in an IllegalArgumentException being thrown) |
boolean |
full()
Tells whether or not the game is full and thus if it can accept more players legally (a game is full when it has as many players as requested by the player who initially created it, not necessarily when it has as many players as it does suspects) |
java.lang.String |
getGameName()
Returns the name of this game |
long |
getTime()
Returns the system time in milleseconds of this GameBoard's creation. |
protected boolean |
handleAccusation()
Asks the current player to make an accusation (if they so desire) |
protected void |
handleRefute(java.lang.String claim)
Asks, everyone to refute the claim made by the current player (excepting the current player itself) |
protected java.lang.String |
handleSuggestion()
Asks for a suggestion/claim from the current player |
protected static Player |
replace()
Creates a Server-side replacement player ready to play a game (this method only obtains a new legal player, this player must still be initialized and placed in the rotation) |
void |
run()
The 'main' method of the Game; calling run sets up the game cycle and starts testing the players |
protected void |
setup()
Sets up a new game and makes it ready to play |
| Methods inherited from class java.lang.Thread |
|---|
activeCount, checkAccess, countStackFrames, currentThread, destroy, dumpStack, enumerate, getAllStackTraces, getContextClassLoader, getDefaultUncaughtExceptionHandler, getId, getName, getPriority, getStackTrace, getState, getThreadGroup, getUncaughtExceptionHandler, holdsLock, interrupt, interrupted, isAlive, isDaemon, isInterrupted, join, join, join, resume, setContextClassLoader, setDaemon, setDefaultUncaughtExceptionHandler, setName, setPriority, setUncaughtExceptionHandler, sleep, sleep, start, stop, stop, suspend, toString, yield |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Field Detail |
|---|
protected static final int POINTS_FOR_CORRECT
protected static final int POINTS_FOR_WIN
protected static final java.lang.String DEFAULT_CONFIGURATION
| Constructor Detail |
|---|
public GameBoard(java.lang.String name,
Player newPlayer,
boolean open,
int maxPlayers,
int iterations)
throws java.lang.IllegalArgumentException
name - The name this session of games is registered under
with the ServernewPlayer - The first player of the game (the one who
requested to play in the first place.) More players may be added
via the addPlayer methodopen - Defines if this is an open of closed game. If true,
other user players will be allowed to connect to this game and
play, if false, only the specified user player, and a group of
computer players will playmaxPlayers - The number of agents, or real players, that will
play the gameiterations - The number of individual games to play with the
same set of players
java.lang.IllegalArgumentException - If the default values were not
initialized, if any of the given values are null, if they have
zero length, or if more players are specified than there are
characters to play as
public GameBoard(java.lang.String name,
Player newPlayer,
boolean open,
int maxPlayers,
int iterations,
java.lang.String board)
throws java.lang.IllegalArgumentException
name - The name this session of games is registered under
with the ServernewPlayer - The first player of the game (the one who
requested to play in the first place.) More players may be added
via the addPlayer methodopen - Defines if this is an open of closed game. If true,
other user players will be allowed to connect to this game and
play, if false, only the specified user player, and a group of
computer players will playmaxPlayers - The number of agents, or real players, that will
play the gameiterations - The number of individual games to play with the
same set of playersboard - The String provided from the client that specifies the
game board, its suspects weapons, and rooms
java.lang.IllegalArgumentException - If any of the given values are
null, if they have zero length, if more players are specified than
there are characters to play as, or if any of the specified
GameBoard data in the board string would construct a board that is
inconsistent or illegal| Method Detail |
|---|
public long getTime()
public java.lang.String getGameName()
public void addPlayer(Player toAdd)
throws java.lang.IllegalArgumentException
toAdd - The player to add to this set of games
java.lang.IllegalArgumentException - If the player to add is null, or
if the game is fullpublic boolean full()
protected static Player replace()
throws java.io.IOException,
java.lang.InterruptedException,
java.lang.IllegalArgumentException
java.io.IOException
java.lang.InterruptedException
java.lang.IllegalArgumentExceptionpublic void run()
run in interface java.lang.Runnablerun in class java.lang.Thread
protected java.lang.String handleSuggestion()
throws java.io.IOException,
java.lang.IllegalArgumentException,
java.lang.InterruptedException
java.io.IOException
java.lang.IllegalArgumentException
java.lang.InterruptedException
protected void handleRefute(java.lang.String claim)
throws java.io.IOException,
java.lang.IllegalArgumentException,
java.lang.InterruptedException
claim - The claim made by the current player
java.io.IOException
java.lang.IllegalArgumentException
java.lang.InterruptedException
protected boolean handleAccusation()
throws java.io.IOException,
java.lang.IllegalArgumentException,
java.lang.InterruptedException
java.io.IOException
java.lang.IllegalArgumentException
java.lang.InterruptedException
protected void setup()
throws java.lang.IllegalArgumentException
java.lang.IllegalArgumentException
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||