Package com.bdtripp.hauntedhouse.engine
Class GameEngine
java.lang.Object
com.bdtripp.hauntedhouse.engine.GameEngine
Orchestrates the overall game loop and state transitions.
The GameEngine initializes the world, manages game state, delegates command execution, moves the
player between rooms, and generates messages.
- Author:
- Michael Kölling, David J. Barnes, and Brian Tripp
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionBuild the welcome message that displays when a new game is started.Gets a description about the room the player is currently in including the items and characters that it contains.voidendGame()Ends the game.Returns a random room in the haunted housebooleanChecks if the game is overmovePlayerTo(Room nextRoom, boolean addToHistory) Moves the player to the specified room and returns details about the roomprocessCommand(Command command) Given a command, process (that is: execute) the command.voidStarts the game by placing the player in the starting room
-
Constructor Details
-
GameEngine
public GameEngine()Creates the GameEngine and the game world.
-
-
Method Details
-
startGame
public void startGame()Starts the game by placing the player in the starting room -
processCommand
Given a command, process (that is: execute) the command.- Parameters:
command- the command to be processed.- Returns:
- a message to display
-
getRandomRoom
Returns a random room in the haunted house- Returns:
- a random room
-
buildWelcomeMessage
Build the welcome message that displays when a new game is started. Includes information about the room a player is in.- Returns:
- the welcome message
-
describeCurrentRoom
Gets a description about the room the player is currently in including the items and characters that it contains.- Returns:
- a description of the room
-
movePlayerTo
Moves the player to the specified room and returns details about the room- Parameters:
nextRoom- the room to move toaddToHistory- true if the current room should be added to history- Returns:
- the details about the room
-
endGame
public void endGame()Ends the game. -
isGameOver
public boolean isGameOver()Checks if the game is over- Returns:
- true if the game is over, false otherwise
-