Package com.edu.xmum.CST210.Service
Class GameService
java.lang.Object
com.edu.xmum.CST210.Service.GameService
- All Implemented Interfaces:
IGameService
Implementation of the IGameService interface.
Provides methods to manage and control the game state and its components.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionGets the AI service instance.List<int[]>getHint()Provides a hint for the player by returning the path to the goal.Gets the maze service instance.Gets the player service instance.This version does not require a second player.booleanmovePlayer(Direction direction) Moves the player in the specified direction.booleanmoveSecondPlayer(Direction direction) This version does not require a second player.voidResets the game to its initial state, including player, maze, and AI.voidsetDifficulty(Difficulty difficulty) Sets the game difficulty by adjusting the maze size and AI position.
-
Constructor Details
-
GameService
Constructor for GameService. Uses the factory pattern to initialize the maze, player, and AI services.- Parameters:
gameModel- The game model instance.
-
-
Method Details
-
setDifficulty
Sets the game difficulty by adjusting the maze size and AI position.- Specified by:
setDifficultyin interfaceIGameService- Parameters:
difficulty- The difficulty level to set.
-
resetGame
public void resetGame()Resets the game to its initial state, including player, maze, and AI.- Specified by:
resetGamein interfaceIGameService
-
movePlayer
Moves the player in the specified direction.- Specified by:
movePlayerin interfaceIGameService- Parameters:
direction- The direction to move the player.- Returns:
- True if the move is valid and the player is moved, false otherwise.
-
getHint
Provides a hint for the player by returning the path to the goal.- Specified by:
getHintin interfaceIGameService- Returns:
- A list of coordinate pairs representing the path to the goal.
-
moveSecondPlayer
This version does not require a second player.- Specified by:
moveSecondPlayerin interfaceIGameService- Parameters:
direction- The direction to move the second player.- Returns:
- False as second player functionality is not required.
-
getPlayerService
Gets the player service instance.- Specified by:
getPlayerServicein interfaceIGameService- Returns:
- The player service instance.
-
getAiService
Gets the AI service instance.- Specified by:
getAiServicein interfaceIGameService- Returns:
- The AI service instance.
-
getMazeService
Gets the maze service instance.- Specified by:
getMazeServicein interfaceIGameService- Returns:
- The maze service instance.
-
getSecondPlayerService
This version does not require a second player.- Specified by:
getSecondPlayerServicein interfaceIGameService- Returns:
- Null as second player functionality is not required.
-