|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--java.lang.Thread | +--org.gjt.universe.GameEngine
This class starts and runs the game.
Nested Class Summary | |
private class |
GameEngine.ProcessedTurnStruct
|
Field Summary | |
private boolean |
gameOptionsProcessed
Flag to indicate whether the game options have been processed. |
private boolean |
gameOptionsSubmitted
Flag to indicate whether the game options have been submitted. |
private GameOptions |
options
The game options |
static java.util.Random |
randomGen
|
private static boolean |
running
Flag to indicate whether the game is currently running. |
private static GameEngine |
single
Instance of GameEngine used in implementing the Singleton design pattern. |
private java.util.Vector |
turnListeners
Data structure containing registered TurnListeners. |
private int |
turnNumber
Current turn number. |
private java.util.Vector |
turnSubmitted
The |
Fields inherited from class java.lang.Thread |
MAX_PRIORITY, MIN_PRIORITY, NORM_PRIORITY |
Constructor Summary | |
private |
GameEngine()
Instantiate GameEngine with default state. |
Method Summary | |
void |
addTurnProcessedListener(TurnProcessedListener tpl)
Register a listener to receive notification when turns have been processed. |
private boolean |
allTurnsSubmitted()
Returns true if all players have submitted their turn. |
(package private) void |
AutoProcessing()
|
static void |
ExitGame()
Flag the game to be exited at the end of the current turn. |
(package private) void |
ExternalCommunication()
|
static boolean |
gameOptionsProcessed()
Find out whether the game options have been processed. |
static GameOptions |
getGameOptions()
Provides access to the game options currently in effect. |
static int |
getTurnNumber()
Returns the current turn number. |
static GameEngine |
Initialize()
Initialise the game engine, creating the singleton instance of GameEngine. |
static GameEngine |
Instance()
Return the singleton instance of the GameEngine. |
(package private) void |
processGameOptions()
|
(package private) void |
processTurn()
The main turn processing mechanism. |
(package private) static void |
readObject(java.io.ObjectInputStream in)
|
static boolean |
ReadyToExit()
Returns true if the game has been flagged to exit. |
void |
registerGameOptions(GameOptions in_GO)
|
void |
removeTurnProcessedListener(TurnProcessedListener tpl)
Unregister a listener to receive notification when turns have been processed. |
void |
run()
Main game loop. |
void |
submitGameOptions(GameOptions in_GO)
|
(package private) boolean |
submittedTurn(PlayerID pid)
Discover whether a specified civ has submitted their turn in the current game turn. |
(package private) static void |
SubmitTurn(TurnBase turn)
Interface for allowing players to submit turns. |
(package private) static void |
writeObject(java.io.ObjectOutputStream out)
|
Methods inherited from class java.lang.Thread |
activeCount, checkAccess, countStackFrames, currentThread, destroy, dumpStack, enumerate, getContextClassLoader, getName, getPriority, getThreadGroup, holdsLock, interrupt, interrupted, isAlive, isDaemon, isInterrupted, join, join, join, resume, setContextClassLoader, setDaemon, setName, setPriority, 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 |
private static GameEngine single
private GameOptions options
private int turnNumber
private static boolean running
private boolean gameOptionsSubmitted
private boolean gameOptionsProcessed
public static java.util.Random randomGen
private java.util.Vector turnSubmitted
turnSubmittedfield contains a list of instances of
ProcessedTurnStructobjects, each of which acts as a pigeonhole for a civ to submit a turn into. The presence of a value in the turnSubmitted data structure does not guarantee that this is a current turn ready to be processed: instead the
ProcessedTurnStructinstance should be consulted to check the
submittedvalue.
private java.util.Vector turnListeners
Constructor Detail |
private GameEngine()
Method Detail |
public static GameEngine Initialize()
public void run()
run
in interface java.lang.Runnable
run
in class java.lang.Thread
public static GameEngine Instance()
static void SubmitTurn(TurnBase turn)
public static void ExitGame()
public static boolean ReadyToExit()
public static int getTurnNumber()
public void registerGameOptions(GameOptions in_GO)
public void submitGameOptions(GameOptions in_GO)
public static boolean gameOptionsProcessed()
void processGameOptions()
boolean submittedTurn(PlayerID pid)
void AutoProcessing()
void ExternalCommunication()
void processTurn()
This method should be invoked once per turn.
private boolean allTurnsSubmitted()
public static GameOptions getGameOptions()
public void addTurnProcessedListener(TurnProcessedListener tpl)
public void removeTurnProcessedListener(TurnProcessedListener tpl)
static void writeObject(java.io.ObjectOutputStream out) throws java.io.IOException
java.io.IOException
static void readObject(java.io.ObjectInputStream in) throws java.io.IOException, java.lang.ClassNotFoundException
java.io.IOException
java.lang.ClassNotFoundException
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |