public class Game
extends java.lang.Object
Modifier and Type | Field and Description |
---|---|
static int |
DEFAULT_FRAME
The default frame value.
|
static java.lang.String |
MAP_DIRECTORY
The directory that contains the map.
|
static java.lang.String |
MAP_EXTENSION
The extension of the maps' file name --usually .txt .
|
Constructor and Description |
---|
Game(java.lang.String managerClassname,
java.io.File f)
Constructor: a game instance with a set Board that is read from File f, using
the manager whose class name is managerClassname.
|
Game(java.lang.String managerClassname,
java.io.File f,
int frame)
Constructor: a game instance with a set Board that is read from File f, using
the manager whose class name is managerClassname, and uses the given frame rate
|
Game(java.lang.String managerClassname,
long seed)
Constructor: a game instance with a random board from seed seed using
the manager whose class name is managerClassname.
|
Game(java.lang.String managerClassname,
long seed,
int frame)
Constructor: a game instance with a random board from seed seed using
the manager whose class name is managerClassname, and uses the given frame rate.
|
Modifier and Type | Method and Description |
---|---|
static java.io.File |
gameFile(java.lang.String filename)
Return a file for the string board filename.
|
Board |
getBoard()
Return the board of this game.
|
java.io.File |
getFile()
Return the file from which this game was created
(null if created randomly and thus not loaded).
|
int |
getFrame()
Return the duration of a frame for this game, in milliseconds
|
GUI |
getGUI()
Return the GUI that represents this game.
|
Manager |
getManager()
Return the manager for this Game.
|
java.lang.String |
getManagerClassname()
Return a String of the class name used to load the manager.
|
long |
getSeed()
Return the seed from which this game was generated from (-1 if this game
was loaded from a non-randomly generated file.)
|
java.lang.Throwable |
getThrownThrowable()
Return the exception thrown during the running of this game.
|
java.lang.String |
getUpdateMessage()
Return the current update message shown on the GUI.
|
boolean |
isFinished()
Return true iff this game is finished.
|
boolean |
isFrameAltered()
Return true iff the frame rate of this game was altered in
such a way that changed the running of the game
|
boolean |
isRunning()
Return true iff this game is currently running (in progress, not completed).
|
void |
kill()
End this game prematurely by halting trucks and manager.
|
int[] |
parcelStats()
Return the parcel stats for the current game in the form
[on city, on truck, delivered]
|
void |
setFrame(int f)
Set the duration of a frame for this game, in milliseconds.
|
void |
setGUI(GUI g)
Set the GUI that draws this game to g.
|
boolean |
setManager(java.lang.String managerClassname)
If the manager and managerClass are null, set the manager to the class whose
name is managerClassname.
|
void |
setUpdateMessage(java.lang.String s)
Update the GUI to show s as an update message for a few seconds.
|
void |
start()
Start the game by the manager run; then have each truck begin running.
|
int[] |
truckStats()
Return the truck stats for the current game in the form
[waiting, traveling, getting manager input]
|
void |
writeGame(java.lang.String fileName)
Write this Game to a text file that can be loaded and re-played later.
|
public static final java.lang.String MAP_DIRECTORY
public static final java.lang.String MAP_EXTENSION
public static final int DEFAULT_FRAME
public Game(java.lang.String managerClassname, java.io.File f)
public Game(java.lang.String managerClassname, java.io.File f, int frame)
public Game(java.lang.String managerClassname, long seed)
public Game(java.lang.String managerClassname, long seed, int frame)
public boolean setManager(java.lang.String managerClassname)
public int getFrame()
public void setFrame(int f) throws java.lang.IllegalArgumentException
java.lang.IllegalArgumentException
- if f <= 0public boolean isFrameAltered()
public boolean isRunning()
public boolean isFinished()
public Board getBoard()
public Manager getManager()
public java.lang.String getManagerClassname()
public java.io.File getFile()
public long getSeed()
public void start()
public java.lang.Throwable getThrownThrowable()
public GUI getGUI()
public void setGUI(GUI g)
public java.lang.String getUpdateMessage()
public void setUpdateMessage(java.lang.String s)
public int[] parcelStats()
public int[] truckStats()
public void kill()
public static java.io.File gameFile(java.lang.String filename) throws java.lang.IllegalArgumentException
java.lang.IllegalArgumentException
public void writeGame(java.lang.String fileName) throws java.io.IOException, java.lang.RuntimeException
java.io.IOException
- - If the file writing goes bad.java.lang.RuntimeException
- if the game is not in its pre-start state.