VASSAL.build.module
Class GameState
java.lang.Object
|
+--VASSAL.build.module.GameState
- public abstract class GameState
- extends java.lang.Object
The GameState represents the state of the game currently being played. Only one game can be open at once.
- See Also:
GameModule.getGameState()
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
pieces
protected java.util.Hashtable pieces
gameComponents
protected java.util.Vector gameComponents
loadGame
protected javax.swing.JMenuItem loadGame
saveGame
protected javax.swing.JMenuItem saveGame
newGame
protected javax.swing.JMenuItem newGame
closeGame
protected javax.swing.JMenuItem closeGame
lastSave
protected java.lang.String lastSave
GameState
public GameState()
addTo
public void addTo(GameModule mod)
- Expects to be added to a GameModule. Adds
New,
Load, Close, and Save
entries to the File menu of the controls window
isModified
public boolean isModified()
- Returns:
- true if the game state is different from when it was
last saved
addGameComponent
public void addGameComponent(GameComponent theComponent)
- Add a
GameComponent to the list of objects that will
be notified when a game is started/ended
removeGameComponent
public void removeGameComponent(GameComponent theComponent)
- Remove a
GameComponent from the list of objects that will
be notified when a game is started/ended
getGameComponentsEnum
public java.util.Enumeration getGameComponentsEnum()
- Returns:
- an enumeration of all
GameComponent objects
that have been added to this GameState
setup
public void setup(boolean gameStarting)
- Start/end a game. Prompt to save if the game state has been
modified since last save. Invoke
GameComponent.setup(boolean)
on all registered GameComponent objects
isGameStarted
public boolean isGameStarted()
loadGame
public void loadGame()
- Read the game from a savefile. The contents of the file is
sent to
GameModule.decode(java.lang.String) and translated into a
GameState.SetupCommand, which is then executed. The command read from the
file should be that returned by getRestoreCommand()
saveString
protected java.lang.String saveString()
getRestoreCommand
public abstract Command getRestoreCommand()
- Return a
GameState.SetupCommand that, when executed, will restore the
game to its current state. Invokes GameComponent.getRestoreCommand()
on each registered GameComponent
saveGame
public void saveGame()
- Prompts the user for a file into which to save the game
setModified
public void setModified(boolean modified)
addPiece
public void addPiece(GamePiece p)
- Add a
GamePiece to the current game.
The GameState keeps track of all GamePieces in the system,
regardless of which Map they belong to (if any)
getPieceForId
public GamePiece getPieceForId(java.lang.String id)
- Returns:
- the
GamePiece in the current game with the given id
removePiece
public void removePiece(java.lang.String id)
- Remove a
GamePiece from the current game
getNewPieceId
public java.lang.String getNewPieceId()
- Returns:
- a String identifier guaranteed to be different from the
id of all GamePieces in the game
- See Also:
GamePiece.getId()
loadGame
public abstract void loadGame(java.io.File f)
throws java.io.IOException
saveGame
public abstract void saveGame(java.io.File f)
throws java.io.IOException
loadContinuation
public abstract void loadContinuation(java.io.File f)
throws java.io.IOException
getPieces
public java.util.Enumeration getPieces()
- Returns:
- an Enumeration of all
GamePieces in the game.