Class HamsterGameViewModel
java.lang.Object
de.hamstersimulator.objectsfirst.adapter.HamsterGameViewModel
Provides all components of a game which are necessary to attach a UI or a test framework to a game
Besides inputInterfaces and the controller, this class only provides read-only access. In particular it is not possible to modify the territory or anything on it or add log messages.
- territory: makes it possible to bind to the territory and observe changes on it
- controller: makes it possible to control the associated game: stop, pause etc.
- log: makes it possible to display log messages
addInputInterface
.Besides inputInterfaces and the controller, this class only provides read-only access. In particular it is not possible to modify the territory or anything on it or add log messages.
-
Constructor Summary
ConstructorDescriptionHamsterGameViewModel(ObservableTerritory territory, HamsterGameController gameController, ObservableLog log, Collection<InputInterface> inputInterfaces)
Creates a new HamsterGameViewModel This is only meant for internal use -
Method Summary
Modifier and TypeMethodDescriptionvoid
addInputInterface(InputInterface newInputInterface)
Adds newInputInterface to this game's input interfaces for reading values from users or mock objects.Getter for the gameController This can be used to control the associated game: stop, pause, resume, undo, redo etc.Gets the input interfaces of this game used to read values from users or mock objects.getLog()
Getter for the log This can be used to get the log entriesGetter for the territory This can be used to observe changes of the territory or objects on it (e.g.void
removeInputInterface(InputInterface inputInterfaceToRemove)
Removes inputInterfaceToRemove from this game's input interfaces for reading values from users or mock objects
-
Constructor Details
-
HamsterGameViewModel
public HamsterGameViewModel(ObservableTerritory territory, HamsterGameController gameController, ObservableLog log, Collection<InputInterface> inputInterfaces)Creates a new HamsterGameViewModel This is only meant for internal use- Parameters:
territory
- the territory, must be != nullgameController
- the gameController to stop, pause etc., must be != nulllog
- the log with all log messages, must be != nullinputInterfaces
- an initial collection of InputInterfaces, must be != null, might be empty
-
-
Method Details
-
getTerritory
Getter for the territory This can be used to observe changes of the territory or objects on it (e.g. hamsters)- Returns:
- The territory (not null)
-
getGameController
Getter for the gameController This can be used to control the associated game: stop, pause, resume, undo, redo etc.- Returns:
- The gameController associated with this game (not null)
-
getLog
Getter for the log This can be used to get the log entries- Returns:
- The ObservableLog associated with this game (not null)
-
getInputInterfaces
Gets the input interfaces of this game used to read values from users or mock objects.- Returns:
- An unmodifiable set which contains all current input interfaces
-
addInputInterface
Adds newInputInterface to this game's input interfaces for reading values from users or mock objects. Duplicates are ignored- Parameters:
newInputInterface
- The new input interface, must be != null.
-
removeInputInterface
Removes inputInterfaceToRemove from this game's input interfaces for reading values from users or mock objects- Parameters:
inputInterfaceToRemove
- The input interface to remove, must be != null
-