Class SimpleHamsterGame
java.lang.Object
de.hamstersimulator.objectsfirst.external.model.SimpleHamsterGame
Deprecated.
Parent class of a simple, to a large extend preconfigured hamster game.
To be used in lectures 2-8 of PSE as predefined base class.
- Author:
- Steffen Becker
-
Nested Class Summary
Modifier and TypeClassDescriptionprotected static class
Deprecated.Different UI types No enum is used because enums use reflection for valueOf which can cause issues if reflection is forbidden -
Field Summary
Modifier and TypeFieldDescriptionprotected SimpleHamsterGame
Deprecated.The current SimpleHamsterGame.protected HamsterGame
Deprecated.The game object of this simple game.protected Hamster
Deprecated.Variable inherited to child classes containing the default hamster which is named paule here. -
Constructor Summary
ConstructorDescriptionDeprecated.Initialized a simple hamster game by loading a default territory and setting protected references to contain the default hamster and the game. -
Method Summary
Modifier and TypeMethodDescriptionprotected void
Deprecated.Displays the hamster game in a new game window The UI type can be specified in the config file or in the environment variable OUTPUT_INTERFACE.void
doRun()
Deprecated.Method to start the execution of a hamster game and handle any exceptions happening while running.Deprecated.Returns the view model used by the game as an output interfaceprotected String
Deprecated.Checks if a game UI mode is requested via environment variables or config and returns that mode in that priority.protected void
loadTerritoryFromResourceFile(String fileName)
Deprecated.Loads the Territory from a resources file.protected void
postRun()
Deprecated.Executed after the run method was executed Can be used, to perform cleanup, or start UI tools Warning: might not be executed!protected abstract void
run()
Deprecated.Predefined hamster method designed to be overridden in subclass.
-
Field Details
-
paule
Deprecated.Variable inherited to child classes containing the default hamster which is named paule here. Intentionally, no getter or setter is used as they are introduced only after lecture 2. -
game
Deprecated.The game object of this simple game. Can be used to start, stop, reset, or display the game. -
currentGame
Deprecated.The current SimpleHamsterGame. Can be used to load a territory or to display the game in a new game window.
-
-
Constructor Details
-
SimpleHamsterGame
public SimpleHamsterGame()Deprecated.Initialized a simple hamster game by loading a default territory and setting protected references to contain the default hamster and the game.
-
-
Method Details
-
run
protected abstract void run()Deprecated.Predefined hamster method designed to be overridden in subclass. Put the hamster code into this method. This parent class version is empty, so that the hamster does not do anything by default. -
doRun
public final void doRun()Deprecated.Method to start the execution of a hamster game and handle any exceptions happening while running. -
postRun
protected void postRun()Deprecated.Executed after the run method was executed Can be used, to perform cleanup, or start UI tools Warning: might not be executed! -
getRequestedUIMode
Deprecated.Checks if a game UI mode is requested via environment variables or config and returns that mode in that priority.If none is requested, the JAVA_FX mode will be requested.
- Returns:
- A non-null String which will be one of the strings in
UIMode
of the currently requested mode,
-
displayInNewGameWindow
protected void displayInNewGameWindow()Deprecated.Displays the hamster game in a new game window The UI type can be specified in the config file or in the environment variable OUTPUT_INTERFACE. Possible values are JAVA_FX, HTTP and NONE The default is JAVA_FX. -
loadTerritoryFromResourceFile
Deprecated.Loads the Territory from a resources file. Only absolute resource paths are allowed. E.g. the fileName "/territory.ter" represents the file territory.ter in the resources directory This resets the game if it was already started. After the territory was loaded, the game is in mode INITIALIZING. To start the game, game.startGame() should be called- Parameters:
fileName
- An absolute path to the resource file. Must start with a "/"- Throws:
IllegalArgumentException
- if fileName is no absolute resource path (does not start with "/") or if the file was not found
-
getGameViewModel
Deprecated.Returns the view model used by the game as an output interfaceThe view model provides information about the current game and can be used to (un)register input interfaces. It is used for adapting the game to a user interface such as the JavaFX UI
- Returns:
- The view model used by the game in this simple hamster game. It is always the same instance and won't be null
-
SimpleHamsterGame