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